Simulate input/Mouse: Difference between revisions

From Rosetta Code
Content added Content deleted
(mouse click)
 
(→‎Tcl: Added implementation)
Line 1: Line 1:
{{task|GUI}}Simulate the click of a mouse button by the user.
{{task|GUI}}Simulate the click of a mouse button by the user.
<br clear=all>

=={{header|AutoHotkey}}==
=={{header|AutoHotkey}}==
Line 10: Line 10:
Click 200, 200 right
Click 200, 200 right
</lang>
</lang>

=={{header|Tcl}}==
{{libheader|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>

Revision as of 10:14, 27 May 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.


AutoHotkey

<lang AutoHotkey> /* simulate a right mouse click 200 pixels right and down from the top left of the screen.

  • /

CoordMode, Mouse, Screen Click 200, 200 right </lang>

Tcl

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>