Jump to content

How to get this script to loop, pls?


Recommended Posts

Thank goodness for the Code Wizard <g>.

I had a script that worked perfectly for delaying scripts but it lacked a cancel button. With the help of the code wizard I was able to add this button in but after numerous attempts, haven't been able to successfully integrate the looping feature to get the script to pull up the initial input box after a snooze. So in other words, the NO and CANCEL buttons work perfectly, but the YES one doesn't work. Fortunately, unhiding the systray icon showed that it just winked out so then I went back to the code and saw that I'd completely missed a sort of looping thing.

What's needed is for the script to go back to the beginning of the "case = 6" part to bring up the snooze question box again. Know that what's difficult for some of us is easy for others ... <g>

;
; AutoIt v3.0
;

;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=None

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(3,"Delay launch ... ?","Would you like to delay launching ''Through Clock'' task scheduler?" & @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("''Through Clock launch ...'' reminder ...", "Snooze for how many minutes?", 15)
        $time = $input*1000*60
        Sleep($time)
        #NoTrayIcon     ; AutoIt's icon doesn't show in systray

    Case $iMsgBoxAnswer = 7 ;No
        ShellExecute(@ScriptDir & "\ThClock.exe")
        WinWait("ThroughClock")
        WinSetState ("ThroughClock", "", @SW_MINIMIZE)

    Case $iMsgBoxAnswer = 2 ;Cancel
        
EndSelect

Exit
; finished

Thank you! :)

Link to comment
Share on other sites

sorry i don't understand very well..

like this?

;
; AutoIt v3.0
;
While 1
;MsgBox features: Title=Yes, Text=Yes, Buttons=Yes, No, and Cancel, Icon=None

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(3,"Delay launch ... ?","Would you like to delay launching ''Through Clock'' task scheduler?" & @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("''Through Clock launch ...'' reminder ...", "Snooze for how many minutes?", 15)
        
        If Not @error Then 
        
        $time = $input*1000*60
        Sleep($time)
        #NoTrayIcon     ; AutoIt's icon doesn't show in systray
    Else
        ContinueLoop
    EndIf
    

    Case $iMsgBoxAnswer = 7 ;No
        ShellExecute(@ScriptDir & "\ThClock.exe")
        WinWait("ThroughClock")
        WinSetState ("ThroughClock", "", @SW_MINIMIZE)

    Case $iMsgBoxAnswer = 2 ;Cancel
       ExitLoop
EndSelect
WEnd
Exit
Link to comment
Share on other sites

Hi,

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(3,"Delay launch ... ?","Would you like to delay launching ''Through Clock'' task scheduler?" & @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
        Do
            $input = InputBox("''Through Clock launch ...'' reminder ...", "Snooze for how many minutes?", 15)
            $time = $input*1000*60
            Sleep($time)
        Until $input = @error
        #NoTrayIcon     ; AutoIt's icon doesn't show in systray
        
    Case $iMsgBoxAnswer = 7 ;No
        ShellExecute(@ScriptDir & "\ThClock.exe")
        WinWait("ThroughClock")
        WinSetState ("ThroughClock", "", @SW_MINIMIZE)

    Case $iMsgBoxAnswer = 2 ;Cancel
       
EndSelect

Exit

Cheers

Link to comment
Share on other sites

Hi,

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
$iMsgBoxAnswer = MsgBox(3,"Delay launch ... ?","Would you like to delay launching ''Through Clock'' task scheduler?" & @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
        Do
            $input = InputBox("''Through Clock launch ...'' reminder ...", "Snooze for how many minutes?", 15)
            $time = $input*1000*60
            Sleep($time)
        Until $input = @error
        #NoTrayIcon     ; AutoIt's icon doesn't show in systray
        
    Case $iMsgBoxAnswer = 7 ;No
        ShellExecute(@ScriptDir & "\ThClock.exe")
        WinWait("ThroughClock")
        WinSetState ("ThroughClock", "", @SW_MINIMIZE)

    Case $iMsgBoxAnswer = 2 ;Cancel
       
EndSelect

Exit

Cheers

Hi, thanks! This is darned close and this is what I managed to achieve myself. What is needed is to bring up the whole snooze question from the beginning box not the actual snooze box. From this snooze box, you see, it isn't possible to just launch the app. I can only snooze it, which is why my own results didn't work for me, either <vbg>.

I have code that does what's needed exactly but that doesn't have a CANCEL button and I didn't get anything to work in trying to add the CANCEL to that code. The CodeWizard provided me with the right code to have all 3 buttons but I haven't successfully intregated the 2 codes. This doesn't loop back to the first box that asks if we want to snooze, open the file or cancel.

Thanks.

Link to comment
Share on other sites

Hi,

If Not IsDeclared("iMsgBoxAnswer") Then Local $iMsgBoxAnswer
Do
$iMsgBoxAnswer = MsgBox(3,"Delay launch ... ?","Would you like to delay launching ''Through Clock'' task scheduler?" & @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("''Through Clock launch ...'' reminder ...", "Snooze for how many minutes?", 15)
            $time = $input*1000*60
            Sleep($time)
        
        #NoTrayIcon     ; AutoIt's icon doesn't show in systray
       
    Case $iMsgBoxAnswer = 7 ;No
        ShellExecute(@ScriptDir & "\ThClock.exe")
        WinWait("ThroughClock")
        WinSetState ("ThroughClock", "", @SW_MINIMIZE)

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

Cheers

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...