truther242 Posted October 29, 2012 Share Posted October 29, 2012 So let's say that I have a script that writes words in notepad. It’s all working great until notepad suddenly decides to crash. How do I make sure that the program constantly checks “has notepad crashed?” while still running the main code? So for example $test = winactive(“notepad.exe”) If $test = 0 then ;notepad crashed How would I keep this running WHILE my code writes in notepad? If I were just to write While 1 $test = winactive(“notepad.exe”) If $test = 0 then ;notepad crashed Well the code would be stuck here and the rest of the code would not be executed. What I want to do is constantly check if notepad has crashed if it has stop whatever the main code is doing an relaunch notepad Hope you understand Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 29, 2012 Moderators Share Posted October 29, 2012 truther242,Use an Adlib function to check at regular intervals - your main script is only momentarily interrupted each time. 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...
truther242 Posted October 29, 2012 Author Share Posted October 29, 2012 truther242,Use an Adlib function to check at regular intervals - your main script is only momentarily interrupted each time. M23works amazingly thanks Link to comment Share on other sites More sharing options...
truther242 Posted October 29, 2012 Author Share Posted October 29, 2012 (edited) truther242, Use an Adlib function to check at regular intervals - your main script is only momentarily interrupted each time. M23 Until I tested it a few times it worked amazingly Anyways my problem is that after the adlib has been executed and relaunched notepad.exe the adlib function that runs throughout the program stops. How do I keep the function running after fixing the first crash? I tried this but it does not seem to make the adlib function check every 250 ms again :< AdlibRegister("Order",250) Func order() $test = WinActive("Notepad") If $test = 0 then relauncnotepad() endfunc relauncnotepad() AdlibRegister("Order",250) Etc.. endfunc Edited October 29, 2012 by truther242 Link to comment Share on other sites More sharing options...
kylomas Posted October 29, 2012 Share Posted October 29, 2012 truther242, The adlib will not stop till you unregister it. Your problem lies elsewhere. Are you sure that this test is true when you expect it to be?If $test = 0 then relauncnotepad() Also, how is notepad stopping? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
truther242 Posted October 30, 2012 Author Share Posted October 30, 2012 (edited) this is the code expandcollapse popupAdlibRegister("Order",250) $Time = _Timer_Init() main() func main() while 1 WinActivate("ChillControl V.exe") MouseClick("left",438,423,2) sleep(2000) MouseClick("left",426,357,2) sleep(2000) MouseClick("left",442,580,2) sleep(2000) if $RunTime > 0.1 Then WinActivate("ChillControl V.exe") Send("!+{F4}") $QTS = 1 EndIf WEnd EndFunc func Order() $Spot = WinActive("ChillControl V.exe") $RunTime = _Timer_Diff($Time) $RunTime = $RunTime / 1000 $RunTime = $RunTime / 60 ToolTip("RUNTIME " & $RunTime, 0 , 0) if $Spot= 0 AND $QTS = 1 Then reset() EndFunc func reset() Run("C:Program Files (x86)Antec CCChillControl V.exe") sleep(2000) $QTS = 0 $Time = _Timer_Init() main() EndFunc for some reason the adlib function stops running after first reset Edited October 30, 2012 by truther242 Link to comment Share on other sites More sharing options...
kylomas Posted October 30, 2012 Share Posted October 30, 2012 (edited) truther242, Tooltip may be blocking. Send your calc back to the main loop with a variable and issue the tooltip there. kylomas edit: I also would not call another func from the adlib. Send a true/false variable back to the mainloop and call from there. Edited October 30, 2012 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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