Sign in to follow this  
Followers 0
Diana (Cda)

Adding time out to this complicated msgbx with delay?

6 posts in this topic

Searched through the forums and found this to timeout a script (found here = http://www.autoitscript.com/forum/index.ph...ime+out\):

Global $Init_Time = TimerInit()
AdlibEnable("Check_Running_Time")

; your script

Func Check_Running_Time()
If TimerDiff($Init_Time) > 3 * 60 * 1000 Then Exit
EndFuncoÝ÷ ÙIߢ»n«^"!j÷§ßÛ`¢Û^+m£
+­l¬r¸©´z)x,¢g¨ç(ºWlyì!jÒ7ö÷¢w°®àN¢jeÆ­âØb²Ç+b²ØZ´ýh¦É"ªºl3z«¨µû§rب¼¡jø§§^¬Ùh¢r¥ê¶§8hºH¦ëfÊ]±Êâ¦Ö¥)íë)¢ÛajÛÊÊ®¢Ü¨º»®*mªê-/z+]¡ë'ßÛlyé­¡·°¢¹"è¥çlm¢b}øº[m¡ø º·¨ºÜ!jÒ7ö÷¢w°®àN"½é¨­êeiǦz{]zÖ¢n¶Ø^iº/yÊy·¢·¶)Þ²·ªºFÚªê-jwjº@vXvꮢÖÞ~Þ¶ªºH|Ú->ºzËÆ+-²«¨¶Ø^v&«Éì^ªê-N§ªê-jwiºÛazV¬·ibë+z«¨´[§r«¨µ§íz»az«¨´IÝ!ûaÁ'tëzV­yÛhªê-jëh×6;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!



SoundPlay(@ScriptDir & "\WAV-PrPref.wav")
Sleep(750)
;________________________________________________________________________________________________
; Text-to-speech follows; if speech installed and enabled (or WinXP), computer will speak the following text:
$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("Diary, Version, 2 point 2, alert.")
Sleep(1000)
;________________________________________________________________________________________________




If Not ProcessExists("thediary.exe") Then

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=None
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
Do
$iMsgBoxAnswer = MsgBox(3,"DIARY v2.2 launch ... ?","Would you like to delay launching ''The Diary''?" & @CR & @CR & "- Clicking ''YES'' brings up box to delay the launch of this program." & @CR & "- Clicking ''NO'' opens the file immediately." & @CR & "- Clicking ''CANCEL'' exits this script.")
Select
    Case $iMsgBoxAnswer = 6 ;Yes
         
            $input = InputBox("''DIARY v2.2 ...'' diary program ...", "Snooze for how many minutes?", 15)
            $time = $input*1000*60
            Sleep($time)
         
            #NoTrayIcon     ; AutoIt's icon doesn't show in systray
            SoundPlay(@ScriptDir & "\WAV-PrPref.wav")
         
         
    Case $iMsgBoxAnswer = 7 ;No
         ;=============================================================================
         #NoTrayIcon
         SoundSetWaveVolume(+20)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         ;_________________________________________________________________________________________________
         ; Text-to-speech follows; if speech installed and enabled, computer will speak the following text:
         $oSp = ObjCreate("SAPI.SpVoice")
         $oSp.Speak("Minimizing apps.  Diary, version, 2 point 2, will be launched momentarily.")
         SoundPlay(@ScriptDir & "\WAV-Computer, old-style.wav")
         ;_________________________________________________________________________________________________
         
         Sleep(3500)
         SoundPlay(@ScriptDir & "\WAV-PrExit.wav")
         Sleep(1500)
         ; minimize all windows
         WinMinimizeAll ( )
         
         Sleep(4000)
         $oSp.Speak("Launching.")
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         Sleep(1000)
         
         ; PATH:  M:\diary, The Diary v2.2\APP- The Diary v2.2\BACKUPS (unzip files to DATA fldr)
         Run('C:\Program Files\0- MY APPS\DOpus8\dopus.exe "M:\DIARY_~1.2\APP-TH~1.2\BACKUP~1"')
         ;WinWait("DATA")
         ;WinSetState ("DATA)", "", @SW_MAXIMIZE)
         WinWait("DATA")
         WinSetState ("DATA", "", @SW_MAXIMIZE)
         
         SoundSetWaveVolume(15)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         
         Sleep(200)
         ; PATH: M:\BKP\bkp, My Own Backup v2.1 (XLent!)\APP- MOB v2.1\MOBv2.exe
         ShellExecute("M:\BKP\bkp, My Own Backup v2.1 (XLent!)\APP- MOB v2.1\MOBv2.exe", "", @SW_MAXIMIZE)
         WinWait("Backup")
         WinSetState ("Backup", "", @SW_MAXIMIZE)
         
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         Sleep(200)
         ;  Open folder:
         ;  PATH = M:\diary, The Diary v2.2\APP- The Diary v2.2\thediary.exe
         ShellExecute("M:\diary, The Diary v2.2\APP- The Diary v2.2\thediary.exe")
         WinWait("Diary")
         WinSetState ("Diary", "", @SW_MAXIMIZE)
         
         SoundSetWaveVolume(-20)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         ;=============================================================================

         
         
Case $iMsgBoxAnswer = 2 ;Cancel
        EndSelect
        Until $iMsgBoxAnswer <> 6

    EndIf   ; this EndIf related to:  "If Not ProcessExists(" ... .exe " Then" seen above ...)




Exit
; finished

Thank you! :P

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Searched through the forums and found this to timeout a script (found here = http://www.autoitscript.com/forum/index.ph...ime+out\):

Global $Init_Time = TimerInit()
AdlibEnable("Check_Running_Time")

; your script

Func Check_Running_Time()
If TimerDiff($Init_Time) > 3 * 60 * 1000 Then Exit
EndFuncoÝ÷ ÙIߢ»n«^"!j÷§ßÛ`¢Û^+m£
+­l¬r¸©´z)x,¢g¨ç(ºWlyì!jÒ7ö÷¢w°®àN¢jeÆ­âØb²Ç+b²ØZ´ýh¦É"ªºl3z«¨µû§rب¼¡jø§§^¬Ùh¢r¥ê¶§8hºH¦ëfÊ]±Êâ¦Ö¥)íë)¢ÛajÛÊÊ®¢Ü¨º»®*mªê-/z+]¡ë'ßÛlyé­¡·°¢¹"è¥çlm¢b}øº[m¡ø º·¨ºÜ!jÒ7ö÷¢w°®àN"½é¨­êeiǦz{]zÖ¢n¶Ø^iº/yÊy·¢·¶)Þ²·ªºFÚªê-jwjº@vXvꮢÖÞ~Þ¶ªºH|Ú->ºzËÆ+-²«¨¶Ø^v&«Éì^ªê-N§ªê-jwiºÛazV¬·ibë+z«¨´[§r«¨µ§íz»az«¨´IÝ!ûaÁ'tëzV­yÛhªê-jëh×6;
; AutoIt v3.0
;
AutoItSetOption("WinTitleMatchMode", 2)     ; this allows partial window titles to be valid!



SoundPlay(@ScriptDir & "\WAV-PrPref.wav")
Sleep(750)
;________________________________________________________________________________________________
; Text-to-speech follows; if speech installed and enabled (or WinXP), computer will speak the following text:
$oSp = ObjCreate("SAPI.SpVoice")
$oSp.Speak("Diary, Version, 2 point 2, alert.")
Sleep(1000)
;________________________________________________________________________________________________




If Not ProcessExists("thediary.exe") Then

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=None
If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
Do
$iMsgBoxAnswer = MsgBox(3,"DIARY v2.2 launch ... ?","Would you like to delay launching ''The Diary''?" & @CR & @CR & "- Clicking ''YES'' brings up box to delay the launch of this program." & @CR & "- Clicking ''NO'' opens the file immediately." & @CR & "- Clicking ''CANCEL'' exits this script.")
Select
    Case $iMsgBoxAnswer = 6 ;Yes
         
            $input = InputBox("''DIARY v2.2 ...'' diary program ...", "Snooze for how many minutes?", 15)
            $time = $input*1000*60
            Sleep($time)
         
            #NoTrayIcon     ; AutoIt's icon doesn't show in systray
            SoundPlay(@ScriptDir & "\WAV-PrPref.wav")
         
         
    Case $iMsgBoxAnswer = 7 ;No
         ;=============================================================================
         #NoTrayIcon
         SoundSetWaveVolume(+20)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         ;_________________________________________________________________________________________________
         ; Text-to-speech follows; if speech installed and enabled, computer will speak the following text:
         $oSp = ObjCreate("SAPI.SpVoice")
         $oSp.Speak("Minimizing apps.  Diary, version, 2 point 2, will be launched momentarily.")
         SoundPlay(@ScriptDir & "\WAV-Computer, old-style.wav")
         ;_________________________________________________________________________________________________
         
         Sleep(3500)
         SoundPlay(@ScriptDir & "\WAV-PrExit.wav")
         Sleep(1500)
         ; minimize all windows
         WinMinimizeAll ( )
         
         Sleep(4000)
         $oSp.Speak("Launching.")
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         Sleep(1000)
         
         ; PATH:  M:\diary, The Diary v2.2\APP- The Diary v2.2\BACKUPS (unzip files to DATA fldr)
         Run('C:\Program Files\0- MY APPS\DOpus8\dopus.exe "M:\DIARY_~1.2\APP-TH~1.2\BACKUP~1"')
         ;WinWait("DATA")
         ;WinSetState ("DATA)", "", @SW_MAXIMIZE)
         WinWait("DATA")
         WinSetState ("DATA", "", @SW_MAXIMIZE)
         
         SoundSetWaveVolume(15)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         
         Sleep(200)
         ; PATH: M:\BKP\bkp, My Own Backup v2.1 (XLent!)\APP- MOB v2.1\MOBv2.exe
         ShellExecute("M:\BKP\bkp, My Own Backup v2.1 (XLent!)\APP- MOB v2.1\MOBv2.exe", "", @SW_MAXIMIZE)
         WinWait("Backup")
         WinSetState ("Backup", "", @SW_MAXIMIZE)
         
         SoundPlay(@ScriptDir & "\WAV-Laser 01a.wav")
         Sleep(200)
         ;  Open folder:
         ;  PATH = M:\diary, The Diary v2.2\APP- The Diary v2.2\thediary.exe
         ShellExecute("M:\diary, The Diary v2.2\APP- The Diary v2.2\thediary.exe")
         WinWait("Diary")
         WinSetState ("Diary", "", @SW_MAXIMIZE)
         
         SoundSetWaveVolume(-20)   ;  adjusts the volume up to the percent level in the brackets - i.e., (25) = 25%, (50) = 50%, etc.
         ;=============================================================================

         
         
Case $iMsgBoxAnswer = 2 ;Cancel
        EndSelect
        Until $iMsgBoxAnswer <> 6

    EndIf   ; this EndIf related to:  "If Not ProcessExists(" ... .exe " Then" seen above ...)




Exit
; finished

Thank you! :P

I suspect the problem is that the adlib function won't get called while the script is waiting for the input function to end.

So to solve that I suggest you create a Gui with the relevant buttons instead of using Input. Have a while 1/wend and inside have the usual $msg = GuiGetMsg() type of thing and I think that will solve your problem.

EDIT: I see the AutoIt tags are messing up again. My continual reccommendation is to use code tags instead. I know the Autoit tags give nice colours and so on but they are a frequent cause of frustration IMO.

Edited by martin

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.

Share this post


Link to post
Share on other sites

I suspect the problem is that the adlib function won't get called while the script is waiting for the input function to end.

So to solve that I suggest you create a Gui with the relevant buttons instead of using Input. Have a while 1/wend and inside have the usual $msg = GuiGetMsg() type of thing and I think that will solve your problem.

EDIT: I see the AutoIt tags are messing up again. My continual reccommendation is to use code tags instead. I know the Autoit tags give nice colours and so on but they are a frequent cause of frustration IMO.

Oh. Drat. I'm not that skilled. I guess I'll just have to live with this till I figure out how to do the GUI thing. I have a hard enough time with regular scripts and I didn't understand half of what you're talking about here <lol>. I'll check those terms out, though, in the meantime. Always great to learn new stuff.

Thanks. :P

Share this post


Link to post
Share on other sites

<holding breath> Well, I kept plugging away and just did another, much broader search than before of the forum and I came across something I've never used before so it wasn't something I remembered off the top of my head: Msgbox timeout. I'm cautious on this one, but it does actually seem to be working <crossing fingers>.

I just added a ", 10" to the end of the main and first message box and the box disappeared in 10 seconds! Will just play with the times now to see how long I should let this wait ...

$iMsgBoxAnswer = MsgBox(3,"DIARY v2.2 launch ... ?","Would you like to delay launching ''The Diary''?" & @CR & @CR & "- Clicking ''YES'' brings up box to delay the launch of this program." & @CR & "- Clicking ''NO'' opens the file immediately." & @CR & "- Clicking ''CANCEL'' exits this script.", 10)

I'm a bit flabbergasted by how simple this is. Another extremely great tip to add to my tips folder, let me tell you! I never would have dreamed this problem would have such a simple solution.

So, another great AI solution. I have a very simple scheduler that I've figured out how to get relative paths with so that I can use it my USB flash drive. All the complexity required that I've never found any supposed USB-capable scheduler to have is accomplished with AutoIt where I also figured out relative paths (through extremely kind help in the forum). And now it's become even more efficient with the timeout!

Wow, just can't get much better than this! Thanks. :P

Share this post


Link to post
Share on other sites

<holding breath> Well, I kept plugging away and just did another, much broader search than before of the forum and I came across something I've never used before so it wasn't something I remembered off the top of my head: Msgbox timeout. I'm cautious on this one, but it does actually seem to be working <crossing fingers>.

I just added a ", 10" to the end of the main and first message box and the box disappeared in 10 seconds! Will just play with the times now to see how long I should let this wait ...

$iMsgBoxAnswer = MsgBox(3,"DIARY v2.2 launch ... ?","Would you like to delay launching ''The Diary''?" & @CR & @CR & "- Clicking ''YES'' brings up box to delay the launch of this program." & @CR & "- Clicking ''NO'' opens the file immediately." & @CR & "- Clicking ''CANCEL'' exits this script.", 10)

I'm a bit flabbergasted by how simple this is. Another extremely great tip to add to my tips folder, let me tell you! I never would have dreamed this problem would have such a simple solution.

So, another great AI solution. I have a very simple scheduler that I've figured out how to get relative paths with so that I can use it my USB flash drive. All the complexity required that I've never found any supposed USB-capable scheduler to have is accomplished with AutoIt where I also figured out relative paths (through extremely kind help in the forum). And now it's become even more efficient with the timeout!

Wow, just can't get much better than this! Thanks. :P

Share this post


Link to post
Share on other sites

<holding breath> Well, I kept plugging away and just did another, much broader search than before of the forum and I came across something I've never used before so it wasn't something I remembered off the top of my head: Msgbox timeout. I'm cautious on this one, but it does actually seem to be working <crossing fingers>.

I just added a ", 10" to the end of the main and first message box and the box disappeared in 10 seconds! Will just play with the times now to see how long I should let this wait ...

$iMsgBoxAnswer = MsgBox(3,"DIARY v2.2 launch ... ?","Would you like to delay launching ''The Diary''?" & @CR & @CR & "- Clicking ''YES'' brings up box to delay the launch of this program." & @CR & "- Clicking ''NO'' opens the file immediately." & @CR & "- Clicking ''CANCEL'' exits this script.", 10)

I'm a bit flabbergasted by how simple this is. Another extremely great tip to add to my tips folder, let me tell you! I never would have dreamed this problem would have such a simple solution.

So, another great AI solution. I have a very simple scheduler that I've figured out how to get relative paths with so that I can use it my USB flash drive. All the complexity required that I've never found any supposed USB-capable scheduler to have is accomplished with AutoIt where I also figured out relative paths (through extremely kind help in the forum). And now it's become even more efficient with the timeout!

Wow, just can't get much better than this! Thanks. :P

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0