FindClick() - ImageSearch, Clicking, & More [Newest Version]

Post your working scripts, libraries and tools
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

14 Feb 2017, 22:03

Vizzy wrote:For instance if I added the option w500,50 I was under the impression that would wait 500ms total, checking every 50ms for a total of 10 checks. However when I add this and run in diagnostic mode I get this: http://imgur.com/6KS1kke


Hey Vizzy! That is really strange and definitely not the intended behavior. You are right, it should only search for 500 ms before timing out. When I run it on my machine it works correctly. Are you using any other options for findclick besides w and dx? Sometimes they are interdependent and that might help me fix the bug.

r2997790 wrote:As a newbie this is all a bit overwhelming... I was wondering if someone could give me a little bit of steer... I want to open up an image and click on it a few times and right the location of the clicks to a file.


Sure r2997790 here is some code to get you started

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("my image.png", "", FoundX, FoundY) ; clicks on the image and stores the x and y coordinates in FoundX and FoundY
WinGetPos, WinX, WinY, , , A ; Get the position of the active window
FoundX -= WinX ; FindClick returns coordinates based on the screen so if you want relative coordinates you need to subtract the window position
FoundY -= WinY
FileAppend, %FoundX%`,%FoundY%`n, %A_Desktop%\Output.txt ; append to a file
Vizzy
Posts: 1
Joined: 12 Feb 2017, 14:33

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

16 Feb 2017, 08:48

Thanks for getting back to me. It's happening on the two different setups of findclick I use:

FindClick("C:\Users\Vizzy\Desktop\S.png", "am200 o20 n2 Sleep100")
FindClick("C:\Users\Vizzy\Desktop\GREEN.png", "am5 o10 kz w500,50")

The first doesn't even have the wait option and still displays that behaviour. It's almost certainly linked to another one of the settings as you suspect. I've had a look at your code to see if I can spot anything but I'm afraid it's a little beyond me! I'm still relatively new to autohotkey.

Here's the full code of how I use it:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

16 Feb 2017, 09:19

Thanks Vizzy! I'm on the train right now and don't have time to dive into the code but from first glance I am almost positive it's a bug with the a-m option. That's actually something I've never used myself which makes it more likely to have a bug I never noticed. I'm glad you find the feature helpful though! I'll update you when I find something
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

17 Feb 2017, 13:54

I tweaked a couple of lines to keep the problem from happening. The original download link should be updated. Let me know if you are still having problems :)
secar
Posts: 2
Joined: 19 Feb 2017, 16:49

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

19 Feb 2017, 16:53

Hello berban, thanks for this nice utility you've made.
But I have a small issue here, could you help so I'll save some time on the debugging?
the issue i'm talking about is that whenever I run an image search, the script points the coursor to the target OK, but does not return the value of the x coordinate.
msgBox for x shows a blank place after the "image is" words. running latest AutoHotkey_1.1.24.05 the AutoHotkeyU64.exe version on win8 x64 machine. thanks for help in advance.

I'm running it like

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("d:\tmp\search\tower.png", "stay1" xCoord, yCoord)
MsgBox, The y-coordinate of the image is %yCoord%
MsgBox, The x-coordinate of the image is %xCoord%


but when I called it like below, it returned both coordinates, what am I doing wrong?

Code: [Select all] [Download] GeSHi © Codebox Plus

MsgBox, % FindClick("d:\bt\android\screens\search\tower.png", "stay1")
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

20 Feb 2017, 08:15

I believe you're just missing a comma in the first example. It should look like this:

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("d:\tmp\search\tower.png", "stay1", xCoord, yCoord)
secar
Posts: 2
Joined: 19 Feb 2017, 16:49

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

20 Feb 2017, 14:39

berban wrote:I believe you're just missing a comma in the first example. It should look like this:

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("d:\tmp\search\tower.png", "stay1", xCoord, yCoord)


for some reason the sentence "you were right, thanks a lot!" was stripped off.
Last edited by secar on 21 Feb 2017, 03:47, edited 1 time in total.
movermeyer
Posts: 3
Joined: 20 Feb 2017, 20:56

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

20 Feb 2017, 20:59

Hi Berban, I think I am using the latest version of the script (sha256sum: 'f4655f570d0516fd84bde8725e37f43a0c906ac46c878fb3a3d99bac07bc5c8a *FindClick.ahk', https://onedrive.live.com/redir?resid=7824E3085A9C7BE0!38125&authkey=!APWybbrj4Zw7vKI&ithint=file%2Cahk), but I seem to be having the same problem Vizzy had ('w' option hangs forever).

Here is a bit of sample code:

Code: [Select all] [Download] GeSHi © Codebox Plus

#Include FindClick.ahk
F7::Reload
F8::Exit
F10::
FindClick("my_example.png", "on,50", OutputX, OutputY)
MsgBox, Hello! %OutputX%, %OutputY%
return


The above code correctly fails to find the image when it is not on the screen, and reports the coordinates when the image is in on the screen.

Changing the FindClick by adding the w parameter causes it to hang:

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("my_example.png", "w,50 on,50", OutputX, OutputY)


I would have expected this to time out after 50 ms and show me the MsgBox. It does not.

I'm using AHKv1.1.24.5
movermeyer
Posts: 3
Joined: 20 Feb 2017, 20:56

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

20 Feb 2017, 21:05

Further: Do you have a GitHub (or similar) repo for FindClick?

It would be useful to have a place with:

    Ability to submit merge requests.
    Automatic builds and unit test runners.
    Proper issue tracking.

GitHub is free for open-source projects.
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

23 Feb 2017, 23:22

Hey movermeyer,

I think you have a simple misunderstanding about how the options parameter is supposed to be used. It's supposed to be like the GUI options where you might have x10 y20 gMyLabel. The important distinction is you shouldn't use commas in between the option name and the value (i.e. You wouldn't do x,20 y,40 g,MyLabel for a GUI)

In some of the findclick options you do use a comma to separate parts of it. For w, if you put a comma then before the comma is the time to wait and after the comma is the time to sleep between searches. So in your case you have w,50 so the script receives w := ",50". (This should be shown in the first part of the debugger). Before the comma is nothing so the default is used, which is to wait infinitely. The 50 is after the comma so that's the sleep amount.

You can also use commas with the o option, but I don't quite follow what you did there. You have "on,50" so o receives "n,50" as its value. These are imagesearch options as in the help manual. 50 is interpreted as shades of variation, but n is not a valid option. The only ones autohotkey knows is Icon, Trans, w, h, and maybe one other one that isn't useful. Check out the imagesearch documentation for more info on how to use the imagesearch options.

Regarding GitHub... I really should have been using that when I was working on this and other scripts. Unfortunately I'm not that active in AutoHotkey anymore and am too lazy to move everything there at this point. I'd rather just respond to the forum questions, but if you really need to use githubs features for this then maybe I could Be persuaded
movermeyer
Posts: 3
Joined: 20 Feb 2017, 20:56

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

02 Mar 2017, 20:46

D'oh!

Yeah, that's it. Sorry for the confusion.
Asmodeus
Posts: 40
Joined: 19 Oct 2015, 15:53

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

22 Apr 2017, 17:39

could you plz add support for AHK variables?

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("%A_Desktop%\CAPTURE.PNG")

brings up an error: File Not Found.

ImageSearch works fine, even by using a forward slash


not sure, is AHK making no difference between forward and backslash?

btw, +1 for github upload :roll:
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

22 Apr 2017, 18:33

Asmodeus wrote:

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick("%A_Desktop%\CAPTURE.PNG")


You gotta treat this as an expression which is the case for any function in AutoHotkey.

Code: [Select all] [Download] GeSHi © Codebox Plus

FindClick(A_Desktop "\CAPTURE.PNG")


See https://autohotkey.com/docs/Variables.htm#Expressions for more clarification on the difference between AutoHotkey literal statements (i.e. what you wrote) and AutoHotkey expressions (what you need to put).

Asmodeus wrote:btw, +1 for github upload :roll:


I'll try to get on this, I promise :)
Asmodeus
Posts: 40
Joined: 19 Oct 2015, 15:53

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

26 Apr 2017, 16:59

great, it works now.

by reading the manual i found a typo on page 4
MsgBox, The x-coordinate of the image is %yCoord%
also i believe you could be a bit more specific on shades of variation
by mentioning the min max values of *n (variation): a number between 0 and 255.
carno
Posts: 82
Joined: 20 Jun 2014, 16:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

27 Apr 2017, 22:35

I confirm the typo in FINDCLICK DOCUMENTATION
Function by Berban Last updated June 14, 2013:

FindClick("C:\MyImage.png", "n", xCoord, yCoord)
MsgBox, The x-coordinate of the image is %xCoord%
MsgBox, The x-coordinate of the image is %yCoord% ; This should be: MsgBox, The y-coordinate of the image is %yCoord%
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

05 May 2017, 23:16

Thanks for noticing guys. I made a few other updates to the documentation. I added some examples of how I use findclick to maybe give you some ideas.

I also uploaded it to GitHub!! yay. Find it here: https://github.com/berban/FindClick
mankvl
Posts: 8
Joined: 23 Sep 2016, 03:58

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

18 Aug 2017, 05:55

This is epic, thanks a lot.
mankvl
Posts: 8
Joined: 23 Sep 2016, 03:58

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

21 Aug 2017, 05:37

@berban what could be the problem if i use 1-2 foundclick in one hotkey all works ok, but if I use 3 or more after the 2 FoundClick other are not working even "dx" does not start at all. If I use same image with other hotkey all works like a charm. I need like 10-11 Foundclicks in one hotkey :(
User avatar
berban
Posts: 44
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

21 Aug 2017, 06:45

Can you post the code you're using mankvl?
tackis

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

24 Nov 2017, 05:34

i was wondering if it is possible to search for 5+ images and if none are present click another (a skip button), then search for the 5+ images and so on
my programming skills are minimal

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 17 guests