Image Search not working

Ask gaming related questions (AHK v1.1 and older)
rwallhacker0
Posts: 7
Joined: 18 May 2018, 17:49

Image Search not working

07 Oct 2018, 08:11

Hello Autohotkey.com,

I'm here because Image Search function is not working for me and i don't know why.
So what i'm trying to do is to find buttoms in the screen when they appear and then click on them (Image Search + Mouse Move + Click + Loop).
This is my code:

Code: Select all

F1:: 

loop {
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, 1.bmp
If(ErrorLevel == 0){
Click, %foundX%, %foundY%
}

ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, 2.bmp
If(ErrorLevel == 0){
Click, %foundX%, %foundY%
}

{
	ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, 3.bmp
Click, %foundX%, %foundY%
}
I must tell you that i know zero about programming.
I know there is no MouseMove function, i don't know how to insert it.
I hope you can help guys :).
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Image Search not working

07 Oct 2018, 09:02

check ErrorLevels 1 and 2 to see if the image cant be found or isnt being loaded, respectively. Double check your CoordMode setting/select a different one. Check if the .BMP snapshots uve taken make sense.
Side note, if u expect this to work in native fullscreen games, it wont.

No one can debug this other than u urself. We dont have access to ur environment or source images, so yeah, gl. Also, there is a MouseMove command.
rwallhacker0
Posts: 7
Joined: 18 May 2018, 17:49

Re: Image Search not working

08 Oct 2018, 11:36

swagfag wrote:check ErrorLevels 1 and 2 to see if the image cant be found or isnt being loaded, respectively. Double check your CoordMode setting/select a different one. Check if the .BMP snapshots uve taken make sense.
Side note, if u expect this to work in native fullscreen games, it wont.

No one can debug this other than u urself. We dont have access to ur environment or source images, so yeah, gl. Also, there is a MouseMove command.
Ah yes, I forgot to put here the images lol.

Ok, so this is the first buttom, with the "Play" text, it is at "805, 829". The bot Should click on it and wait.
Image
This one is Cancel, here it should just wait, but that button is in the same part of the screen as the last one (805, 829).
Image
Then at "745, 524" this button will appear and the bot should click on it, then wait again.
Image

Ok so the bot started the queue, found it and started game, now it just need to wait it to finish and click...
Image

After this just repeat the process, or maybe trying to find all of them at the same time will work, I dont know.
Is it possible to do? What do you think?.

Thank you for your answer!
rwallhacker0
Posts: 7
Joined: 18 May 2018, 17:49

Re: Image Search not working

08 Oct 2018, 11:38

rwallhacker0 wrote:
swagfag wrote:check ErrorLevels 1 and 2 to see if the image cant be found or isnt being loaded, respectively. Double check your CoordMode setting/select a different one. Check if the .BMP snapshots uve taken make sense.
Side note, if u expect this to work in native fullscreen games, it wont.

No one can debug this other than u urself. We dont have access to ur environment or source images, so yeah, gl. Also, there is a MouseMove command.
Ah yes, I forgot to put here the images lol.

Ok, so this is the first buttom, with the "Play" text, it is at "805, 829". The bot Should click on it and wait.
Image
This one is Cancel, here it should just wait, but that button is in the same part of the screen as the last one (805, 829).
Image
Then at "745, 524" this button will appear and the bot should click on it, then wait again.
Image

Ok so the bot started the queue, found it and started game, now it just need to wait it to finish and click... (673, 713)
Image

After this just repeat the process, or maybe trying to find all of them at the same time will work, I dont know.
Is it possible to do? What do you think?.

Thank you for your answer!
Sorry, the images are not showing...

805, 829 - Play Button https://imgur.com/HiepmkH
745, 524 - Accept Button https://imgur.com/rJcX5vO
673, 713 - Exit Button https://imgur.com/Ydt7688
rwallhacker0
Posts: 7
Joined: 18 May 2018, 17:49

Re: Image Search not working

08 Oct 2018, 12:00

Note: I am playing in windowed.
nacken012
Posts: 90
Joined: 22 Jul 2016, 14:39

Re: Image Search not working

08 Oct 2018, 22:20

Ich würde es so lösen:

Code: Select all

F1:: 

loop {
CoordMode, Pixel, Screen
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *30 1.bmp
if ErrorLevel=1
        Goto, Nicht-gefunden
        if ErrorLevel=0
MouseMove, %FoundX%, %FoundY%, 0
Click, Left, 1
Sleep, 1000

CoordMode, Pixel, Screen
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *30 2.bmp
if ErrorLevel=1
        Goto, Nicht-gefunden
        if ErrorLevel=0
MouseMove, %FoundX%, %FoundY%, 0
Click, Left, 1
Sleep, 1000

CoordMode, Pixel, Screen
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, *30 3.bmp
if ErrorLevel=1
        Goto, Nicht-gefunden
        if ErrorLevel=0
MouseMove, %FoundX%, %FoundY%, 0
Click, Left, 1
Sleep, 1000
}

Nicht-gefunden:
MsgBox, Bild nicht gefunden
Return

rwallhacker0
Posts: 7
Joined: 18 May 2018, 17:49

Re: Image Search not working

09 Oct 2018, 12:01

Hello nacken012, it works!
Thank you!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 63 guests