JuggaloZeke Posted April 19, 2008 Share Posted April 19, 2008 (edited) I'm a hobbyist AutoIt user and I like to write little scripts to automate tasks for myself but I've come across something that I can't quite work out.I've got a script that I need to monitor a certain icon and loop until it changes from one (or more) colors to any other undefinded color. I'm having trouble on how to define either the variable or the While's expression.The script uses the PixelGetColor to get the decimal value of the icon. This is stored in variable $deccolor. I then convert that to hex and store that in $color. I have my constants set (which is where I may be going wrong) as such: $green = "[insert hex value]" and in my While expression I just used While $color = $green but even if $color is equal to green it ends the loop and continues with the script.I assume it is just syntax and me not doing something correctly with it but I've tried several variations and I cannot figure it out so any help would be appreciated! Edited April 19, 2008 by JuggaloZeke Link to comment Share on other sites More sharing options...
JohnMC Posted April 19, 2008 Share Posted April 19, 2008 its hard to understand what your saying, without seeing your script im not sure, especialy if your talking about syntax error https://johnscs.com Link to comment Share on other sites More sharing options...
JuggaloZeke Posted April 19, 2008 Author Share Posted April 19, 2008 I figured but I didn't have the script on the PC I was using at the time, so here it is... expandcollapse popupAutoItSetOption ( "WinTitleMatchMode" , 2 ) MsgBox ( 0 , "Location Selector" , "Place mouse on icon and press Enter." ) Dim $location = MouseGetPos() ;MsgBox ( 0 , "DEBUG" , "Mouse x,y: " & $location [ 0 ] & ", " & $location [ 1 ] ) Dim $deccolor = PixelGetColor ( $location [ 0 ] , $location [ 1 ] ) ;MsgBox ( 0 , "DEBUG" , "Decimal color: " & $deccolor ) Dim $color = Hex ( $deccolor , 6 ) Dim Const $yellow = "71620E" Dim Const $red = "A60000" ;MsgBox ( 0 , "DEBUG" , "Hex color: " & $color ) MsgBox ( 0 , "Ready to Start" , "The program is now ready to run." ) While 1 WinActivate ( "Prog1" ) ; ToolTip ( "Activated Prog1." , 0 , 0 ) Sleep ( 1000 ) Send ( "{ENTER}" ) ; ToolTip ( "Sent ENTER key to connect." , 0 , 0 ) Sleep ( 1000 ) While $color = $yellow ; ToolTip ( "Starting WHILE loop" , 0 , 0 ) Sleep ( 1000 ) $deccolor = PixelGetColor ( $location [ 0 ] , $location [ 1 ] ) ; ToolTip ( "Updating COLOR variable." , 0 , 0 ) Sleep ( 1000 ) WEnd ; ToolTip ( "Successfully worked through first WHILE loop." , 0 , 0 ) Sleep ( 1000 ) WinActivate ( "Prog2" ) Send ( "Test" ) Sleep ( 2500 ) WinActivate ( "Prog1" ) Send ( "{ENTER}" ) While $color = $red $deccolor = PixelGetColor ( $location [ 0 ] , $location [ 1 ] ) WEnd WEnd Link to comment Share on other sites More sharing options...
JuggaloZeke Posted April 19, 2008 Author Share Posted April 19, 2008 I guess what is happening is that the the $color is not stored as a string (?) and that is what I am creating with my constants and thus why it isn't working properly. Link to comment Share on other sites More sharing options...
JuggaloZeke Posted April 20, 2008 Author Share Posted April 20, 2008 Bump 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