litlmike Posted March 31, 2006 Share Posted March 31, 2006 What I want: Whenever the pixel rectangle is red, press start. Whenever the pixel rectangle is NOT red, press pause. What Happens: Whenever the pixel rectangle is red, press start. Whenever the pixel rectangle is NOT red, I DON'T DO ANYTHING I have a feeling the issue has to do with some order that things are called in, but I am not sure how to fix it. What do you think? expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start Sleep(10) If @error Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () While $i = 0 WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start $i = $i + 1 WEnd Return EndFunc Func Click_Time_Left_Pause () While $i = 0 WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause $i = $i + 1 WEnd Return EndFunc _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted March 31, 2006 Share Posted March 31, 2006 (edited) shouldnt it be send("^{p}) not just send("^p") expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start Sleep(10) If @error Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () While $i = 0 WinActivate ("TimeLeft Stopwatch") Send ("^{s}) $i = $i + 1 WEnd Return EndFunc Func Click_Time_Left_Pause () While $i = 0 WinActivate ("TimeLeft Stopwatch") send("^{p}) $i = $i + 1 WEnd Return EndFunc Edited March 31, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
litlmike Posted March 31, 2006 Author Share Posted March 31, 2006 shouldnt it be send("^{p}) not just send("^p") No that works. But, thanks for the input. I think the problem is in the first While Loop It seems that if will do Click_Time_Left_Start (), but not Click_Time_Left_Pause () While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start Sleep(10) If @error Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause WEnd _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 31, 2006 Moderators Share Posted March 31, 2006 shouldnt it be send("^{p}) not just send("^p")'^'This tells AutoIt to send a CONTROL keystroke, therefore Send("^!a") would send "CTRL+ALT+a".N.B. Some programs are very choosy about capital letters and CTRL keys, i.e. "^A" is different to "^a". The first says CTRL+SHIFT+A, the second is CTRL+a. If in doubt, use lowercase! 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. Link to comment Share on other sites More sharing options...
litlmike Posted April 1, 2006 Author Share Posted April 1, 2006 Hey Smoke, any feedback on why this script doesn't work properly? _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 1, 2006 Moderators Share Posted April 1, 2006 (edited) Hey Smoke, any feedback on why this script doesn't work properly?Try this:expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i = 0, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start Else Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause EndIf WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () $i = 0 While $i = 0 WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start $i = $i + 1 WEnd EndFunc Func Click_Time_Left_Pause () $i = 0 While $i = 0 WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause $i = $i + 1 WEnd EndFunc P.S. I don't understand your functions, all they are really doing is this:Func Click_Time_Left_Start () WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start EndFunc Func Click_Time_Left_Pause () WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause EndFunc Edited April 1, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
litlmike Posted April 1, 2006 Author Share Posted April 1, 2006 P.S. I don't understand your functions, all they are really doing is this:Func Click_Time_Left_Start () WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start EndFunc Func Click_Time_Left_Pause () WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause EndFunc Sweet, it works (for the most part). Thanks. I admit, that I prolly need a few lessons in writing scripts. 1 More question...How do I change the script so that: Whenever the pixel rectangle is red, press start ONCE, but keep checking for it to turn NOT red. Whenever the pixel rectangle is NOT red, press pause ONCE, but keep checking for when it does turn red again? _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 1, 2006 Moderators Share Posted April 1, 2006 Something like this maybe?expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i = 0, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749, $Check = 0 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error And $Check = 0 Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start $Check = 1 Else If $Check = 1 Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause $Check = 0 EndIf EndIf WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start EndFunc Func Click_Time_Left_Pause () WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause EndFunc 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. Link to comment Share on other sites More sharing options...
litlmike Posted April 1, 2006 Author Share Posted April 1, 2006 Something like this maybe?Hmm... that just made it click start and pause over and over...Darn it, i can't figure this out! _ArrayPermute()_ArrayUnique()Excel.au3 UDF Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 1, 2006 Moderators Share Posted April 1, 2006 (edited) Hmm... that just made it click start and pause over and over... Darn it, i can't figure this out!Sorry... try this:expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i = 0, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749, $Check = 0 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error And $Check = 0 Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start $Check = 1 ElseIf @error And $Check = 1 Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause $Check = 0 EndIf WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start EndFunc Func Click_Time_Left_Pause () WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause EndFunct Edited April 1, 2006 by SmOke_N 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. Link to comment Share on other sites More sharing options...
litlmike Posted April 3, 2006 Author Share Posted April 3, 2006 Sorry... try this:expandcollapse popup#include <IE.au3> #include <Date.au3> #include <GUIConstants.au3> Global $Paused, $cat_1, $date_a, $email, $contact, $company, $email, $title, $i = 0, $SysTrayPixel = 0xFF0000, $DLI_Position_X = 974 Global $DLI_Position_y = 749, $Check = 0 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") ;;;;;;;; Body of program would go here;;;;;;;; While 1 Opt("WinTitleMatchMode",4) Sleep(100) $coord = PixelSearch ( $DLI_Position_X - 1 , $DLI_Position_y - 1, _ $DLI_Position_X, $DLI_Position_y, $SysTrayPixel ) If Not @error And $Check = 0 Then Click_Time_Left_Start (); If it is not the case that the color is not Found, then Start $Check = 1 ElseIf @error And $Check = 1 Then Click_Time_Left_Pause (); If it is the case that the color is not Found, then Pause $Check = 0 EndIf WEnd ;;;;;;;; ; Pause and Escape Functions Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc ;******************************************************************************** Func Click_Time_Left_Start () WinActivate ("TimeLeft Stopwatch") Send ("^s");^s Start EndFunc Func Click_Time_Left_Pause () WinActivate ("TimeLeft Stopwatch") Send ("^p");^p pause EndFunct Pure Genius...Thanks! Works Perfectly! _ArrayPermute()_ArrayUnique()Excel.au3 UDF 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