I have a script where I need the user to click somewhere on a window and get the mouse coordinates of where they clicked. Input won't work as it waits for a string to be entered.
Is there some way to do this? Don't really need a prompt, as it would be at the beginning when the script is first run by a hotkey. I would then wait for a click, save the coordinates, and go from there.
Thanks
Wait for mouse click, save coordinates Topic is solved
Re: Wait for mouse click, save coordinates
Code: Select all
~LButton::
MouseGetPos, X, Y, WindowUnderMouse, ControlUnderMouse
; WinGetTitle, title, ahk_id %WindowUnderMouse%
; If (title = "Untitled - Notepad" and ControlUnderMouse = "Edit1" and X>100 and Y<200)
; ToolTip, X = %X%`nY = %Y% ; do sth
return
Code: Select all
MouseGetPos, X, Y, A ; A means the active window
Re: Wait for mouse click, save coordinates
Thanks for the reply GEV, but that's not quite what I need. Also, I didn't explain myself very well.
Here's how the flow of the script should be:
Script is started via hotkey and waits for user to click somewhere on the screen
Use MouseGetPos and save the X & Y coordinates
Wait for user to click somewhere else on the screen
Use MouseGetPos and save the second X & Y coordinates
Continue executing the rest of the script
I just can't figure out how to get the script to wait for those two clicks.
Here's how the flow of the script should be:
Script is started via hotkey and waits for user to click somewhere on the screen
Use MouseGetPos and save the X & Y coordinates
Wait for user to click somewhere else on the screen
Use MouseGetPos and save the second X & Y coordinates
Continue executing the rest of the script
I just can't figure out how to get the script to wait for those two clicks.
Re: Wait for mouse click, save coordinates Topic is solved
Hallo,
try:
try:
Code: Select all
i::
ToolTip, click somewhere
KeyWait, LButton, D
MouseGetPos, X1, Y1
KeyWait, LButton, U
ToolTip, click somewhere else
KeyWait, LButton, D
MouseGetPos, X2, Y2
KeyWait, LButton, U
ToolTip
MsgBox, X1: %X1% Y1: %Y1% X2: %X2% Y2: %Y2%
Return
Re: Wait for mouse click, save coordinates
Perfect. Thank you so much. Guess I didn't dig deep enough. Had no idea that KeyWait could be used for mouse clicks.
Who is online
Users browsing this forum: Bing [Bot], Bodhi, boiler, mikeyww, vanheartnet098, wineguy and 53 guests