All-Around Triggerbot

09/26/2012 07:56 Sceluminare#1
Hello, I'm trying to figure out how to make a simple triggerbot that clicks when it finds a certain color within a box but I'm not sure how to make it click when it finds the color.

For example, I want to make it shoot when the crosshair is green and I want to make it search within this box I made: [Only registered and activated users can see links. Click Here To Register...]

The script I have so far is
Quote:
While 1
PixelSearch ( 925, 505, 994, 573, 0x42BB1B, 10 )
if Not @error Then
MouseClick("left")
EndIf
WEnd
I'm new to autoit and I'm not really sure what I should do.
09/26/2012 08:59 BitOfHope#2
I'm still fairly new myself. Is this what you are asking for?

Code:
Local $coord = PixelSearch(0, 0, 50, 50, 0xFFFFFF) ;Left, top, right, bottom, color
If Not @error Then
	Send("{1}") ;It found the color so it does this
ElseIf @error Then
	Send("{0}") ;It didn't find the color so it does this
EndIf
To get it to do exactly what you're asking... I'd do this (although I'm sure my script is sloppy):

Code:
Shoot()

Func Shoot()
	While 1
		Local $coord = PixelSearch(848, 447, 1054, 617, 0x42BB1B, 10)
		If Not @error Then
			MouseClick("Left") ;It found the color so it does this
			Sleep(10)
		ElseIf @error Then
			Sleep(10)
			Shoot() ;It didn't find the color so it does this
		EndIf
	WEnd
EndFunc   ;==>Shoot
Edit: I tried it and my game started to lag. I added in the sleep(10) and it seems to work fine now.

I think that second script will work... It's set to loop until you exit the script.

If it doesn't find the color it'll redo the search. Assuming it works, of course. I might have to try it out next time I play APB:R.
09/26/2012 15:06 H@CT0R#3
Quote:
Originally Posted by Sceluminare View Post
Hello, I'm trying to figure out how to make a simple triggerbot that clicks when it finds a certain color within a box but I'm not sure how to make it click when it finds the color.

For example, I want to make it shoot when the crosshair is green and I want to make it search within this box I made: [Only registered and activated users can see links. Click Here To Register...]

The script I have so far is

I'm new to autoit and I'm not really sure what I should do.
you must define pixelsearch as a variable
look in the autoit help:
Code:
; Find a pure red pixel in the range 0,0-20,300
Local $coord = PixelSearch(0, 0, 20, 300, 0xFF0000)
If Not @error Then
    MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
    mouseclick("left")
EndIf 


; Find a pure red pixel or a red pixel within 10 shades variations of pure red
$coord = PixelSearch(0, 0, 20, 300, 0xFF0000, 10)
If Not @error Then
    MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1])
EndIf
09/26/2012 23:02 Sceluminare#4
Quote:
Originally Posted by BitOfHope View Post
I think that second script will work... It's set to loop until you exit the script.

If it doesn't find the color it'll redo the search. Assuming it works, of course. I might have to try it out next time I play APB:R.
It works but it has a delay, it will randomly shoot sometimes (I know that's because it's finding the color it needs but even when I'm aiming on a player, it sometimes will shoot but mostly wont or not nearly close to the right time) but thanks anyways.
09/27/2012 00:32 BitOfHope#5
Quote:
Originally Posted by Sceluminare View Post
It works but it has a delay, it will randomly shoot sometimes (I know that's because it's finding the color it needs but even when I'm aiming on a player, it sometimes will shoot but mostly wont or not nearly close to the right time) but thanks anyways.
I would guess that you need to confine your pixelsearch range to a smaller scope. If you set the search range to JUST around your crosshairs, it should work perfectly.

I can't do that for you since it's your game.

Code:
Func Shoot()
	While 1
		Local $coord = PixelSearch([B]848, 447, 1054, 617[/B], 0x42BB1B, 10)
		If Not @error Then
			MouseClick("Left") ;It found the color so it does this
			Sleep(10)
		ElseIf @error Then
			Sleep(10)
			Shoot() ;It didn't find the color so it does this
		EndIf
	WEnd
EndFunc   ;==>Shoot
I bolded the coordinates that define your search area.
Also, try messing with the color variation in the pixelsearch. (It's the 10 at the end.)

Oh and, that pixelcolor I put in the script... It's the one you had. I think you took a green color. Try using: 0xBA0714

That's the red color the crosshairs go to when you aim at a player...
09/27/2012 06:00 Sceluminare#6
Quote:
Originally Posted by BitOfHope View Post
I bolded the coordinates that define your search area.
Also, try messing with the color variation in the pixelsearch. (It's the 10 at the end.)

Oh and, that pixelcolor I put in the script... It's the one you had. I think you took a green color. Try using: 0xBA0714

That's the red color the crosshairs go to when you aim at a player...
Yeah I know, the green was just to test if it worked but I had already changed it to red. What do you recommend the shades being at? My resolution is 1920x1080 and that's what I play my game in, so i'm not sure what the box should be.
09/27/2012 06:18 BitOfHope#7
Quote:
Originally Posted by Sceluminare View Post
Yeah I know, the green was just to test if it worked but I had already changed it to red. What do you recommend the shades being at? My resolution is 1920x1080 and that's what I play my game in, so i'm not sure what the box should be.
When you're in the game press ALT+ENTER to go into windowed mode. Once you're in there use the autoit window info to get the coordinates just around your crosshair.
09/29/2012 05:14 Sceluminare#8
I've got it working and everything but I think it's a little late on response occasionally because I'm dropping about 20-30fps, any ideas why it's causing this much lag?

Code:
Shoot()

Func Shoot()
	While 1
		Local $coord = PixelSearch(926, 475, 987, 535, 0xBA0714, 30)
		If Not @error Then
			MouseClick("Left") 
		EndIf
	WEnd
EndFunc   ;==>Shoot
Is there anywhere I should add sleeps or something? I also have to play it in windowed mode or it won't work even running as x64, help on this would be cool too.
09/29/2012 05:44 BitOfHope#9
Quote:
Originally Posted by Sceluminare View Post
I've got it working and everything but I think it's a little late on response occasionally because I'm dropping about 20-30fps, any ideas why it's causing this much lag?

Code:
Shoot()

Func Shoot()
	While 1
		Local $coord = PixelSearch(926, 475, 987, 535, 0xBA0714, 30)
		If Not @error Then
			MouseClick("Left") 
                       [B] Sleep(100)[/B]
		EndIf
	WEnd
EndFunc   ;==>Shoot
Is there anywhere I should add sleeps or something? I also have to play it in windowed mode or it won't work even running as x64, help on this would be cool too.
Without that sleep there it'll cause your FPS to drop, so mess around with it. Sleep(100) may or may not work for you.

To make it work fullscreen... Not sure, I always use scripts in windowed mode on games. Try messing with @DesktopWidth and @DesktopHeight

I'm still new with Autoit myself.
12/17/2012 01:08 uniquerelic#10
any updates to this?

im on a 1980x1080
the scan box i am looking for is smaller basically the top tick on the crosshair and its width. allowing enough length for bloom or larger static cross haired weapons

the box i am trying to hit as example is
965, 525, 955, 540, (based off of the png screen shot at full screen)

with colour 0x0BOCC4 (based off of the png screen shot at full screen)

[Only registered and activated users can see links. Click Here To Register...]