pwnt Posted July 14, 2008 Share Posted July 14, 2008 Hi muttley, I am trying to get my script to first pixelsearch a color ($brwn) and if it doesnt find the color it moves on to my second pixelsearch ($lbrwn) but if it found either of the colors it would click the color that it found first. Here's the script expandcollapse popup#include <GUIConstants.au3> $Form1 = GUICreate("blabla", 122, 178, 1, 127) $B1 = GUICtrlCreateButton("Start", 24, 128, 73, 33, 0) $L1 = GUICtrlCreateLabel("blalbla", 16, 8, 92, 41) $L2 = GUICtrlCreateLabel("bla bla", 16, 48, 92, 41) $L3 = GUICtrlCreateLabel("blabla", 16, 96, 92, 33) GUISetState(@SW_SHOW) GUISetBkColor(0x24E9FF) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd while $msg = guigetmsg() Select case $msg = $b1 $brwn = PixelSearch(255,250,771,589,0xDF7215,2,2) if @error Then $lbrwn = Pixelsearch(255,250,771,589,0x621008,2,2) if not @error Then $x = $brwn[0] $y = $brwn[1] mouseclick("left",$brwn[0],$brwn[1],1,1) $x2 = $lbrwn[0] $y2 = $lbrwn[1] mouseclick("left",$lbrwn[0],$lbrwn[1],1,1) EndIf EndIf EndSelect WEnd Thanks in advance (And I am yeah I am pretty noob at Autoit. And I was just trying guessing so I am pretty certain that half the script needs redoing.....) Link to comment Share on other sites More sharing options...
dmob Posted July 14, 2008 Share Posted July 14, 2008 (edited) you have not said where the script fails. your second while statement is missing the expression. try leaving out the last two parameters and have only $brwn = PixelSearch(255,250,771,589,0xDF7215) to narrow down.CODEWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $b1 $brwn = PixelSearch(255,250,771,589,0xDF7215) if @error Then $lbrwn = Pixelsearch(255,250,771,589,0x621008) if not @error Then $x = $brwn[0] $y = $brwn[1] mouseclick("left",$brwn[0],$brwn[1],1,1) Endif Else $x2 = $lbrwn[0] $y2 = $lbrwn[1] mouseclick("left",$lbrwn[0],$lbrwn[1],1,1) EndIf EndSwitchWEnd Edited July 14, 2008 by dalisuit Link to comment Share on other sites More sharing options...
d3mon Posted July 14, 2008 Share Posted July 14, 2008 (edited) Hi muttley, I am trying to get my script to first pixelsearch a color ($brwn) and if it doesnt find the color it moves on to my second pixelsearch ($lbrwn) but if it found either of the colors it would click the color that it found first. (And I am yeah I am pretty noob at Autoit. And I was just trying guessing so I am pretty certain that half the script needs redoing.....) Hello, I have made script for you I hope that's you wanted : expandcollapse popupOpt("GuiOnEventMode",1) ;EventMode Guictrl #include <GUIConstants.au3> Dim $brwn,$lbrwn $Form1 = GUICreate("Pixel",122,178,1,127) $B1 = GUICtrlCreateButton("Start",24,128,73,33) GUICtrlSetOnEvent(-1,"_Start") $L1 = GUICtrlCreateLabel("L1",16,8,92,41) GUICtrlSetOnEvent(-1,"_L1") $L2 = GUICtrlCreateLabel("L2",16,48,92,41) GUICtrlSetOnEvent(-1,"_L2") $L3 = GUICtrlCreateLabel("L3",16,96,92,33) GUICtrlSetOnEvent(-1,"_L3") GUISetState(@SW_SHOW) GUISetBkColor(0x24E9FF) Func _Start() $brwn = PixelSearch(255,250,771,589,0xDF7215,2,2) $lbrwn = Pixelsearch(255,250,771,589,0x621008,2,2) EndFunc Func _L1() If IsArray($brwn)=1 Then ;$brwn pixelcolor found $x=$brwn[0] $y=$brwn[1] MouseClick("left",$brwn[0],$brwn[1],1,1) _L3();go to _L3 function Else _L2() ;pixelcolor not found go to _L2 function EndIf EndFunc Func _L2() If IsArray($lbrwn)=1 Then ;$lbrwn pixelcolor found $x2=$lbrwn[0] $y2=$lbrwn[1] MouseClick("left",$lbrwn[0],$lbrwn[1],1,1) _L3();go to _L3 function EndIf EndFunc Func _L3() If IsArray($brwn)=1 and IsArray($lbrwn)=1 Then ;Pixel $brwn and $lbwn color found then $x2=$lbrwn[0] $y2=$lbrwn[1] MouseClick("left",$lbrwn[0],$lbrwn[1],1,1) $x=$brwn[0] $y=$brwn[1] MouseClick("left",$brwn[0],$brwn[1],1,1) EndIf EndFunc While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Edited July 14, 2008 by d3mon No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
d3mon Posted July 14, 2008 Share Posted July 14, 2008 Hello again, I have add label for see pixel position on window : expandcollapse popupOpt("GuiOnEventMode",1) ;EventMode Guictrl #include <GUIConstants.au3> Dim $brwn,$lbrwn $Form1 = GUICreate("Pixel",122,178,1,127) $B1 = GUICtrlCreateButton("Start",24,128,73,33) GUICtrlSetOnEvent(-1,"_Start") $L1 = GUICtrlCreateLabel("L1",16,8,92,41) GUICtrlSetOnEvent(-1,"_L1") $L1pixel=GUICtrlCreateLabel("",30,8,80,17) $L2 = GUICtrlCreateLabel("L2",16,48,92,41) GUICtrlSetOnEvent(-1,"_L2") $L2pixel=GUICtrlCreateLabel("",30,48,80,17) $L3 = GUICtrlCreateLabel("L3",16,96,92,33) GUICtrlSetOnEvent(-1,"_L3") $L3pixel=GUICtrlCreateLabel("",30,96,80,17) GUISetState(@SW_SHOW) GUISetBkColor(0x24E9FF) Func _Start() $brwn = PixelSearch(255,250,771,589,0xDF7215,2,2) $lbrwn = Pixelsearch(255,250,771,589,0x621008,2,2) EndFunc Func _L1() If IsArray($brwn)=1 Then ;$brwn pixelcolor found $x=$brwn[0] $y=$brwn[1] MouseClick("left",$brwn[0],$brwn[1],1,1) GUICtrlSetData($L1pixel,$brwn[0]&","&$brwn[1]) _L3();go to _L3 function Else _L2() ;pixelcolor not found go to _L2 function EndIf EndFunc Func _L2() If IsArray($lbrwn)=1 Then ;$lbrwn pixelcolor found $x2=$lbrwn[0] $y2=$lbrwn[1] MouseClick("left",$lbrwn[0],$lbrwn[1],1,1) GUICtrlSetData($L2pixel,$lbrwn[0]&","&$lbrwn[1]) _L3();go to _L3 function EndIf EndFunc Func _L3() If IsArray($brwn)=1 and IsArray($lbrwn)=1 Then ;Pixel $brwn and $lbwn color found then $x2=$lbrwn[0] $y2=$lbrwn[1] MouseClick("left",$lbrwn[0],$lbrwn[1],1,1) GUICtrlSetData($L1pixel,$brwn[0]&","&$brwn[1]) $x=$brwn[0] $y=$brwn[1] MouseClick("left",$brwn[0],$brwn[1],1,1) GUICtrlSetData($L2pixel,$lbrwn[0]&","&$lbrwn[1]) EndIf EndFunc While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
pwnt Posted July 14, 2008 Author Share Posted July 14, 2008 (edited) Thanks for the fast replies everyone but I dont get any error messages and when I click Start and It starts the script (the pixelsearch one)because I can see 2 autoit marks on the bottom right bar (forgot the name muttley) and as I said I am new to all scripting languages so I am not really sure about what d3mon has written and you cant learn autoit with CTRL + C . Isnt there an easier way, because I dont understand anything ;P but thanks for the help everyone I will try and decipher D3mons script Edited July 14, 2008 by pwnt Link to comment Share on other sites More sharing options...
d3mon Posted July 14, 2008 Share Posted July 14, 2008 Thanks for the fast replies everyone but I dont get any error messages and when I click Start and It starts the script (the pixelsearch one) and as I said I am new to all scripting languages so I am not really sure about what d3mon has written and you cant learn with CTRL + C . Isnt there an easier way, because I dont understand anything ;P but thanks for the help everyone I will try and decipher D3mons script muttleyWell if you don't understand all that's normal if you're new, if nothing happend when you click start that's because he hasn't found pixel on screen No-life of autoit...what could be better ?LAST SCRIPTS WITH AUTO-IT : CLICK HERE Link to comment Share on other sites More sharing options...
pwnt Posted July 14, 2008 Author Share Posted July 14, 2008 (edited) Thanks for the help and the script I am starting to get your script a little more muttley. I am done with this topic so nobody has to answer anymore thanks to everyone (especially D3mon). EDIT: Thanks for the post D3mon I've learned LOADS and I fully understand you script Thanks so much Edited July 15, 2008 by pwnt Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now