Jump to content
Sign in to follow this  
KongBR

PixelSearch Loops

Recommended Posts

I'm a total n00b concerning AutoIt...

This seemed simple enough when I first thought about it, but I don't really have any idea what I'm doing, so I need some help.

What I want to happen:

When I push a key, I want 3 PixelSearches going constantly, and when they've found that pixel, do a task and start searching again... So far only the "_Done()" function works... :P

The code:

HotKeySet("{ESC}", "_Done")
HotKeySet("{F8}", "_Start")

While 1
    Sleep(100)
    ;
WEnd

Func _Start()
    While 1
        $c_HPBar = PixelSearch(158, 88, 165, 93, 0x181008, 0) ;Search HP bar for background color.
            If Not @error And IsArray($c_HPBar) Then
                Send("{F1 1}") ;Drink potion.
            EndIf

        $c_HungerBubble = PixelSearch(130, 70, 140, 80, 0xFFFFFF) ;Search for hunger bubble.
            If Not @error And IsArray($c_HungerBubble) Then
                Send("{F2 1}") ;Eat food.
            EndIf

        $c_MonsterHunt = PixelSearch(0, 0, 1024, 768, 0x32AEF7) ;Search for monster... attack... wait...
            If Not @error And IsArray($c_MonsterHunt) Then
                MouseClick("left", $c_MonsterHunt[0], $c_MonsterHunt[1], 1, 0) ;Engage certain monster;
                Sleep(20000)
            EndIf
    WEnd
EndFunc

Func _Done()
    Exit
EndFunc

By reading the comments, you can see what I'm trying to do... This is for a game.

Thanks in advance for any help. :nuke:

Share this post


Link to post
Share on other sites

I'm a total n00b concerning AutoIt...

This seemed simple enough when I first thought about it, but I don't really have any idea what I'm doing, so I need some help.

What I want to happen:

When I push a key, I want 3 PixelSearches going constantly, and when they've found that pixel, do a task and start searching again... So far only the "_Done()" function works... :P

The code:

HotKeySet("{ESC}", "_Done")
HotKeySet("{F8}", "_Start")

While 1
    Sleep(100)
    ;
WEnd

Func _Start()
    While 1
        $c_HPBar = PixelSearch(158, 88, 165, 93, 0x181008, 0) ;Search HP bar for background color.
            If Not @error And IsArray($c_HPBar) Then
                Send("{F1 1}") ;Drink potion.
            EndIf

        $c_HungerBubble = PixelSearch(130, 70, 140, 80, 0xFFFFFF) ;Search for hunger bubble.
            If Not @error And IsArray($c_HungerBubble) Then
                Send("{F2 1}") ;Eat food.
            EndIf

        $c_MonsterHunt = PixelSearch(0, 0, 1024, 768, 0x32AEF7) ;Search for monster... attack... wait...
            If Not @error And IsArray($c_MonsterHunt) Then
                MouseClick("left", $c_MonsterHunt[0], $c_MonsterHunt[1], 1, 0) ;Engage certain monster;
                Sleep(20000)
            EndIf
    WEnd
EndFunc

Func _Done()
    Exit
EndFunc

By reading the comments, you can see what I'm trying to do... This is for a game.

Thanks in advance for any help. :nuke:

Well From what i see, your code should work, all i can think of is this:

Perhaps the game has a cheat blocker that stops key inputs from external programs

I believe an example of such tool is 'Game Guard'

Also

Just for a more optimizing way for the heath bar thing, you can do a 'PixelGetColor' on just one pixel, and if its the background color then send {F1}

same can most likely be done for hunger meter

What game is it anyway?

Share this post


Link to post
Share on other sites

Well From what i see, your code should work, all i can think of is this:

Perhaps the game has a cheat blocker that stops key inputs from external programs

I believe an example of such tool is 'Game Guard'

Also

Just for a more optimizing way for the heath bar thing, you can do a 'PixelGetColor' on just one pixel, and if its the background color then send {F1}

same can most likely be done for hunger meter

What game is it anyway?

The game's called GoonZu. It doesn't use GG, and I did a little MouseMove and MouseClick test and it worked (in game)... So it must be a problem with my code...

Share this post


Link to post
Share on other sites

Well... I took away the "If Not @error" part and the hunger PixelSearch thing worked... Except it ate like 30 units which like... killed my guy, so I'll need to delete that character and start over... :P

I set it to only press F2 once though, why did it press it 30 times?

Share this post


Link to post
Share on other sites

Well... I took away the "If Not @error" part and the hunger PixelSearch thing worked... Except it ate like 30 units which like... killed my guy, so I'll need to delete that character and start over... :P

I set it to only press F2 once though, why did it press it 30 times?

because it took a second for the 'food to work probably, and autoit is FAST, so it pushed the button 30 times, before it detected that the it had worked

best bet for a fix, put a 3-4 second sleep on the food after the first button

Send("{F2}")
Sleep(3000)
Edited by Paulie

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...