oemript Posted December 6, 2018 Share Posted December 6, 2018 (edited) I would like to know on how to force exit script if it runs over 3 minutes. Does anyone have any suggestions? Thanks in advance for any suggestions Edited December 6, 2018 by oemript Link to comment Share on other sites More sharing options...
Xandy Posted December 6, 2018 Share Posted December 6, 2018 (edited) Local $timer = TimerInit() ; Record time to start timer Local $timer_len = 1000 * 3 ; 3000 milliseconds is 3 seconds Do If TimerDiff($timer) >= $timer_len Then Exit Until 0 Edited December 6, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
TheDcoder Posted December 6, 2018 Share Posted December 6, 2018 Or you can go the adlib route if your code is too complicated to be in a event loop or if you are extra lazy: AdlibRegister(ThreeMinuteExit, 60 * 3 * 1000) ; 3 minutes in milliseconds Func ThreeMinuteExit() MsgBox(0, "3 minutes", "Hey mate your time is up, now it is time to quit") Exit EndFunc @Xandy You used 3 seconds instead of the 3 minutes OP asked for by the way Xandy and Skysnake 2 EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
oemript Posted December 6, 2018 Author Share Posted December 6, 2018 (edited) I would like to know on where to place existing coding within Do loop. Furthermore, I do not mean to Exit Do loop. since AutoIT would activate cmd window, I want to exit current running cmd window by force. Local $timer = TimerInit() ; Record time to start timer Local $timer_len = 1000 * 3 ; 3000 milliseconds is 3 seconds Do If TimerDiff($timer) >= $timer_len Then Exit Place existing coding here? which would run under cmd mode Until 0 Do you have any suggestions? Thank you very much for any suggestions (^v^) Edited December 6, 2018 by oemript Link to comment Share on other sites More sharing options...
Xandy Posted December 6, 2018 Share Posted December 6, 2018 (edited) Do you use a loop to control the flow of your code? You could place the first codes I posted in and before your main loop. Set the variables before the loop: Local $timer = TimerInit() ; Record time to start timer Local $timer_len = 1000 * 60 * 3 ; 180000 milliseconds is 3 minutes and do the If TimerDiff() inside your loop. If TimerDiff($timer) >= $timer_len Then Exit You could make a passive function to check time. Local $timer = TimerInit() Func Exit_After_3Miniutes($timer) Local $timer_len = 1000 * 60 * 3; 180000 milliseconds is 3 minutes If TimerDiff($timer) >= $timer_len Then Exit EndFunc Set the timer before the loop and call the function from within your loop. Edited December 6, 2018 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted December 6, 2018 Share Posted December 6, 2018 If you still need assistance, paste your code and I will modify. Skeletor 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 6, 2018 Moderators Share Posted December 6, 2018 Moved to the appropriate forum. Moderation Team 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...
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