Need help with imageSearch

Ask gaming related questions (AHK v1.1 and older)
Slodge
Posts: 5
Joined: 16 Apr 2023, 06:47

Need help with imageSearch

18 Feb 2024, 10:42

I am trying to make a auto reconnect script if your router gets disconnected by using the imageSearch command, but it's not working

Code: Select all

SetKeyDelay 0, 0 , 0
CoordMode, Pixel, Screen

F5::

imageFound := false
while(imageFound = false)
{
    imageSearch, x, y, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\img.png
    if(x <> ""){
        click, 1072, 606
        imgFound := true
    }
    else {
        Send {Click down}
        Sleep, 10000
        Send {Click up}
    }
}

F6::
exitapp
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Need help with imageSearch

18 Feb 2024, 12:07

How to troubleshoot an ImageSearch in a three-line test script
  1. On line 1, set the CoordMode.
  2. On line 2, conduct the search, using a simple static PNG image to test.
  3. On line 3, display the ErrorLevel returned by the search. The value will be 0, 1, or 2.
No additional lines, conditions, loops, variables, or statements are needed to determine whether the search works, and how to fix it.
User avatar
andymbody
Posts: 1034
Joined: 02 Jul 2017, 23:47

Re: Need help with imageSearch

18 Feb 2024, 12:20

Also
4. Check the names of your variables
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Need help with imageSearch

18 Feb 2024, 12:45

Fine but I recommend testing without variables.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Rookieahk and 56 guests