help with pixel search

08/07/2011 21:36 hectorin#1
I need to implement in my autoit bot some changes and i am gonna use pixel search.



What i exactly want is a script that start pressing a buton then compare a pixel if this pixel is grey make script 1 until pixel is not grey , when the pixel became not grey make script 2 till its finished, and when script 2 finish has to go to the compare pixel spot for starting again with script 1 till is not grey to make script 2 ...... and so on indefinitly


it would be something like this?


#Region
$Form1 = GUICreate("BOT", 350, 220, 250, 131)
$Button1 = GUICtrlCreateButton("GO", 74, 32, 185, 49, 0)
GUISetState(@SW_SHOW)
#EndRegion

While 1
$nMsg = GUIGetMsg()

Select

Case $Button1
While 1

$coord = PixelSearch( 0, 0, 20, 300, 0xFF0000, 10 )

If Not @error Then

script 1

EndIf

script 2

wend

or can i make it better way?

cuz script 1 is short but script2 are more than 300 code lines and perhaps i make my script complicated to understand

need some help

and i also need a pag with the hex number of all colors cuz the number i have put in func is the red color (like the example found in help of autoit)

srry 4 my low lvl of english
08/07/2011 21:56 Freddy​#2
Please but your Source in a [ PHP][/PHP] code
08/07/2011 22:11 buFFy!#3
Code:
Runs an external program and pauses script execution until the program finishes.

RunWait ( "program" [, "workingdir" [, show_flag [, opt_flag ]]] )
08/08/2011 01:30 hectorin#4
thats all the source, but its not doing what i want:

Quote:
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.6.1
Author: Hectorin

Script Function:
Template AutoIt script.

#ce ----------------------------------------------------------------------------

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region
$Form1 = GUICreate("Hellgate bot by hectorin", 350, 220, 250, 131)
$Button1 = GUICtrlCreateButton("DALE CAŅA", 74, 32, 185, 49, 0)
$Button2 = GUICtrlCreateButton("YA BASTA", 74, 132, 185, 49, 0)
GUISetState(@SW_SHOW)
#EndRegion

HotKeySet("{F12}", "Terminate")

Func _move($loop,$key)
For $i = $loop to 1 Step -1
ControlSend("Hellgate (x86 DX9)", "", "", $key)
Next
EndFunc

Func Terminate()
Exit 0
EndFunc

While 1
$nMsg = GUIGetMsg()

Select

Case $Button1
While 1
sleep(2000)


$coord = PixelSearch( 0, 0, 1241, 16, 0xFF0000, 10 )

While 1

_move(50,"s") ; move backward and forward till enter SH
Sleep(200)
_move(50,"w")
Sleep(100)

WEnd ; Color has changed then has entered SH

Sleep(3000) ; time to load screen


_move(50,"w") ; Once inside has to make all this
Sleep(5)
_move(40,"a")
ControlSend("Hellgate (x86 DX9)", "", "", "{F2}") ;swapp weapon
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{3}") ; use zombi form
Sleep(2500)
ControlSend("Hellgate (x86 DX9)", "", "", "{F1}") ; swap original weapons
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
Sleep(350)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(1350)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}") ; all sumons are up
Sleep(100)
_move(150,"w")
Sleep(10)
_move(25,"a")
ControlSend("Hellgate (x86 DX9)", "", "", "{2}") ; reaper
Sleep(3500)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
_move(30,"f") ; loot
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}"); finished sumon pet dead
Sleep(2100)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(1500)
_move(30,"a")
_move(30,"f") ; loot
Sleep(15)
_move(30,"f") ; loot
_move(50,"w")
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
_move(30,"f") ; loot
sleep(500)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
_move(30,"f") ; loot
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(1000)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(3000)
_move(100,"w")
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
sleep(500)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(1000)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(3000)
_move(40,"d")
_move(30,"f") ; loot
_move(40,"s") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{'}") ; hp inyector
Sleep(350)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(250)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
_move(30,"f") ; loot
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
_move(30,"f") ; loot
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
_move(30,"f") ; loot
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
_move(30,"f") ; loot
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}"); finished sumon pet dead
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(350)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
Sleep(350)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(350)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
_move(30,"f") ; loot
Sleep(350)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
_move(90,"d")
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{1}")
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}") ; basic function for sumon any pet its dead
_move(30,"f") ; loot
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(1000)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{0}")
Sleep(1000)
ControlSend("Hellgate (x86 DX9)", "", "", "{6}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{5}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{7}")
Sleep(100)
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{8}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{9}")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{0}"); finished sumon pet dead
Sleep(1350)
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
_move(30,"f") ; loot
Sleep(2500)
_move(30,"f") ; loot
_move(15,"a")
_move(30,"f") ; loot
ControlSend("Hellgate (x86 DX9)", "", "", "{4}") ; nova
_move(30,"f") ; loot

Sleep(2350)
_move(30,"f") ; loot

ControlSend("Hellgate (x86 DX9)", "", "", "{ENTER}")
Sleep(100)
Send("+7stuck")
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{ENTER}")
Sleep(15000)
_move(90,"s")
Sleep(5)
_move(18,"w")
Sleep(5) ; walking back and fordward cuz sometimes door doesnt detect us well
_move(18,"s")
Sleep(4000)

Send("{ALTDOWN}"); finished running SH doing a reset here
Sleep(500)
MouseClick("left",1039,79,1)
Sleep(500)
MouseClick("left",1039,79,1)
Sleep(100)
ControlSend("Hellgate (x86 DX9)", "", "", "{ENTER}")
Sleep(10)
MouseClick("left",558,571,1)
Sleep(500)
MouseClick("left",558,571,1)
Sleep(200)
ControlSend("Hellgate (x86 DX9)", "", "", "{ENTER}")
Sleep(100)
MouseClick("left",645,550,1)
Sleep(300)
MouseClick("left",645,550,1)
Sleep(400)
Send("{ALTUP}")
Sleep(350) ; reset done now its gonna start again GOTO START

WEnd

Case $Button2
GUIDelete()
ExitLoop

EndSelect


wend
Now is just doing this:

Quote:
_move(50,"s")
Sleep(200)
_move(50,"w")
Sleep(100)
what i need is if coords x=1241 and Y=16 are yellow color repeat this:

Quote:
_move(50,"s")
Sleep(200)
_move(50,"w")
Sleep(100)
but when coords x=1241 and Y=16 are not yellow color continue running rest of the scrip not just repiting forward backward:

Quote:
Sleep(3000) ; time to enter and load SH


_move(50,"w")
Sleep(5)
_move(40,"a")
ControlSend("Hellgate (x86 DX9)", "", "", "{F2}") ;swapp weapon
Sleep(1350)..... and all lines till the end moment that script will start again testing yellow color cuz its a loop.