Solchael 1 Posted December 21, 2020 Hello everyone, how are you all ? I am new here, so I hope it's the right place to ask. If no, then apologies and if a moderator can move it to the correct section. I am completly new to coding and new to AutoIt. And I am trying to get the result of the Timeout of a MsgBox. IE : If timeout is over then desplay a message Else continue the code : expandcollapse popup$iTimeout = 10 $s_currentday = InputBox ("Tutoriel" , "Which day of the week are we??", "Enter a day" , "" , 200, 130, Default, Default, $iTimeout) If $iTimeout <> 0 then MsgBox ( 16, "Tutoriel", "Too long to answer, programe will close!!") Else Switch $s_currentday Case "Monday" MsgBox ( 0, "Tutoriel", "It's only the start of the week!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "It's the start of an awesome week!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be a better day!") EndIf Case "Tuesday" MsgBox ( 0, "Tutoriel", "Second day of the week!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "Let's make this week and amazing one!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be a better day!") EndIf Case "Wednesday" MsgBox ( 0, "Tutoriel", "Third day of the week!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox == 6 Then MsgBox ( 0, "Tutoriel", "Half of the week and yet more good stuff to come!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be a better day!") EndIf Case "Thursday" MsgBox ( 0, "Tutoriel", "Closer to the weekend!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "We are close to end the week! Keep that positive mind") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be a better day!") EndIf Case "Friday" MsgBox ( 0, "Tutoriel", "Almost weekend!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "It's the start of an awesome weekend! Think of what you are going to do!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be a better day! Maybe you can go out and have a drink with your friends?") EndIf Case "Saturday" MsgBox ( 0, "Tutoriel", "It's the start of the weekend!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "It's the start of an awesome weekend!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow is Sunday, you can rest and have a good day with your friends and/or family!") EndIf Case "Sunday" MsgBox ( 0, "Tutoriel", "We are almost at the end of the week!") $mybox = MsgBox ( 4, "Tutoriel", "Do you feel good?") If $mybox = 6 Then MsgBox ( 0, "Tutoriel", "It's the end of an awesome week! And I am sure that the next one will be even better!") ElseIf $mybox = 7 Then MsgBox ( 0, "Tutoriel", "Don't worry tomorrow will be the start of a new week! So new chance to feel better") EndIf EndSwitch EndIf Sorry for my bad english, not my main language. Thanks in advance, Solchael Share this post Link to post Share on other sites
Solchael 1 Posted December 21, 2020 EDIT : Seems I can't edit my own post. But the code is of course wrong because : "If $iTimeout <> 0" can't be a good condition, I tested with "If $iTimeout = 0" Share this post Link to post Share on other sites
TheXman 405 Posted December 21, 2020 (edited) Your title refers to MsgBox. I assume you meant InputBox. You want to look at the value of @error to see if the dialog was cancelled or timed out. Example: #include <Constants.au3> $sValue = InputBox("Test", "Enter anything you like", "", "", -1, -1, Default, Default, 5) If @error Then Switch @error Case 1 ;Cancelled MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "User cancelled input box") Case 2 ;Timed out MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "Input box timed out") Case Else ;Other error MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Input box failed - @error = " & @error) EndSwitch Exit EndIf MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "You entered:" & @LF & @LF & $sValue) Welcome to the forum! Edited December 21, 2020 by TheXman About TheXman | CryptoNG UDF - Cryptography API: Next Gen | HttpApi UDF - HTTP Server API | jq UDF - Powerful and Flexible JSON Processor Share this post Link to post Share on other sites
water 2,391 Posted December 21, 2020 Welcome to AutoIt and the forum! There is a limit of 5 or 10 posts before you can edit your posts. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2020-10-10 - Version 1.5.2.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX (NEW 2020-12-15 - Version 1.6.3.1) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2020-06-27 - Version 1.3.2.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsPowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & SupportExcel - Example Scripts - WikiWord - WikiTask Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - WikiTutorials:ADO - Wiki, WebDriver - Wiki Share this post Link to post Share on other sites
Solchael 1 Posted December 21, 2020 16 minutes ago, TheXman said: You want to look at the value of @error to see if the dialog was canceled or timed out. Example: #include <Constants.au3> $sValue = InputBox("Test", "Enter anything you like", "", "", -1, -1, Default, Default, 5) If @error Then Switch @error Case 1 MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "User cancelled input box") Case 2 MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "Input box timed out") Case Else MsgBox($MB_ICONERROR + $MB_TOPMOST, "ERROR", "Input box failed - @error = " & @error) EndSwitch Exit EndIf MsgBox($MB_ICONINFORMATION + $MB_TOPMOST, "INFO", "You entered:" & @LF & $sValue) Thank you. I just didn't read properly the Function InputBox .... It's clearly written ... Maybe I need another pair of glasses : Return Value Success: the string that was entered. Failure: "" (empty string) and sets the @error flag to non-zero. @error: 1 = The Cancel button was pushed.2 = The Timeout time was reached. 3 = The InputBox failed to open. This is usually caused by bad arguments. 4 = The InputBox cannot be displayed on any monitor. 5 = Invalid parameters width without height or left without top. 16 minutes ago, water said: Welcome to AutoIt and the forum! There is a limit of 5 or 10 posts before you can edit your posts. Thank you very much for the info. Couldn't find it. Regards, Solchael 1 TheXman reacted to this Share this post Link to post Share on other sites