Difference between revisions of "MouseAndKeyInput"

From Lazarus wiki
Jump to navigationJump to search
Line 28: Line 28:
 
===How to===
 
===How to===
 
With your project open:
 
With your project open:
Go to the Lazarus install directory -> components -> mouseandkeyinput.
+
Go to the Lazarus install directory -> components -> mouseandkeyinput.
There you will find: lazmouseandkeyinput.lpk
+
There you will find: lazmouseandkeyinput.lpk
 
Open and compile the .lpk.  
 
Open and compile the .lpk.  
  

Revision as of 19:22, 4 January 2015

About

MouseAndKeyInput package is a tool for cross-platform manipulation with mouse and key input. You can move mouse cursor to specified location, send clicks and do key presses. It is suitable for GUI testing or program control demonstration.

Location

lazarusdir/components/mouseandkeyinput

Author

Tom Gregorovic

License

GPL

Change Log

  • Version 0.1

Restrictions

  • it is not recommended calling mouse and key input directly from events like OnClick, use Application.QueueAsyncCall instead
  • do not forget to set back mouse button and key state after Down method with Up method

Carbon

  • pressing alpha chars is not supported

Gtk1/2

  • needs Xtst library
  • ALT key pressing is not supported


How to

With your project open: Go to the Lazarus install directory -> components -> mouseandkeyinput. There you will find: lazmouseandkeyinput.lpk. Open and compile the .lpk.

In your unit.pas add in Uses: MouseAndKeyInput ,LCLType

To simulate press of F1 from a button:

procedure TForm1.HelpButtonClick(Sender: TObject); begin

 Application.ProcessMessages;
 KeyInput.Press(VK_F1);             // This will simulate press of F1 function key.

end;

VK- def's is found here: http://lazarus-ccr.sourceforge.net/docs/lcl/lcltype/index-2.html