Jump to content

Recommended Posts

Posted

Never worked with PixelSearch before, but I think something like this would probably do it:

Do
PixelSearch(blah blah blah)
Until Pixelsearch(blah blah blah) NOT @error

Works perfectly thank you. Now, is it possible to make it until for the color to appear FOR a certain amount of time, and if it doesn't appear within that amount of them, then it just continues through the thread instead of endlessly waiting?

Posted (edited)

Add a timer:

$ExitTime = 5000 ;In Miliseconds, 5 seconds
$Time = TimerInit ()
Do
     PixelSearch(blah, blah, blah)
Until PixelSearch(blah, blah, blah) Not @Error Or TimerDiff($Timer) >= $ExitTime
Edited by LurchMan

Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Posted

Do
If Not WinActive($hwnd_Window) Then
WinActivate($hwnd_Window)
WinWaitActive($hwnd_Window)
EndIf
GUI()
Sleep(5)
$aPosition = PixelSearch($Left, $Top, $Right, $Bottom, $Red, $RedColorSensitivity, 3)
CheckTimer(@error)
Until @error <> 1
If IsArray($aPosition) Then
MouseMove($aPosition[0] + Random(-5, 5, 1), $aPosition[1] + Random(-3, 3, 1), 5)
$SLeft = $aPosition[0] - 50
$SRight = $SLeft + 60
$STop = $aPosition[1] - 50
$SBottom = $STop + 65
EndIf

Func CheckTimer($PixelError)
If TimerDiff($Timer) >= $MaxTime Then
SetError(0)
Return -1
EndIf
SetError($PixelError)
EndFunc ;==>CheckTimer

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

Do
If Not WinActive($hwnd_Window) Then
WinActivate($hwnd_Window)
WinWaitActive($hwnd_Window)
EndIf
GUI()
Sleep(5)
$aPosition = PixelSearch($Left, $Top, $Right, $Bottom, $Red, $RedColorSensitivity, 3)
CheckTimer(@error)
Until @error <> 1
If IsArray($aPosition) Then
MouseMove($aPosition[0] + Random(-5, 5, 1), $aPosition[1] + Random(-3, 3, 1), 5)
$SLeft = $aPosition[0] - 50
$SRight = $SLeft + 60
$STop = $aPosition[1] - 50
$SBottom = $STop + 65
EndIf
 
Func CheckTimer($PixelError)
If TimerDiff($Timer) >= $MaxTime Then
SetError(0)
Return -1
EndIf
SetError($PixelError)
EndFunc ;==>CheckTimer

I dun understand =[[

Posted

Do
    $coord = PixelSearch(157, 98, 225, 146, 0x545453, 0, 1, "")
    $diff = TimerDiff($start)
Until Not @error Or $diff > 10000

I am not sure about this... @error can be setted by the TimerDiff function so is useless, in this case you should use this

Do
    $coord = PixelSearch(157, 98, 225, 146, 0x545453, 0, 1, "")
    $diff = TimerDiff($start)
Until IsArray($coord) Or $diff > 10000
Posted (edited)

I dun understand =[[

Then learn. The code I posted is from an operational program that I use at least once a week. It works exactly as advertised and does exactly what you're asking for. We're not here to write the bot* you want for you. We're not here to spoon feed you code. You can take what I posted apart line by line and learn what's going on, how the programming logic works, and cross reference it with the help file, or you can sit there and twiddle your thumbs and go nowhere.

*Because that's what 99% of the pixelsearch questions boil down to. Game automation.

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Posted

Then learn. The code I posted is from an operational program that I use at least once a week. It works exactly as advertised and does exactly what you're asking for. We're not here to write the bot* you want for you. We're not here to spoon feed you code. You can take what I posted apart line by line and learn what's going on, how the programming logic works, and cross reference it with the help file, or you can sit there and twiddle your thumbs and go nowhere.

*Because that's what 99% of the pixelsearch questions boil down to. Game automation.

Sorry about that, I didn't exactly look at it before, I kinda looked at it and said to myself womfg too much code.

But now that I look at it, I just used the help file for stuff I didn't know. and it actually does exactly what I want it to do lol

THanks =P

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...