img search

Ask gaming related questions (AHK v1.1 and older)
tustoneey3
Posts: 5
Joined: 09 Oct 2017, 00:51

img search

09 Oct 2017, 00:56

i been trying to get it to click randomly inside the img instead of always the same spot

Code: Select all

z::
Send {f2}
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, druid.png
If(ErrorLevel == 0){
Click, %foundX%, %foundY%
}else{
MsgBox, Image not found.
}
return
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: img search

09 Oct 2017, 01:03

Means, you've to know the images size and do some math using its final position coordinate and the Random-command? Good luck :)
tustoneey3
Posts: 5
Joined: 09 Oct 2017, 00:51

Re: img search

09 Oct 2017, 01:05

BoBo wrote:Means, you've to know the images size and do some math using its final position coordinate and the Random-command? Good luck :)
can u give me a example on how to use it
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: img search

09 Oct 2017, 01:11

Here we go! This contains even two examples! :thumbup:
https://autohotkey.com/docs/commands/Random.htm

BTW, is it for a game?
tustoneey3
Posts: 5
Joined: 09 Oct 2017, 00:51

Re: img search

09 Oct 2017, 01:16

BoBo wrote:Here we go! This contains even two examples! :thumbup:
https://autohotkey.com/docs/commands/Random.htm

BTW, is it for a game?

yes its for a game i been trying to make my own shit instead of buying it from people
tustoneey3
Posts: 5
Joined: 09 Oct 2017, 00:51

Re: img search

09 Oct 2017, 01:26

BoBo wrote:Here we go! This contains even two examples! :thumbup:
https://autohotkey.com/docs/commands/Random.htm

BTW, is it for a game?

yes its for a game i been trying to make my own shit instead of buying it from people
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: img search

09 Oct 2017, 01:34

Code: Select all

imgx := 10 ; your img width is 10 px ...
imgy := 10 ; your img height is 10 px
Random, xPos,% foundx,% foundx+imgx
Random, yPos,% foundy,% foundy+imgy
Not tested.
tustoneey3
Posts: 5
Joined: 09 Oct 2017, 00:51

Re: img search

09 Oct 2017, 01:42

BoBo wrote:

Code: Select all

imgx := 10 ; your img width is 10 px ...
imgy := 10 ; your img height is 10 px
Random, xPos,% foundx,% foundx+imgx
Random, yPos,% foundy,% foundy+imgy
Not tested.

idk if its me or if i am doing it right but its not working
User avatar
Reloaded
Posts: 283
Joined: 25 Aug 2017, 08:48

Re: img search

16 Oct 2017, 08:48

tustoneey3 wrote:i been trying to get it to click randomly inside the img instead of always the same spot

Code: Select all

z::
Send {f2}
ImageSearch, foundX, foundY, 0, 0, %A_ScreenWidth%, %A_ScreenHeight%, druid.png
If(ErrorLevel == 0){
Click, %foundX%, %foundY%
}else{
MsgBox, Image not found.
}
return
Found a Working Image Search Script

Code: Select all

f::
Coordmode, mouse, Screen
ImageSearch, xp, yp, 0, 0, 793, 726, *50 f.png
If ErrorLevel=0
{
MouseMove, xp, yp, 0
send {LButton}
}
Return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: jameswrightesq and 145 guests