gte Posted October 7, 2009 Share Posted October 7, 2009 (edited) In my code, I need one loop to run, and then sleep for 540000 ms and then run again (regardless of anything). I need another loops to run every 1000 ms and check for windows that are popping up and close them immediately. I can post my code, but it won't run on anyone's machine unless they have the peregrine software unfortunately. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=caprskeepalive.ico #AutoIt3Wrapper_outfile=carpskeepalive1withrefresh.exe #AutoIt3Wrapper_Res_Comment=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Description=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #include <Timers.au3> #Include <Misc.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) Opt('Sendkeydelay',75) Opt("WinTitleMatchMode", 1) func caprskeepalive() if ProcessExists('scguiw32.exe') then Sleep (7000) Else $caprsusername = @UserName If _Timer_GetIdleTime () <= "5000" Then Sleep(5000) Else Run(@ComSpec & " /c " & 'scguiw32.exe', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) sleep(2500) Send($caprsusername) Sleep(500) send("{enter}") sleep(3000) Send("{TAB}") Sleep(2500) send("{enter}") EndIf EndIf EndFunc While 1 If ProcessExists('scguiw32.exe') Then If _Timer_GetIdleTime () <= "5000" Then Sleep(2000) Else $originalwindow = WinGetState("ServiceCenter - [Incident", "Incident Queue:") If $originalwindow < 8 OR $originalwindow > 15 Then ; not active or minimized $activewindow = WinGetHandle("[active]") ; sets the caprs window to variable $activewindow WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 0) ; makes the caprs window transparent EndIf WinActivate("ServiceCenter - [Incident", "Incident Queue:") ; sets the caprs window to active If $originalwindow < 16 Then ; if caprs window not minimized do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" Sleep(250) EndIf If $originalwindow > 15 Then ; if caprs window is minimized WinSetState("ServiceCenter - [Incident", "Incident Queue:",@SW_RESTORE) ; restore the caprs window if it is minimized EndIf sleep(100) $winposition = WinGetPos("ServiceCenter", "Incident Queue:") ; store the window position in a variable/array $array = _ArrayToString($winposition, @CRLF, 0) $array2 = StringSplit($array, @CRLF) $originalXaxis = $array2[1] $originalYaxis = $array2[3] If $originalwindow > 15 Then ; if window was originally minimized WinMove("ServiceCenter - [Incident", "Incident Queue:", 2700, 102) ; move the window off screen EndIf Sleep(100) If $originalwindow < 16 Then ; if original window was NOT minimized do Until _Timer_GetIdleTime () >= "5000" ; sleep until there is 5 full seconds of inactivity Sleep(250) EndIf if WinActive("ServiceCenter - [Incident", "Incident Queue: ") = 1 Then ; if the caprs list specific window is active Sleep(100) Send("{F2}") ; send F2 to refresh it EndIf sleep(100) If $originalwindow > 15 Then ; if the original window is minimized, move it back to the original coordinates WinMove("ServiceCenter - [Incident", "Incident Queue:", $originalXaxis, $originalYaxis) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow > 15 Then WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow < 8 OR $originalwindow > 15 then ; if the original window not active or minimized WinActivate($activewindow) ; set the $activewindow value to active EndIf Sleep(250) WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 255 ) ; set the transparency back to none for the caprs window Sleep(540000) EndIf EndIf WEnd while 1 if WinExists('Active Notes') Then ; if the annoying notes window pops up WinClose('Active Notes') ; close the annoying note window elseif WinExists('ServiceCenter', 'Your inactive session has timed out, Client will terminate.') Then WinClose('Active Notes', 'Active Notes') ; if the annoying notes window or inactive window pops up, close them both WinClose('ServiceCenter') caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter','ServiceCenter terminated due to a data transmission error. Please see the ServiceCenter log for more details.') Then WinClose('ServiceCenter') ; if the transmission error window pops, close it caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter', 'ServiceCenter terminated') Then ; if the service terminated window pops WinClose('ServiceCenter', 'ServiceCenter terminated') ; close it WinClose('Active Notes', 'Active Notes') ; close the active notes window too caprskeepalive() ; start caprs again elseif WinExists("[CLASS:xSC4550detdoc9012]", "") = 1 Then ; if the session times out overnight/weekend WinActivate("[CLASS:xSC4550detdoc9012]", "") ; activate the window Sleep(1000) ProcessClose("scguiw32.exe") ; kill the caprs process, which in turn closes the session time out window Sleep(2000) caprskeepalive() elseif ProcessExists('scguiw32.exe') = 1 Then ; if the caprs process exists, sleep for 1 second Sleep(1000) Else Sleep(15000) EndIf if ProcessExists('scguiw32.exe') <> 1 Then ; if the caprs process does not exists, start the program caprskeepalive() EndIf WEnd Edited October 9, 2009 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 7, 2009 Moderators Share Posted October 7, 2009 gte,Have you looked at Adlib? If not, I would suggest that you do. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
FuryCell Posted October 7, 2009 Share Posted October 7, 2009 (edited) AdLibEnable should do what you want. It can call a function every x amount of ms.Edit:Beat me to it Edited October 7, 2009 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code. Link to comment Share on other sites More sharing options...
gte Posted October 7, 2009 Author Share Posted October 7, 2009 Hi, I did briefly look at adlib Reading at it, I thought that it might hose my sleep command like a message box would? Is this the case, or did I misread? HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
UEZ Posted October 7, 2009 Share Posted October 7, 2009 (edited) Use AdlibRegister ( "function" [, time] ) to add more than one running function at same time! To do this you have to compile/run it with latest beta version (v3.3.1.1 (beta))And use AdlibUnRegister( "function" ) to unregister Adlib function!Look in Beta helpfile for more details!Btw, I see that you working with Service Center, too. Incident / change management? UEZ Edited October 8, 2009 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
wolf9228 Posted October 7, 2009 Share Posted October 7, 2009 In my code, I need one loop to run, and then sleep for 540000 ms and then run again (regardless of anything). I need another loops to run every 1000 ms and check for windows that are popping up and close them immediately. I can post my code, but it won't run on anyone's machine unless they have the peregrine software unfortunately. expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=caprskeepalive.ico #AutoIt3Wrapper_outfile=carpskeepalive1withrefresh.exe #AutoIt3Wrapper_Res_Comment=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Description=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright=Brad W - 2009 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #include <Timers.au3> #Include <Misc.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) Opt('Sendkeydelay',75) Opt("WinTitleMatchMode", 1) func caprskeepalive() if ProcessExists('scguiw32.exe') then Sleep (7000) Else $caprsusername = @UserName If _Timer_GetIdleTime () <= "5000" Then Sleep(5000) Else Run(@ComSpec & " /c " & 'scguiw32.exe', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) sleep(2500) Send($caprsusername) Sleep(500) send("{enter}") sleep(3000) Send("{TAB}") Sleep(2500) send("{enter}") EndIf EndIf EndFunc While 1 If ProcessExists('scguiw32.exe') Then If _Timer_GetIdleTime () <= "5000" Then Sleep(2000) Else $originalwindow = WinGetState("ServiceCenter - [Incident", "Incident Queue:") If $originalwindow < 8 OR $originalwindow > 15 Then ; not active or minimized $activewindow = WinGetHandle("[active]") ; sets the caprs window to variable $activewindow WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 0) ; makes the caprs window transparent EndIf WinActivate("ServiceCenter - [Incident", "Incident Queue:") ; sets the caprs window to active If $originalwindow < 16 Then ; if caprs window not minimized do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" Sleep(250) EndIf If $originalwindow > 15 Then ; if caprs window is minimized WinSetState("ServiceCenter - [Incident", "Incident Queue:",@SW_RESTORE) ; restore the caprs window if it is minimized EndIf sleep(100) $winposition = WinGetPos("ServiceCenter", "Incident Queue:") ; store the window position in a variable/array $array = _ArrayToString($winposition, @CRLF, 0) $array2 = StringSplit($array, @CRLF) $originalXaxis = $array2[1] $originalYaxis = $array2[3] If $originalwindow > 15 Then ; if window was originally minimized WinMove("ServiceCenter - [Incident", "Incident Queue:", 2700, 102) ; move the window off screen EndIf Sleep(100) If $originalwindow < 16 Then ; if original window was NOT minimized do Until _Timer_GetIdleTime () >= "5000" ; sleep until there is 5 full seconds of inactivity Sleep(250) EndIf if WinActive("ServiceCenter - [Incident", "Incident Queue: ") = 1 Then ; if the caprs list specific window is active Sleep(100) Send("{F2}") ; send F2 to refresh it EndIf sleep(100) If $originalwindow > 15 Then ; if the original window is minimized, move it back to the original coordinates WinMove("ServiceCenter - [Incident", "Incident Queue:", $originalXaxis, $originalYaxis) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow > 15 Then WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow < 8 OR $originalwindow > 15 then ; if the original window not active or minimized WinActivate($activewindow) ; set the $activewindow value to active EndIf Sleep(250) WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 255 ) ; set the transparency back to none for the caprs window Sleep(540000) EndIf EndIf WEnd while 1 if WinExists('Active Notes') Then ; if the annoying notes window pops up WinClose('Active Notes') ; close the annoying note window elseif WinExists('ServiceCenter', 'Your inactive session has timed out, Client will terminate.') Then WinClose('Active Notes', 'Active Notes') ; if the annoying notes window or inactive window pops up, close them both WinClose('ServiceCenter') caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter','ServiceCenter terminated due to a data transmission error. Please see the ServiceCenter log for more details.') Then WinClose('ServiceCenter') ; if the transmission error window pops, close it caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter', 'ServiceCenter terminated') Then ; if the service terminated window pops WinClose('ServiceCenter', 'ServiceCenter terminated') ; close it WinClose('Active Notes', 'Active Notes') ; close the active notes window too caprskeepalive() ; start caprs again elseif WinExists("[CLASS:xSC4550detdoc9012]", "") = 1 Then ; if the session times out overnight/weekend WinActivate("[CLASS:xSC4550detdoc9012]", "") ; activate the window Sleep(1000) ProcessClose("scguiw32.exe") ; kill the caprs process, which in turn closes the session time out window Sleep(2000) caprskeepalive() elseif ProcessExists('scguiw32.exe') = 1 Then ; if the caprs process exists, sleep for 1 second Sleep(1000) Else Sleep(15000) EndIf if ProcessExists('scguiw32.exe') <> 1 Then ; if the caprs process does not exists, start the program caprskeepalive() EndIf WEnd http://msdn.microsoft.com/en-us/library/ms682453(VS.85).aspx CreateThread Function Creates a thread to execute within the virtual address space of the calling process. To create a thread that runs in the virtual address space of another process, use the CreateRemoteThread function. But in Autoit that is not possible except by using Assembly language Through the Autoit language Such an example in this topic Execute in a different thread http://www.autoitscript.com/forum/index.php?showtopic=95510&st=0&p=686626&fromsearch=1&#entry686626 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
TurionAltec Posted October 8, 2009 Share Posted October 8, 2009 Something along these lines may work too: Big_ol_wait() $timer1=TimerInit() While 1 If TimerDiff($timer1)>=540000 Then Big_ol_wait() $timer1=TimerInit() WEnd Everysecond() Sleep(1000) WEnd Or as mentioned Adlib. If you don't have the beta, look at this UDF: http://www.autoitscript.com/forum/index.php?showtopic=83967&view=findpost&p=601345 No, it's not actually multithreaded but it lets you register multiple adlibs. Link to comment Share on other sites More sharing options...
gte Posted October 9, 2009 Author Share Posted October 9, 2009 (edited) Yes, damn java and service center, ugh! So how about this, is this what you meant? Because I've noticed that adlibenable hoses my _Timer_GetIdleTime () What am I doing wrong? expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=caprskeepalive.ico #AutoIt3Wrapper_outfile=carpskeepalive1withrefresh.exe #AutoIt3Wrapper_Res_Comment=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Description=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #include <Timers.au3> #Include <Misc.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) Opt('Sendkeydelay',75) Opt("WinTitleMatchMode", 1) func caprskeepalive() if ProcessExists('scguiw32.exe') then Sleep (7000) Else $caprsusername = @UserName If _Timer_GetIdleTime () <= "5000" Then Sleep(5000) Else Run(@ComSpec & " /c " & 'scguiw32.exe -express:xxxx', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) sleep(2500) Send($caprsusername) Sleep(500) send("{enter}") sleep(3000) Send("{TAB}") Sleep(2500) send("{enter}") EndIf EndIf EndFunc AdlibEnable("windowclose", 1000) While 1 If ProcessExists('scguiw32.exe') Then If _Timer_GetIdleTime () <= "5000" Then Sleep(2000) Else $originalwindow = WinGetState("ServiceCenter - [Incident", "Incident Queue:") If $originalwindow < 8 OR $originalwindow > 15 Then ; not active or minimized $activewindow = WinGetHandle("[active]") ; sets the caprs window to variable $activewindow WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 0) ; makes the caprs window transparent EndIf WinActivate("ServiceCenter - [Incident", "Incident Queue:") ; sets the caprs window to active If $originalwindow < 16 Then ; if caprs window not minimized do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" Sleep(250) EndIf If $originalwindow > 15 Then ; if caprs window is minimized WinSetState("ServiceCenter - [Incident", "Incident Queue:",@SW_RESTORE) ; restore the caprs window if it is minimized EndIf sleep(100) $winposition = WinGetPos("ServiceCenter", "Incident Queue:") ; store the window position in a variable/array $array = _ArrayToString($winposition, @CRLF, 0) $array2 = StringSplit($array, @CRLF) $originalXaxis = $array2[1] $originalYaxis = $array2[3] If $originalwindow > 15 Then ; if window was originally minimized WinMove("ServiceCenter - [Incident", "Incident Queue:", 2700, 102) ; move the window off screen EndIf Sleep(100) If $originalwindow < 16 Then ; if original window was NOT minimized do Until _Timer_GetIdleTime () >= "5000" ; sleep until there is 5 full seconds of inactivity Sleep(250) EndIf if WinActive("ServiceCenter - [Incident", "Incident Queue: ") = 1 Then ; if the caprs list specific window is active Sleep(100) Send("{F2}") ; send F2 to refresh it EndIf sleep(100) If $originalwindow > 15 Then ; if the original window is minimized, move it back to the original coordinates WinMove("ServiceCenter - [Incident", "Incident Queue:", $originalXaxis, $originalYaxis) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow > 15 Then WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow < 8 OR $originalwindow > 15 then ; if the original window not active or minimized WinActivate($activewindow) ; set the $activewindow value to active ;~ WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 255 ) ; set the transparency back to none for the caprs window ;~ Sleep(540000) EndIf EndIf WEnd Func windowclose() if WinExists('Active Notes') Then ; if the annoying notes window pops up WinClose('Active Notes') ; close the annoying note window elseif WinExists('ServiceCenter', 'Your inactive session has timed out, Client will terminate.') Then WinClose('Active Notes', 'Active Notes') ; if the annoying notes window or inactive window pops up, close them both WinClose('ServiceCenter') caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter','ServiceCenter terminated due to a data transmission error. Please see the ServiceCenter log for more details.') Then WinClose('ServiceCenter') ; if the transmission error window pops, close it caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter', 'ServiceCenter terminated') Then ; if the service terminated window pops WinClose('ServiceCenter', 'ServiceCenter terminated') ; close it WinClose('Active Notes', 'Active Notes') ; close the active notes window too caprskeepalive() ; start caprs again elseif WinExists("[CLASS:xSC4550detdoc9012]", "") = 1 Then ; if the session times out overnight/weekend WinActivate("[CLASS:xSC4550detdoc9012]", "") ; activate the window Sleep(1000) ProcessClose("scguiw32.exe") ; kill the caprs process, which in turn closes the session time out window Sleep(2000) caprskeepalive() elseif ProcessExists('scguiw32.exe') = 1 Then ; if the caprs process exists, sleep for 1 second Sleep(1000) Else Sleep(15000) EndIf if ProcessExists('scguiw32.exe') <> 1 Then ; if the caprs process does not exists, start the program caprskeepalive() EndIf EndFunc On 10/7/2009 at 5:37 PM, 'UEZ said: Use AdlibRegister ( "function" [, time] ) to add more than one running function at same time! To do this you have to compile/run it with latest beta version (v3.3.1.1 (beta)) And use AdlibUnRegister( "function" ) to unregister Adlib function! Look in Beta helpfile for more details! Btw, I see that you working with Service Center, too. Incident / change management? UEZ Edited April 27, 2018 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
martin Posted October 9, 2009 Share Posted October 9, 2009 Yes, damn java and service center, ugh! So how about this, is this what you meant? Because I've noticed that adlibenable hoses my _Timer_GetIdleTime () What am I doing wrong? expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=caprskeepalive.ico #AutoIt3Wrapper_outfile=carpskeepalive1withrefresh.exe #AutoIt3Wrapper_Res_Comment=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Description=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright=Brad W - 2009 #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #include <Timers.au3> #Include <Misc.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) Opt('Sendkeydelay',75) Opt("WinTitleMatchMode", 1) func caprskeepalive() if ProcessExists('scguiw32.exe') then Sleep (7000) Else $caprsusername = @UserName If _Timer_GetIdleTime () <= "5000" Then Sleep(5000) Else Run(@ComSpec & " /c " & 'scguiw32.exe -express:caprs.ba.ad.ssa.gov.7472', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) sleep(2500) Send($caprsusername) Sleep(500) send("{enter}") sleep(3000) Send("{TAB}") Sleep(2500) send("{enter}") EndIf EndIf EndFunc AdlibEnable("windowclose", 1000) While 1 If ProcessExists('scguiw32.exe') Then If _Timer_GetIdleTime () <= "5000" Then Sleep(2000) Else $originalwindow = WinGetState("ServiceCenter - [Incident", "Incident Queue:") If $originalwindow < 8 OR $originalwindow > 15 Then ; not active or minimized $activewindow = WinGetHandle("[active]") ; sets the caprs window to variable $activewindow WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 0) ; makes the caprs window transparent EndIf WinActivate("ServiceCenter - [Incident", "Incident Queue:") ; sets the caprs window to active If $originalwindow < 16 Then ; if caprs window not minimized do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" Sleep(250) EndIf If $originalwindow > 15 Then ; if caprs window is minimized WinSetState("ServiceCenter - [Incident", "Incident Queue:",@SW_RESTORE) ; restore the caprs window if it is minimized EndIf sleep(100) $winposition = WinGetPos("ServiceCenter", "Incident Queue:") ; store the window position in a variable/array $array = _ArrayToString($winposition, @CRLF, 0) $array2 = StringSplit($array, @CRLF) $originalXaxis = $array2[1] $originalYaxis = $array2[3] If $originalwindow > 15 Then ; if window was originally minimized WinMove("ServiceCenter - [Incident", "Incident Queue:", 2700, 102) ; move the window off screen EndIf Sleep(100) If $originalwindow < 16 Then ; if original window was NOT minimized do Until _Timer_GetIdleTime () >= "5000" ; sleep until there is 5 full seconds of inactivity Sleep(250) EndIf if WinActive("ServiceCenter - [Incident", "Incident Queue: ") = 1 Then ; if the caprs list specific window is active Sleep(100) Send("{F2}") ; send F2 to refresh it EndIf sleep(100) If $originalwindow > 15 Then ; if the original window is minimized, move it back to the original coordinates WinMove("ServiceCenter - [Incident", "Incident Queue:", $originalXaxis, $originalYaxis) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow > 15 Then WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow < 8 OR $originalwindow > 15 then ; if the original window not active or minimized WinActivate($activewindow) ; set the $activewindow value to active ;~ WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 255 ) ; set the transparency back to none for the caprs window ;~ Sleep(540000) EndIf EndIf WEnd Func windowclose() if WinExists('Active Notes') Then ; if the annoying notes window pops up WinClose('Active Notes') ; close the annoying note window elseif WinExists('ServiceCenter', 'Your inactive session has timed out, Client will terminate.') Then WinClose('Active Notes', 'Active Notes') ; if the annoying notes window or inactive window pops up, close them both WinClose('ServiceCenter') caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter','ServiceCenter terminated due to a data transmission error. Please see the ServiceCenter log for more details.') Then WinClose('ServiceCenter') ; if the transmission error window pops, close it caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter', 'ServiceCenter terminated') Then ; if the service terminated window pops WinClose('ServiceCenter', 'ServiceCenter terminated') ; close it WinClose('Active Notes', 'Active Notes') ; close the active notes window too caprskeepalive() ; start caprs again elseif WinExists("[CLASS:xSC4550detdoc9012]", "") = 1 Then ; if the session times out overnight/weekend WinActivate("[CLASS:xSC4550detdoc9012]", "") ; activate the window Sleep(1000) ProcessClose("scguiw32.exe") ; kill the caprs process, which in turn closes the session time out window Sleep(2000) caprskeepalive() elseif ProcessExists('scguiw32.exe') = 1 Then ; if the caprs process exists, sleep for 1 second Sleep(1000) Else Sleep(15000) EndIf if ProcessExists('scguiw32.exe') <> 1 Then ; if the caprs process does not exists, start the program caprskeepalive() EndIf EndFunc I think that you will need to rethink your script. You are trying to call a function every second using AdlibRegister even though that function takes a lot longer than 1 second to complete. You should put something in the function to make it return immediately if it is already executing or you will end up with some sort of error like "stack overflow" or worse. Something like Global FuncWCRun = false . . . Func windowclose() if FuncWCRun then return FuncWCRun = true windowcloseReal() FuncWCRun = false EndFunc and rename your windowclose function to windowcloseReal. In your function caprskeepalive, maybe if ProcessExists('scguiw32.exe') then Return Else instead of if ProcessExists('scguiw32.exe') then Sleep (7000) Else Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
gte Posted October 9, 2009 Author Share Posted October 9, 2009 (edited) Hi Martin, Thanks for the reply, I understood most of what you wrote, except for the function, can you explain a little more what that does? I see that you set it to false in the beginning as a global variable Do you mean the following? Or am I misunderstanding? Quote Func windowclose() if FuncWCRun =1 then return FuncWCRun = true else windowcloseReal() FuncWCRun = false EndFunc expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_icon=caprskeepalive.ico #AutoIt3Wrapper_outfile=carpskeepalive1withrefresh.exe #AutoIt3Wrapper_Res_Comment=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Description=Caprs Keep Alive Utility #AutoIt3Wrapper_Res_Fileversion=1.0.0.7 #AutoIt3Wrapper_Res_LegalCopyright= #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #Include <WinAPI.au3> #include <Timers.au3> #Include <Misc.au3> #include <GUIConstantsEx.au3> #include <Array.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) Opt('Sendkeydelay',75) Opt("WinTitleMatchMode", 1) func caprskeepalive() if ProcessExists('scguiw32.exe') then return Else $caprsusername = @UserName If _Timer_GetIdleTime () <= "5000" Then Sleep(5000) Else Run(@ComSpec & " /c " & 'scguiw32.exe -express:xxx', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) sleep(2500) Send($caprsusername) Sleep(500) send("{enter}") sleep(3000) Send("{TAB}") Sleep(2500) send("{enter}") EndIf EndIf EndFunc AdlibEnable("windowclose", 5000) While 1 If ProcessExists('scguiw32.exe') <> 1 Then ; if the caprs process does not exists, start the program do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" caprskeepalive() EndIf If ProcessExists('scguiw32.exe') Then If _Timer_GetIdleTime () <= "5000" Then Sleep(2000) Else $originalwindow = WinGetState("ServiceCenter - [Incident", "Incident Queue:") If $originalwindow < 8 OR $originalwindow > 15 Then ; not active or minimized $activewindow = WinGetHandle("[active]") ; sets the caprs window to variable $activewindow WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 0) ; makes the caprs window transparent EndIf WinActivate("ServiceCenter - [Incident", "Incident Queue:") ; sets the caprs window to active If $originalwindow < 16 Then ; if caprs window not minimized do ; wait for 5 full seconds of idle time Until _Timer_GetIdleTime () >= "5000" Sleep(250) EndIf If $originalwindow > 15 Then ; if caprs window is minimized WinSetState("ServiceCenter - [Incident", "Incident Queue:",@SW_RESTORE) ; restore the caprs window if it is minimized EndIf sleep(100) $winposition = WinGetPos("ServiceCenter", "Incident Queue:") ; store the window position in a variable/array $array = _ArrayToString($winposition, @CRLF, 0) $array2 = StringSplit($array, @CRLF) $originalXaxis = $array2[1] $originalYaxis = $array2[3] If $originalwindow > 15 Then ; if window was originally minimized WinMove("ServiceCenter - [Incident", "Incident Queue:", 2700, 102) ; move the window off screen EndIf Sleep(100) If $originalwindow < 16 Then ; if original window was NOT minimized do Until _Timer_GetIdleTime () >= "5000" ; sleep until there is 5 full seconds of inactivity Sleep(250) EndIf if WinActive("ServiceCenter - [Incident", "Incident Queue: ") = 1 Then ; if the caprs list specific window is active Sleep(100) Send("{F2}") ; send F2 to refresh it EndIf sleep(100) If $originalwindow > 15 Then ; if the original window is minimized, move it back to the original coordinates WinMove("ServiceCenter - [Incident", "Incident Queue:", $originalXaxis, $originalYaxis) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow > 15 Then WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) ; lengthened to a 1/4 second so it doesn't leave a blank blue screen if $originalwindow < 8 OR $originalwindow > 15 then ; if the original window not active or minimized WinActivate($activewindow) ; set the $activewindow value to active ;~ WinSetState("ServiceCenter - [Incident", "Incident Queue:", @SW_MINIMIZE) EndIf Sleep(250) WinSetTrans ("ServiceCenter - [Incident", "Incident Queue:", 255 ) ; set the transparency back to none for the caprs window Sleep(540000) EndIf EndIf WEnd Func windowclose() if WinExists('Active Notes') Then ; if the annoying notes window pops up WinClose('Active Notes') ; close the annoying note window elseif WinExists('ServiceCenter', 'Your inactive session has timed out, Client will terminate.') Then WinClose('Active Notes', 'Active Notes') ; if the annoying notes window or inactive window pops up, close them both WinClose('ServiceCenter') caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter','ServiceCenter terminated due to a data transmission error. Please see the ServiceCenter log for more details.') Then WinClose('ServiceCenter') ; if the transmission error window pops, close it caprskeepalive() ; start caprs again elseif WinExists('ServiceCenter', 'ServiceCenter terminated') Then ; if the service terminated window pops WinClose('ServiceCenter', 'ServiceCenter terminated') ; close it WinClose('Active Notes', 'Active Notes') ; close the active notes window too caprskeepalive() ; start caprs again elseif WinExists("[CLASS:xSC4550detdoc9012]", "") = 1 Then ; if the session times out overnight/weekend WinActivate("[CLASS:xSC4550detdoc9012]", "") ; activate the window Sleep(1000) ProcessClose("scguiw32.exe") ; kill the caprs process, which in turn closes the session time out window Sleep(2000) caprskeepalive() EndIf EndFunc On 10/9/2009 at 1:11 PM, 'martin said: I think that you will need to rethink your script. You are trying to call a function every second using AdlibRegister even though that function takes a lot longer than 1 second to complete. You should put something in the function to make it return immediately if it is already executing or you will end up with some sort of error like "stack overflow" or worse. Something like Global FuncWCRun = false . . . Func windowclose() if FuncWCRun then return FuncWCRun = true windowcloseReal() FuncWCRun = false EndFunc and rename your windowclose function to windowcloseReal. In your function caprskeepalive, maybe if ProcessExists('scguiw32.exe') then Return Else instead of if ProcessExists('scguiw32.exe') then Sleep (7000) Else Edited April 27, 2018 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
martin Posted October 9, 2009 Share Posted October 9, 2009 Hi Martin, Thanks for the reply, I understood most of what you wrote, except for the function, can you explain a little more what that does? I see that you set it to false in the beginning as a global variable Do you mean the following? Or am I misunderstanding? I meant what I wrote except that my formatting might have confused you. First I have a global variable which tells me if a function is being executed. I called it FuncWCRuns. When the script starts the function is not running so it is set to be false. In the function we need to know if the function has already been called and not been completed so we check FuncWCRuns. Func windowclose() If FuncWCRuns then return; so we don't have more than one instance of the function. ;now we know we are the only case so set the variable FuncWCRuns = True; stop another call to this function winowcloseReal(); call the actual function ;now we have done so before we return set the variable FuncWCRuns = false EndFunc Amother way to do it is to stop adlib like this Adlibregister("windowclose",1000) . . .. Func windowclose() AdlibUnregister("windowclose") windowcloseReal() AdlibRegister("windowclose",1000) EndFunc But I'm not clear what you are trying to acheive and I suspect you are not going to get what you hope for. You have two preocesses which take some seconds each and only one of them will be running at a time. If windowclose takes several seconds and is called again 1 second after it finishes because you are using AdLib, then the other function, which also looks like it takes many seconds, will only complete a cycle for many cycles of the windowclose function. If you really need two operations going on at the same time then you need two scripts. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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