haripurnanto Posted December 2, 2021 Share Posted December 2, 2021 Dear All, My name's Hari from Indonesia. I want to ask about How to automatically close the OK button in the message box in AutoIt Program ? File attached : Please help and inform us related to problem solving, thank you. Regards, Hari Link to comment Share on other sites More sharing options...
Musashi Posted December 2, 2021 Share Posted December 2, 2021 (edited) 3 hours ago, haripurnanto said: How to automatically close the OK button in the message box in AutoIt Program ? I don't quite understand what you are trying to accomplish. If you want to close a standard message box after e.g. 10 seconds, then use the optional Timeout flag ( which you obviously already do). If you want to close the message box immediately, why should it be displayed at all? EDIT : If you want to display a counter, take a look at the following post : count-down-msgbox Edited December 2, 2021 by Musashi "In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move." Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 2, 2021 Moderators Share Posted December 2, 2021 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...
Nine Posted December 2, 2021 Share Posted December 2, 2021 Only way to close the message box is to launch a second process that will perform a ControlClick on the button. MsgBox is a blocking function, you cannot interact with it within the same script. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
jguinch Posted December 2, 2021 Share Posted December 2, 2021 (edited) 2 hours ago, Nine said: MsgBox is a blocking function, you cannot interact with it within the same script. Not really sure 😉. Using a Timer, it works #include <MsgBoxConstants.au3> #include <Timers.au3> Local $iDuration = 10 Local $iTimerProgress = _Timer_SetTimer(0, 1000, "_CountDown") ; create timer Local $sMsgboxTitle = "My MsgBox" Local $sMsgboxText = "The text of the MsgBox" MsgBox($MB_YESNO, $sMsgboxTitle, $sMsgboxText) Func _CountDown($hWnd, $iMsg, $iIDTimer, $iTime) Local Static $iCountDown = 10 Local Static $hMsgBox = WinGetHandle($sMsgboxTitle, $sMsgboxText) $iCountDown -= 1 ControlSetText($hMsgBox, "", "[CLASS:Button; INSTANCE:2]", "Close in " & $iCountDown & " s") If $iCountDown = 0 Then ControlClick($hMsgBox, "", "[CLASS:Button; INSTANCE:1]") EndFunc Edited December 2, 2021 by jguinch Earthshine and Musashi 2 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
junkew Posted December 3, 2021 Share Posted December 3, 2021 #include <MsgBoxConstants.au3> MsgBox($MB_SYSTEMMODAL, "Title", "This message box will timeout after 10 seconds or select the OK button.", 10) https://www.autoitscript.com/autoit3/docs/functions/MsgBox.htm Earthshine 1 FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Nine Posted December 3, 2021 Share Posted December 3, 2021 16 hours ago, jguinch said: Not really sure nice one “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
haripurnanto Posted December 20, 2021 Author Share Posted December 20, 2021 Dear All, Thank you very much for helping me, you all respect me so much. Regards, Hari 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