Scalabium Software |
|
Knowledge for your independence'. | |
Home Delphi and C++Builder tips |
#112: How can I press a mouse button from code? |
|
Sometimes you need press a left and/or right mouse button from code without any user activity. For example, as part of demo program which demonstrates the possibilities of your application. You can use the next procedures which simulates a mouse activity: procedure PressMouseDown(IsLeftButton: Boolean); begin if IsLeftButton then mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) else mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); end; procedure PressMouseUp(IsLeftButton: Boolean); begin if IsLeftButton then mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0) else mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); end; procedure ClickMouseButton(IsLeftButton: Boolean); begin PressMouseDown(IsLeftButton); PressMouseUp(IsLeftButton); end; So if you need "click" on mouse button, call the
ClickMouseButton procedure.
|
Copyright© 1998-2024, Scalabium
Software. All rights reserved. |