Geeky Posted October 20, 2005 Posted October 20, 2005 (edited) Hi, Ive made a script to search for a special color, but it wont do what i want it to do when it finds the color... I tried to fill the whole background in paint with the color (Light Green) But it still wont react, whats the problem?? $tid = inputbox( "Checkbox tid", "How long should Checkbox run (Hours)?", "24",) $checkbox = $tid * 6 * 60 $o = 1 $o = $o + 1 Do $coord = PixelSearch( 157, 170, 567, 537, 0x00ff00, 30) $color = PixelGetColor( "$coord[0]", "$coord[1]") If $color = ("0x00ff00") Then MouseMove ( "$coord[0]", "$coord[1]") MouseClick ("left", "$coord[0]", "$coord[1]") Until $o = $checkbox Edited October 20, 2005 by Geeky
Moderators SmOke_N Posted October 20, 2005 Moderators Posted October 20, 2005 (edited) Hi, Ive made a script to search for a special color, but it wont do what i wat it to do when it finds the color...I tried to fill the whole background in paint with the color (Light Green) But it still wont react, whats the problem??$tid = inputbox( "Checkbox tid", "How long should Checkbox run (Hours)?", "24",) $checkbox = $tid * 6 * 60 $o = 1 $o = $o + 1 Do $coord = PixelSearch( 157, 170, 567, 537, 0x00ff00, 30) $color = PixelGetColor( "$coord[0]", "$coord[1]") If $color = ("0x00ff00") Then MouseMove ( "$coord[0]", "$coord[1]") MouseClick ("left", "$coord[0]", "$coord[1]") Until $o = $checkboxYou have your $o = $o + 1 outside a loop, so it will only ever = 1 for starters.Your mouseclick doesn't know how many times to click for 2.Opt("PixelCoordMode", 0); If your Coords are Window Coords / 2 if client coords / 1 if screen coords Opt("MouseCoordMode", 0); same as above ; If your trying to click in a window ; Opt("WinTitleMatchMode", 4) ; $WINDOW = "Title Of Window" $tid = inputbox( "Checkbox tid", "How long should Checkbox run (Hours)?", "24",) $checkbox = $tid * 6 * 60 $o = 1 Do $coord = PixelSearch( 157, 170, 567, 537, 0x00ff00, 30) If Not @error Then If Not WinActive($WINDOW) Then WinActivate($WINDOW) Sleep(200) MouseClick ("left", $coord[0], $coord[1], 1, 1) EndIf Sleep(55) $o = $o + 1 Until $o = $checkboxEdit: Forgot /Code TagEdit2: Noticed there were quotation marks around the variables Edit3: LXP's Code is cleaner (Of Course, I just went off what you were doing already) Edited October 20, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.
LxP Posted October 20, 2005 Posted October 20, 2005 Welcome to the forums! Looks like Ron has beat me to it but I'll post anyway... The problem is that you're comparing the return value of PixelGetColor() (a numeric value) to a string. Actually, you are using quotes in some other places that you probably shouldn't:"0x00ff00" => 0x00ff00"$coord[0]" => $coord[0]One other small problem I can see is that because your code to increment $o lies outside the loop, your loop will run forever. Try this code out for size:; Declare your variables! Local $Duration = InputBox('CheckBox', 'How many hours should CheckBox run?', 24) ; Convert to a value useable by TimerDiff() $Duration = $Duration * 1000 * 60 * 60 ; Note the start time Local $StartTime = TimerInit() ; Loop until the end time is reached While TimerDiff($StartTime) < $Duration Local $Coords = PixelSearch(157, 170, 567, 537, 0x00ff00) ; @Error won't be set if the colour was found If Not(@Error) Then MouseClick('Left', $Coords[0], $Coords[1]) WEnd
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