Page 1 of 1

How to triggerbot with multiple pixel images under certain condition syntax...

Posted: 17 May 2018, 13:29
by jjz580
Greetings,

I am a newbie to coding as well as AHK program, and I have been using AHK for quite awhile for gaming purposes. Recently, i wanted to make an trigger-bot for 1920x1080 resolution that will left mouse click button will only be activated, IF all the provided 3x3 sized colored pixel images are scanned successfully. The issue now is that the bot will be triggered at any successfully scanned single colored pixel image, rather than be triggered under the condition i mentioned above.

The attached is the image of single dot cross hair in-game consisting of 9 colored pixels, with each single colored pixel selected and cropped into individual png files that labelled as between p1 to p9, respectively.
Just in case if anybody is in need of the hex values of each, here you go:

Code: Select all

p1 = 0x870303
p2 = 0x850101
p3 = 0x7F0201
p4 = 0x870302
p5 = 0xFF0000
p6 = 0x790000
p7 = 0x7D0100
p8 = 0x7F0404
p9 = 0x790000

Image

The followings are the codes i found on this forum and edited with my amateur coding knowledge...

Code: Select all

loop
{
ImageSearch, , , 958, 0, 958, 538, *100 p1.png
If Errorlevel = 0
ImageSearch, , , 958, 539, 958, 1080, *100 p1.png
If Errorlevel = 0
ImageSearch, , , 959, 0, 959, 538, *100 p2.png
If Errorlevel = 0
ImageSearch, , , 959, 539, 959, 1080, *100 p2.png
If Errorlevel = 0
ImageSearch, , , 960, 0, 960, 538, *100 p3.png
If Errorlevel = 0
ImageSearch, , , 960, 539, 960, 1080, *100 p3.png
If Errorlevel = 0
ImageSearch, , , 958, 0, 958, 539, *100 p4.png
If Errorlevel = 0
ImageSearch, , , 958, 540, 958, 1080, *100 p4.png
If Errorlevel = 0
ImageSearch, , , 959, 0, 959, 539, *100 p5.png
If Errorlevel = 0
ImageSearch, , , 959, 540, 959, 1080, *100 p5.png
If Errorlevel = 0
ImageSearch, , , 960, 0, 960, 539, *100 p6.png
If Errorlevel = 0
ImageSearch, , , 960, 540, 960, 1080, *100 p6.png
If Errorlevel = 0
ImageSearch, , , 958, 0, 958, 540, *100 p7.png
If Errorlevel = 0
ImageSearch, , , 958, 541, 958, 1080, *100 p7.png
If Errorlevel = 0
ImageSearch, , , 959, 0, 959, 540, *100 p8.png
If Errorlevel = 0
ImageSearch, , , 959, 541, 959, 1080, *100 p8.png
If Errorlevel = 0
ImageSearch, , , 960, 0, 960, 540, *100 p9.png
If Errorlevel = 0
ImageSearch, , , 960, 541, 960, 1080, *100 p9.png
If Errorlevel = 0
mouseclick, left

}
return
TL;DR Looking for a way to create a left mouse button click trigger bot under the condition that all 9 colored pixels are scanned successfully at the same time.

Any help and suggestions are greatly appreciated, and please forgive my english as a foreign speaker:) Thanks all and have a nice day.

Harry

Re: How to triggerbot with multiple pixel images under certain condition syntax...

Posted: 18 May 2018, 09:58
by MaxAstro
My first guess is that your if statements are not blocked correctly. Put the expression in parenthesis and add a { to the end of each, like this: If (Errorlevel = 0) { Then, after the mouse click, add this: }}}}}}}}}}}}}}}}}}

Re: How to triggerbot with multiple pixel images under certain condition syntax...

Posted: 18 May 2018, 10:27
by swagfag
Are these reddish pixels scattered all over the screen or are they as they appear on the image you provided, ie 3x3 matrix?

If the latter is the case, why not make a single .png consisting of those 3x3 pixels, make a single call to ImageSearch and use the image as the haystack?

Unless there's something I'm heavily misunderstanding...