Click mouse relative to x,y variable from color search

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
veggiebike
Posts: 4
Joined: 15 Aug 2018, 10:58

Click mouse relative to x,y variable from color search

15 Aug 2018, 11:29

Hi!
I'm having trouble figuring this out... On a website I'm using, I need AHK to click a button called print labels, then another redundant button comes out after the click that also says print labels and needs me to click it as well. I'm using an extension that highlights the word "print labels" in orange. So AHK clicks the orange color on print labels correctly, but now the problem is getting it to click the second one. Because they're the same text, I can't make it colored something different. Is there a way to make AHK click on a second instant of the same color? Another solution, this one less precise, is I know the second button is about 25 pixels below the first button.

I tried making the code click on px, py for the first button, then px, py+25 but ends up clicking the same spot a second time. Here's my code:

PixelSearch, Px, Py, 0, 0, 1062, 1062, 0x3399ff, 0, Fast
If(ErrorLevel == 0){
Click, %Px%, %Py%
Sleep 500
Click, %Px%, y+25
}else{
MsgBox, Printlabels not found.
exit
}


Thank you all so much for the help
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Click mouse relative to x,y variable from color search

15 Aug 2018, 13:09

Click, %x%, %y% Since click does not support expressions, variables should be enclosed in percent signs.
u need to do ur calculation prior to using the variable with Click
veggiebike
Posts: 4
Joined: 15 Aug 2018, 10:58

Re: Click mouse relative to x,y variable from color search

21 Aug 2018, 09:43

I'm still doing something wrong. This one doesn't work neither

PixelSearch, Px, Py, 0, 0, 1062, 1062, 0x3399ff, 0, Fast
If(ErrorLevel == 0){
Wa:= %Px% + 10
Hb:= %Py% + 10
Click, %Wa%,%Hb%
}else{
MsgBox, Printlabels not found.
exit
}
Any help would be really awesome
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Click mouse relative to x,y variable from color search

21 Aug 2018, 11:43

Code: Select all

PixelSearch, Px, Py, 0, 0, 1062, 1062, 0x3399ff, 0, Fast
if (ErrorLevel == 0) {
	Wa := Px + 10
	Hb := Py + 10
	Click, %Wa%,%Hb%
} else {
	MsgBox, Printlabels not found.
	exit
}
also read this: https://autohotkey.com/docs/Variables.htm#Intro

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: RandomBoy, Theda and 269 guests