Prompting user for coords rather than using ImageSearch

Discuss Autohotkey related topics here. Not a place to share code.
Forum rules
Discuss Autohotkey related topics here. Not a place to share code.
cheeseontoast
Posts: 3
Joined: 11 Nov 2020, 09:41

Prompting user for coords rather than using ImageSearch

Post by cheeseontoast » 28 Nov 2021, 16:07

Apologies if this stating the blindingly obvious; but as a novice I'm finding I can often get a script up and running quicker by prompting for screen co-ordinates at the start of a run, rather than coding for ImageSearch or the intricacies of Window controls (when they exist).
Basically the script asks for the cursor to be placed on a Search box, button etc. and saves the coords for use later on.
I thought I'd mention it in case it's an easier approach for other newcomers to AHK to try, or anyone wanting to cobble together a quick script for a one-off task.
It won't always be appropriate, but it saves me a lot of time when it is.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Prompting user for coords rather than using ImageSearch

Post by Lepes » 29 Nov 2021, 00:49

Use InputBox.

This forum is not a place to share code, so...

cheeseontoast
Posts: 3
Joined: 11 Nov 2020, 09:41

Re: Prompting user for coords rather than using ImageSearch

Post by cheeseontoast » 29 Nov 2021, 01:13

Thanks for the reply, but I probably didn't explain my approach clearly.
I don't expect the user to know the coordinates so that they can enter them in an Input box.
Rather they get prompted to place the cursor on the required location(s), and the script can then use MouseGetPos to determine the coordinates.

Lepes
Posts: 141
Joined: 06 May 2021, 07:32
Location: Spain

Re: Prompting user for coords rather than using ImageSearch

Post by Lepes » 29 Nov 2021, 01:27

Oh! don't worry, I'm sure I misunderstood your question.

I would say that MouseGetPos is not a good approach on some situations, for example if the window has scrollbars.

I think you can study AHkSpy for example, it is a complex piece of Ahk software, but you can detect the control under the cursor and then send Messages to it.
It also highlight the control under your mouse. A really cool option if you want to simulate.
AhkSpy allows to freeze the application when the mouse is under the control you want to detect, I think you could use something like this for your initial question.

Post Reply

Return to “General Discussion”