Simulate input/Mouse: Difference between revisions

From Rosetta Code
Content added Content deleted
(specify if external windows are ok)
(moving "where it came from" category to talk page)
Line 2: Line 2:
Specify if the target gui may be externally created.
Specify if the target gui may be externally created.
__TOC__
__TOC__
<br clear=all>
=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
target gui may be externally created.
target gui may be externally created.
Line 21: Line 22:
Note that many of Tk's windows also need appropriate <Enter> and <Leave> events in order to work correctly. For the process of actually simulating a click on a button, it is actually easier to work at the method-call level rather than the event generation level:
Note that many of Tk's windows also need appropriate <Enter> and <Leave> events in order to work correctly. For the process of actually simulating a click on a button, it is actually easier to work at the method-call level rather than the event generation level:
<lang tcl>.okBtn invoke</lang>
<lang tcl>.okBtn invoke</lang>



[[Category:AutoHotkey_Originated]]

Revision as of 08:45, 3 June 2009

Task
Simulate input/Mouse
You are encouraged to solve this task according to the task description, using any language you may know.

Simulate the click of a mouse button by the user.

Specify if the target gui may be externally created.


AutoHotkey

target gui may be externally created. <lang AutoHotkey> WinActivate, ahk_class MozillaUIWindowClass Click 200, 200 right  ; relative to external window (firefox) sleep, 2000 WinMinimize CoordMode, Mouse, Screen Click 400, 400 right  ; relative to top left corner of the screen. </lang>

Tcl

Within an Application

Library: Tk

<lang tcl># Simulate a full click cycle: button down and up event generate .okBtn <ButtonPress-1> -x 5 -y 5 event generate .okBtn <ButtonRelease-1> -x 5 -y 5</lang> Note that many of Tk's windows also need appropriate <Enter> and <Leave> events in order to work correctly. For the process of actually simulating a click on a button, it is actually easier to work at the method-call level rather than the event generation level: <lang tcl>.okBtn invoke</lang>