Page 1 of 1

Click mouse relative to x,y variable from color search

Posted: 15 Aug 2018, 11:29
by veggiebike
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

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

Posted: 15 Aug 2018, 13:09
by swagfag
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

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

Posted: 21 Aug 2018, 09:43
by veggiebike
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

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

Posted: 21 Aug 2018, 11:43
by swagfag

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