Ravel Posted July 2, 2008 Share Posted July 2, 2008 I currently have a script that is recursive in that it looks for a title of the window and then if it is found it "runs" another script. The only issue is is that while that works fine, I would like the script to only continue in a recursive state if said window does not appear more than say... 5 times in a 10 min period. If it were to appear more than 5 times in a 10min period, I would like the the script to end. Is this possible? Here is a copy of the simple script I have now: Global $Paused = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
evilertoaster Posted July 2, 2008 Share Posted July 2, 2008 Something like this should work- Global $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
simbo Posted July 2, 2008 Share Posted July 2, 2008 Hi, this is not a full script, just some ideas. Hope it helps! #include <Array.au3> ;dimension an array with 5 elements to store 5 time stamps dim $timestamps[5] ;your loop with a time stamp added everytime your event is triggered while 1 If WinExists("TACAN Fault Data") Then ;put a time stamp at the end of the array, then delete the first element. This produces a "rolling" list of the last 5 events _arraydelete($timestamps,1) _arrayadd($timestamps,timerinit()) ;have there been more than five events in the last 10 minutes (ie, 600000 miliseconds)? if timerinit()-$timestamps[1]>600000 then exit Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") EndIf Wend I currently have a script that is recursive in that it looks for a title of the window and then if it is found it "runs" another script. The only issue is is that while that works fine, I would like the script to only continue in a recursive state if said window does not appear more than say... 5 times in a 10 min period. If it were to appear more than 5 times in a 10min period, I would like the the script to end. Is this possible? Here is a copy of the simple script I have now: Global $Paused = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Ravel Posted July 5, 2008 Author Share Posted July 5, 2008 Thanks I will give these a try, but it looks pretty good. Thanks for the help. Because I had never done a timer/count before. I should be able to use this knowledge else were too. Thanks again. Link to comment Share on other sites More sharing options...
Ravel Posted July 5, 2008 Author Share Posted July 5, 2008 I had another question... Sometime the script return to service...(compiled script) will hang because of the certain windows that are supposed to open doesnt. I added another if,then,else, endif. What I would like to do is pause the script below for 2 and half mins. then search to see if the said .exe process is still running and if it is end it, and loop back to the the beginning of the script. Can you all look this over and let me know if it is correct? I ask because I cannot check the semantics of it because I am at work. expandcollapse popupGlobal $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Sleep (150000) If ProcessExists ("Restore Transmitter to Service2.exe") Then Processclose ("Restore Transmitter to Service2.exe") Else EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Ravel Posted July 7, 2008 Author Share Posted July 7, 2008 I had another question... Sometime the script return to service...(compiled script) will hang because of the certain windows that are supposed to open doesnt. I added another if,then,else, endif. What I would like to do is pause the script below for 2 and half mins. then search to see if the said .exe process is still running and if it is end it, and loop back to the the beginning of the script. Can you all look this over and let me know if it is correct? I ask because I cannot check the semantics of it because I am at work. expandcollapse popupGlobal $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Sleep (150000) If ProcessExists ("Restore Transmitter to Service2.exe") Then Processclose ("Restore Transmitter to Service2.exe") Else EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Bump... any ideas? Link to comment Share on other sites More sharing options...
Ravel Posted July 10, 2008 Author Share Posted July 10, 2008 Something like this should work- Global $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Wend Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Question with this script above it records the number of events during a specific timespan. Is there a way to set it up to continue doing that, but also add a function that records absolute amount of events that occur while the script is running and place it in a txt file? Link to comment Share on other sites More sharing options...
Ravel Posted July 14, 2008 Author Share Posted July 14, 2008 Question with this script above it records the number of events during a specific timespan. Is there a way to set it up to continue doing that, but also add a function that records absolute amount of events that occur while the script is running and place it in a txt file?any ideas? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 14, 2008 Moderators Share Posted July 14, 2008 any ideas?Add another variable that collects all events and doesn't reset, and use FileWrite with that variable... it's a pretty novice question that would take anyone about 30 seconds to do with that script. 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...
Ravel Posted July 14, 2008 Author Share Posted July 14, 2008 Add another variable that collects all events and doesn't reset, and use FileWrite with that variable... it's a pretty novice question that would take anyone about 30 seconds to do with that script. I have never delt with variables. I dont write a lot of auto it scripts, and none of mine have included variables or other scripts. I am still very much a noob when it comes to some of these things. Most of the time I come up here to ask for help with a script when I am trying to get it to do something specific, and I dont understand how to do it. Based on that I have tried to modify the script to do what you suggested. I am not sure if it is correct or not. expandcollapse popupGlobal $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Wend $Count += 1 $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Link to comment Share on other sites More sharing options...
Ravel Posted September 23, 2008 Author Share Posted September 23, 2008 I have never delt with variables. I dont write a lot of auto it scripts, and none of mine have included variables or other scripts. I am still very much a noob when it comes to some of these things. Most of the time I come up here to ask for help with a script when I am trying to get it to do something specific, and I dont understand how to do it. Based on that I have tried to modify the script to do what you suggested. I am not sure if it is correct or not. expandcollapse popupGlobal $Paused = 0 Global $Timer = 0 Global $Count = 0 HotKeySet("{SPACE}", "TogglePause") HotkeySet('{ESC}', 'Terminate') opt ("WinTitleMatchMode",2) while 1 If WinExists("TACAN Fault Data") Then Winclose("TACAN Fault Data") Run("C:\Documents and Settings\Administrator\My Documents\Scripts\Restore Transmitter to Service2.exe") $Count += 1 if $Count>5 Then Exit EndIf if $Timer = 0 then $Timer = TimerInit() EndIf if ((TimerDiff($Timer)/1000)/60) > 10 Then $Timmer = TimerInit() $count=0 EndIf EndIf Wend $Count += 1 $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then Exit EndIf FileWrite($file, "Line1") FileWrite($file, "Still Line1" & @CRLF) FileWrite($file, "Line2") FileClose($file) Func TogglePause() $Paused = Not $Paused While $Paused Sleep (1) WEnd EndFunc Func Terminate() Exit EndFunc Can Someone look this over to help assist me in ensuring that this script will work? I cannot test it on my PC because I do not have the ability to install Autoit at work. Any help in ensuring this works would be appreciated. Thanks. Link to comment Share on other sites More sharing options...
Ravel Posted September 23, 2008 Author Share Posted September 23, 2008 Can Someone look this over to help assist me in ensuring that this script will work? I cannot test it on my PC because I do not have the ability to install Autoit at work. Any help in ensuring this works would be appreciated. Thanks.What i am most interested in is the portion of the script that creates the text file. 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