How can I detect mouse clicks and keyboard presses?
Moderators: JRL, Dorian (MJT support)
How can I detect mouse clicks and keyboard presses?
Hi. I have a question. How can I detect mouse clicks and keyboard button presses? For example, when the user clicks somewhere in the screen, the script will take the x and y coordinates of the clicked pixel and do something with the coordinates. For another example, each time the user presses "A" from the keyboard, the script will do something. Thank you.
I think what you're looking for is WaitKeyDown. Read the documentation its fairly straightforward. I have never been able to get the virtual keys to work for mouse clicks. I have circumvented this by leaving a message to the user to position the mouse as needed and then press a key (usually the space bar). And using GetCursorPos (GCP) to grab the cursor coordinates. Here is an example.
MDL>Position the cursor and press the Space Bar.%CRLF%Pick OK to continue
WaitKeyDown>VK32
GCP>x,y
MDL>mouse positioned at %x%,%y%
Hope this helps,
Dick
MDL>Position the cursor and press the Space Bar.%CRLF%Pick OK to continue
WaitKeyDown>VK32
GCP>x,y
MDL>mouse positioned at %x%,%y%
Hope this helps,
Dick