Scalabium Software

SMExport advertising
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.
But if you need "press" on button, do a something and release a button, then call a PressMouseDown, execute the some own code and call the PressMouseUp.


Published: January 6, 2001

See also
 
ABA Picture Convert
ABA Database Convert
Word Web-stream
Clarion to Text converter
Excel Reader (dll)
DBExport tools
Database Information Manager
ABA Spreadsheet Convert
SMImport suite
ABA Document Convert
 
 


Contact to webmaster

 

Borland Software Code Gear Scalabium Delphi tips

Copyright© 1998-2024, Scalabium Software. All rights reserved.
webmaster@scalabium.com

SMExport advertising