Sign in to follow this  
Followers 0
Spacetech

Pixelsearch Troubles

10 posts in this topic

#1 ·  Posted (edited)

Hi, I'm new and started autoit about a week ago. I have coded in other langs before and this one seemed since so I'm trying it. I made some useful scripts for myself by using some examples on this forum but now I'm stuck. I'm trying to make a bot for Halo PC version. I can't seem to get pixelsearch to work unless im over the color. I have literally tried everything. Heres the code I'm using:

#Include <Constants.au3>
#NoTrayIcon

$AimbotToggle = False
$HexColor = "0xFFFFFF"

Opt("CaretCoordMode", 0)
Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)

HotKeySet("{F9}", "AimbotToggle")
HotKeySet("{F10}", "GetMousePosColor")
HotKeySet("{F11}", "ExitAimBot")

Func AimbotToggle()
    $AimbotToggle = Not $AimbotToggle
EndFunc

Func GetMousePosColor()
    $MousePos = MouseGetPos()
;MsgBox(64, "Color", Hex(PixelGetColor($MousePos[0], $MousePos[1])))
    ClipPut("0x" & StringRight(Hex(PixelGetColor($MousePos[0], $MousePos[1])), 6))
EndFunc

Func ExitAimBot()
    MsgBox(64, "Exited", "Exited")
    Exit
EndFunc

While 1
    If($AimbotToggle == True) Then
        $MousePos = MouseGetPos()
        $Cords = PixelSearch($MousePos[0], $MousePos[1], $MousePos[0], $MousePos[1], $HexColor, 5)
        If(IsArray($Cords)) Then
            MsgBox(64, "Mouse Position", $Cords[0] & "-" & $Cords[1])
    ;MouseMove($Cords[0], $Cords[1])
    ;MouseDown("left")
    ;MouseUp("left")
            MouseClick("Left", $Cords[0], $Cords[1])
        EndIf
    EndIf
WEnd

Exit

It's pretty simple but I still can't get it to work good.

If someone could help me that would be great :)

Thanks in advance!

Edited by Spacetech

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The reason you are not search anything except whats under you mouse is because the coordinates you have defined for pixelSearch are confined to just mouse pos.

This will search a 100 Pixel area centered around the mouse pos.

#Include <Constants.au3>
#NoTrayIcon

$AimbotToggle = False
$HexColor = "0xFFFFFF"

Opt("CaretCoordMode", 0)
Opt("MouseCoordMode", 0)
Opt("PixelCoordMode", 0)

HotKeySet("{F9}", "AimbotToggle")
HotKeySet("{F10}", "GetMousePosColor")
HotKeySet("{F11}", "ExitAimBot")

Func AimbotToggle()
    $AimbotToggle = Not $AimbotToggle
EndFunc

Func GetMousePosColor()
    $MousePos = MouseGetPos()
;MsgBox(64, "Color", Hex(PixelGetColor($MousePos[0], $MousePos[1])))
    ClipPut("0x" & StringRight(Hex(PixelGetColor($MousePos[0], $MousePos[1])), 6))
EndFunc

Func ExitAimBot()
    MsgBox(64, "Exited", "Exited")
    Exit
EndFunc

While 1
    If($AimbotToggle == True) Then
        $MousePos = MouseGetPos()
        $Cords = PixelSearch($MousePos[0]-100, $MousePos[1]-100, $MousePos[0]+100, $MousePos[1]+100, $HexColor, 5) ; <--Note changes
            If Not @Error then MouseClick("Left", $Cords[0], $Cords[1],1,0)
    EndIf
WEnd
Edited by Paulie

Share this post


Link to post
Share on other sites

1 you need to set the pixel search area, not this

$MousePos = MouseGetPos()

$Cords = PixelSearch($MousePos[0], $MousePos[1], $MousePos[0], $MousePos[1], $HexColor, 5)

2

your OPT() coordinates mode could/shoould be 2... see help

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

-snip-

Thanks a lot it seems to work :)

1 you need to set the pixel search area, not this

$MousePos = MouseGetPos()

$Cords = PixelSearch($MousePos[0], $MousePos[1], $MousePos[0], $MousePos[1], $HexColor, 5)

2

your OPT() coordinates mode could/shoould be 2... see help

8)

When

Opt("MouseCoordMode", 2)
Opt("PixelCoordMode", 2)

and I'm searching for a pixel on the desktop it brings it to the top left corner.

I removed those lines and it fixed it.

I also DID search the help file like crazy.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

...

I removed those lines and it fixed it.

That should be the same as

Opt("MouseCoordMode", 1)

Opt("PixelCoordMode", 1)

EDIT: Modes

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

Right now I'm in the game and when I hit F10 which usually activates the GetMousePosColor function doesn't seem to work.

Share this post


Link to post
Share on other sites

Actually, if you are just trying to click on a color... this will set you up perfectly

GameBot Builder

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

This is mine

Func Get_Color()
    $pos = MouseGetPos()
    $Svar = PixelGetColor(  $pos[0] , $pos[1])
    $var = "0x" & Hex($Svar,6)
    Show_Color()
EndFunc

the entire script is here

Get That Color

also gets mouse position

8)

Well thats pretty much what is has. Is their a problem with PixelGetColor and fullscreen games?

Share this post


Link to post
Share on other sites

Well thats pretty much what is has. Is their a problem with PixelGetColor and fullscreen games?

Then you would use this

Opt("MouseCoordMode", 1)

Opt("PixelCoordMode", 1)

to utilize the entire screen

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0