skoal2k4 Posted February 28, 2005 Share Posted February 28, 2005 Func Move() $result = 0 WinActivate ("Connected to """ & $tablename); while $result = 0 $color = PixelGetColor (338, 55); if $color = 255 then $result = 1 return $result endif $color = PixelGetColor (338, 67); if $color = 65535 then $result = 2 return $result endif $color = PixelGetColor (338, 79); if $color = 16776960 then $result = 3 return $result endif $color = PixelGetColor (338, 88); if $color = 65280 then $result = 4 return $result endif Wend EndFunc completely new to this... just looking for a review and advice... I can't get this thing to return any values... help???? Link to comment Share on other sites More sharing options...
Alterego Posted February 28, 2005 Share Posted February 28, 2005 Func Move() $result = 0 WinActivate("Connected to """ & $tablename); While $result = 0 $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 Return $result EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 Return $result EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 Return $result EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 Return $result EndIf WEnd EndFunc ;==>MoveHumm.... is your WinActivate line formatted properly? Is the title really Connected to ""? This dynamic web page is powered by AutoIt 3. Link to comment Share on other sites More sharing options...
skoal2k4 Posted February 28, 2005 Author Share Posted February 28, 2005 Func Move() $result = 0 WinActivate("Connected to """ & $tablename); While $result = 0 $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 Return $result EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 Return $result EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 Return $result EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 Return $result EndIf WEnd EndFunc ;==>MoveHumm.... is your WinActivate line formatted properly? Is the title really Connected to ""?<{POST_SNAPBACK}>Yeah, That window becomes active like it's supposed to... but it seems like there's no Return value sent Link to comment Share on other sites More sharing options...
Nakuribon Posted February 28, 2005 Share Posted February 28, 2005 just for teh heck of it, try: WinActivate("Connected to " & '"' & $tablename & '"') i own this sig... php rulezlinks:My PSP Web Portal Link to comment Share on other sites More sharing options...
Insolence Posted February 28, 2005 Share Posted February 28, 2005 If you want to see what that string turns into, try to debug it like this MsgBox("","", "Connected to " & '"' & $tablename & '"') "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
skoal2k4 Posted February 28, 2005 Author Share Posted February 28, 2005 just for teh heck of it, try: WinActivate("Connected to " & '"' & $tablename & '"')<{POST_SNAPBACK}>Ok... I tried that and the "connected to" window didn't acitivate, so i put it back to the way it was... As far as the function goes, the syntax is ok though? I'm not missing anything right? Is there a better alternative to this than a while loop? Link to comment Share on other sites More sharing options...
Nakuribon Posted February 28, 2005 Share Posted February 28, 2005 i see ur prob... try this: Func Move() $result = 0 WinActivate("Connected to """ & $tablename); While $result = 0 $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 EndIf WEnd Return $result EndFunc ;==>Move see, whats happening is ur loop is exiting and therefore breaking the operation when you change $result because ur loop is While $result = 0. As soon as it changes, any subsequent code in the loop is not processed, therefore there is no return value being sent.... i own this sig... php rulezlinks:My PSP Web Portal Link to comment Share on other sites More sharing options...
Alterego Posted February 28, 2005 Share Posted February 28, 2005 hah! nice catch. This dynamic web page is powered by AutoIt 3. Link to comment Share on other sites More sharing options...
skoal2k4 Posted February 28, 2005 Author Share Posted February 28, 2005 i see ur prob... try this:Func Move() $result = 0 WinActivate("Connected to """ & $tablename); While $result = 0 $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 EndIf WEnd Return $result EndFunc;==>Movesee, whats happening is ur loop is exiting and therefore breaking the operation when you change $result because ur loop is While $result = 0. As soon as it changes, any subsequent code in the loop is not processed, therefore there is no return value being sent....<{POST_SNAPBACK}>I tried that and the same result :\ ... so I did this...Func Move() Run("notepad.exe") $result = 0 WinActivate("Connected to """ & $tablename) While $result = 0 $color = PixelGetColor(338, 55);red If $color = 255 Then WinActivate("Untitled - Notepad") Send("red") $result = 1 EndIf $color = PixelGetColor(338, 66);yellow If $color = 65535 Then WinActivate("Untitled - Notepad") Send("yellow") $result = 2 EndIf $color = PixelGetColor(338, 77);blue If $color = 16776960 Then WinActivate("Untitled - Notepad") Send("blue") $result = 3 EndIf $color = PixelGetColor(338, 88);green If $color = 65280 Then WinActivate("Untitled - Notepad") Send("green") $result = 4 EndIf WEnd WinActivate($tablename) Return $result EndFunc ;==>MoveNotepad opened up and the windown with the title of "Connected to.." came active... but nothing after that... thoughts? Link to comment Share on other sites More sharing options...
Nakuribon Posted February 28, 2005 Share Posted February 28, 2005 try not using a while loop i dont kno wat to use in place of it, but maybe just dont loop it at all... i own this sig... php rulezlinks:My PSP Web Portal Link to comment Share on other sites More sharing options...
phillip123adams Posted February 28, 2005 Share Posted February 28, 2005 see, whats happening is ur loop is exiting and therefore breaking the operation when you change $result because ur loop is While $result = 0. As soon as it changes, any subsequent code in the loop is not processed, therefore there is no return value being sent....<{POST_SNAPBACK}>@NakuribonWhat skoal2k4 had for this part works okay because the Until statement does not test its condition until everything before it has been done (it does not see $result change as soon as it changes). Since skoal2k4 issued a Return statement immediately after assigning a value to $result, the Until statement would not have been reached on that loop and the entire Func would have exited and the value returned.@skoal2k4It is difficult to debug without the exact window you are using, but I think the problem is one of two things. Either the Window Title is not correct (including the case of each character, and the quote embedded in the title you provide),or the color values are incorrect. Try the following which is your code plus some debugging code I added. It should narrow the possibilities a bit.expandcollapse popup; For debugging purposes. $MyColor = PixelGetColor(338, 55); $XX = Move() ToolTip("") MsgBox(4096, "Debug", "The returned value is " & $XX) Exit Func Move() $result = 0 opt("WinTitleMatchMode", 2) WinActivate("Connected to """ & $tablename); While $result = 0 ; For debugging purposes. ToolTip("The while loop is still looking for a color match." &@lf&@lf& "If you see this tool tip for more than a second," &@lf& "there is no color match. Use the tray icon to stop.") $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 Return $result EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 Return $result EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 Return $result EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 Return $result EndIf ; For debugging purposes. ; Since $MyColor came from 338,55 the next test ; will be true (if this point is reached). $color = PixelGetColor(338, 55); If $color = $MyColor Then ToolTip("") MsgBox(4096, "Debug", "The color at 338,55 is " & $Color &@lf&@LF& "for window title 'Connected to """ & $tablename &"'" &@LF&@LF& "5 will be returned.") Return 5 EndIf WEnd MsgBox(4096, 1, 1) EndFunc ;==>Move Phillip Link to comment Share on other sites More sharing options...
skoal2k4 Posted February 28, 2005 Author Share Posted February 28, 2005 @NakuribonWhat skoal2k4 had for this part works okay because the Until statement does not test its condition until everything before it has been done (it does not see $result change as soon as it changes). Since skoal2k4 issued a Return statement immediately after assigning a value to $result, the Until statement would not have been reached on that loop and the entire Func would have exited and the value returned.@skoal2k4It is difficult to debug without the exact window you are using, but I think the problem is one of two things. Either the Window Title is not correct (including the case of each character, and the quote embedded in the title you provide),or the color values are incorrect. Try the following which is your code plus some debugging code I added. It should narrow the possibilities a bit.expandcollapse popup; For debugging purposes. $MyColor = PixelGetColor(338, 55); $XX = Move() ToolTip("") MsgBox(4096, "Debug", "The returned value is " & $XX) Exit Func Move() $result = 0 opt("WinTitleMatchMode", 2) WinActivate("Connected to """ & $tablename); While $result = 0 ; For debugging purposes. ToolTip("The while loop is still looking for a color match." &@lf&@lf& "If you see this tool tip for more than a second," &@lf& "there is no color match. Use the tray icon to stop.") $color = PixelGetColor(338, 55); If $color = 255 Then $result = 1 Return $result EndIf $color = PixelGetColor(338, 67); If $color = 65535 Then $result = 2 Return $result EndIf $color = PixelGetColor(338, 79); If $color = 16776960 Then $result = 3 Return $result EndIf $color = PixelGetColor(338, 88); If $color = 65280 Then $result = 4 Return $result EndIf ; For debugging purposes. ; Since $MyColor came from 338,55 the next test ; will be true (if this point is reached). $color = PixelGetColor(338, 55); If $color = $MyColor Then ToolTip("") MsgBox(4096, "Debug", "The color at 338,55 is " & $Color &@lf&@LF& "for window title 'Connected to """ & $tablename &"'" &@LF&@LF& "5 will be returned.") Return 5 EndIf WEnd MsgBox(4096, 1, 1) EndFunc ;==>Move<{POST_SNAPBACK}>Well, I feel like an idiot now... It wasn't seeing the color so I had to put this in there...AutoItSetOption("ColorMode", 1)Everything works great now... thanks for all the help! Link to comment Share on other sites More sharing options...
phillip123adams Posted February 28, 2005 Share Posted February 28, 2005 AutoItSetOption("ColorMode", 1)Everything works great now... thanks for all the help!<{POST_SNAPBACK}>You're welcome, and good catch! Phillip 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