taylansan Posted June 9, 2015 Posted June 9, 2015 Dear AutoIt Community,i want my script to pop-up a MsgBox, but at the same time to continue the script.ConsoleWrite("Hello - 1" & @CRLF) MsgBox(0, "", "Hello - 2") ConsoleWrite("Hello - 3" & @CRLF)If I do it as above, the script is paused and waiting for me to close the MsgBox to continue on the third line.I don't want to set a timer to close the MsgBox either, because I will read the contents of the MsgBox but want my script continue to the next lines.I didn't see any kind of restriction on the MsgBox help file that will cause the script to be paused.Can you please tell / show me if this is possible? TY.
Moderators Melba23 Posted June 9, 2015 Moderators Posted June 9, 2015 taylansan,search for "NotifyBox" by Yashied - that is a sort of MsgBox which does not pause the script. Or look at the Notify UDF in my sig - that produces small 2-line dialogs that pop in from the side of the screen.M23 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
MikahS Posted June 9, 2015 Posted June 9, 2015 MsgBox is a blocking GUI that needs interaction before continuing on with the script. It essentially pauses the script waiting for a response.It is not possible to continue in your script, unless you response to the MsgBox prompt. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
ViciousXUSMC Posted June 9, 2015 Posted June 9, 2015 I usually use splashtexton() in those situations.
taylansan Posted June 9, 2015 Author Posted June 9, 2015 8 years in AutoIt, 30 posts, still learning something new.Thanks M23, MikahS, ViciousXUSMC TY.
Herb191 Posted June 9, 2015 Posted June 9, 2015 (edited) I just make a custom message box.#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hMsgBoxGUI = GUICreate("", 248, 168) GUISetBkColor(0xFFFFFF) $SaveButton = GUICtrlCreateButton("Save", 32, 120, 75, 25) $CancelButton = GUICtrlCreateButton("Cancel", 145, 120, 75, 25) $Label1 = GUICtrlCreateLabel("Some text", 24, 64, 114, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) $Label2 = GUICtrlCreateLabel("Save this Search", 9, 16, 223, 36) GUICtrlSetFont(-1, 20, 800, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Edited June 9, 2015 by Herb191 I did not past all the code the first time
ViciousXUSMC Posted June 9, 2015 Posted June 9, 2015 Melba, not sure how often a feature like this is requested but I like your extended message box udf. Would a non blocking parameter be easy enough to add to your udf?
Moderators Melba23 Posted June 9, 2015 Moderators Posted June 9, 2015 Herb191,That dialog blocks just like the API-generated MsgBox and so does not meet the OP's requirement.ViciousXUSMC,Unfortunately adding a "non-blocking parameter" would mean a complete rewrite of the ExtMsgBox UDF - and as there is already my Notify UDF which does not block the script........M23 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
BrewManNH Posted June 9, 2015 Posted June 9, 2015 You can always do it this way.ConsoleWrite("Hello - 1" & @CRLF) Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(4096, '''', ''Hello - 2'')"') ConsoleWrite("Hello - 3" & @CRLF) If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
MikahS Posted June 9, 2015 Posted June 9, 2015 8 years in AutoIt, 30 posts, still learning something new.Thanks M23, MikahS, ViciousXUSMCIt's a constant journey, but no problem. I learned something new as well. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Herb191 Posted June 9, 2015 Posted June 9, 2015 That dialog blocks just like the API-generated MsgBox and so does not meet the OP's requirement.Am a missing something basic here? If he wants to show a message box a still continue on with the script why wouldn’t this work?#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $g_CancelButton ConsoleWrite("Hello - 1" & @CRLF) MakeMsgBox() ConsoleWrite("Hello - 3" & @CRLF) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $g_CancelButton ExitLoop EndSwitch WEnd Func MakeMsgBox() $hMsgBoxGUI = GUICreate("", 248, 168) GUISetBkColor(0xFFFFFF) $SaveButton = GUICtrlCreateButton("Save", 32, 120, 75, 25) $g_CancelButton = GUICtrlCreateButton("Cancel", 145, 120, 75, 25) $Label1 = GUICtrlCreateLabel("Some text", 24, 64, 114, 22) GUICtrlSetFont(-1, 12, 400, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) $Label2 = GUICtrlCreateLabel("Save this Search", 9, 16, 223, 36) GUICtrlSetFont(-1, 20, 800, 0, "Arial") GUICtrlSetColor(-1, 0x3399FF) GUISetState(@SW_SHOW) EndFunc ;==>MakeMsgBox
Moderators Melba23 Posted June 9, 2015 Moderators Posted June 9, 2015 Herb191,Unlike the code in your first post that will indeed meet the OP's requirement. However, as it stands it is limited to a single dialog at a time, which may or may not be a problem.M23 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
MikahS Posted June 9, 2015 Posted June 9, 2015 Something that might help others understand how MsgBox works in various ways: Modal MsgBox Styles - AutoIt Wiki Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
mikell Posted June 9, 2015 Posted June 9, 2015 Using BrewManNH's way :#pragma compile(AutoItExecuteAllowed, True) Opt("GuiOnEventMode", 1) Global $stop = 0 GUICreate("My GUI", 250, 100) $label = GUICtrlCreateLabel("", 20, 30, 50, 20) $btn = GUICtrlCreateButton("stop", 10, 60, 50, 20) GUICtrlSetOnEvent(-1, "_stop") GUISetState() For $i = 1 to 100 If $i = 10 Then Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, '''', ''$i was 10'')"') If $stop Then Exitloop GuiCtrlSetData($label, $i) Sleep(300) Next Func _stop() $stop = 1 EndFuncBut this doesn't allow the use of variables from the main script in the MsgBox
Moderators Melba23 Posted June 9, 2015 Moderators Posted June 9, 2015 mikell,But this doesn't allow the use of variables from the main script in the MsgBoxYes it does:#pragma compile(AutoItExecuteAllowed, True) Opt("GuiOnEventMode", 1) Global $stop = 0, $sText = "Hi There" GUICreate("My GUI", 250, 100) $label = GUICtrlCreateLabel("", 20, 30, 50, 20) $btn = GUICtrlCreateButton("stop", 10, 60, 50, 20) GUICtrlSetOnEvent(-1, "_stop") GUISetState() For $i = 1 to 100 If $i = 10 Then Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ""' & $sText & '"", ''$i was 10'')"') If $stop Then Exitloop GuiCtrlSetData($label, $i) Sleep(300) Next Func _stop() $stop = 1 EndFuncYou just need to get the quotes right - and, yes, it took me several goes!M23 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
LarsJ Posted June 10, 2015 Posted June 10, 2015 If you want to get an answer back from your MsgBox:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #pragma compile(AutoItExecuteAllowed, True) Opt( "GuiOnEventMode", 1 ) Global $iStop = 0, $lbl2, $lbl3 Local $hGui = GUICreate( "My GUI", 250, 100 ) GUISetOnEvent( $GUI_EVENT_CLOSE, "Stop" ) GUIRegisterMsg( $WM_USER, "WM_MSGBOX" ) GUICtrlCreateLabel( "Loop: ", 10, 10, 30, 20 ) Local $lbl1 = GUICtrlCreateLabel( "", 50, 10, 30, 20 ) GUICtrlCreateLabel( "MsgBox: ", 110, 10, 50, 20 ) $lbl2 = GUICtrlCreateLabel( "", 170, 10, 30, 20 ) GUICtrlCreateLabel( "Answer: ", 110, 40, 50, 20 ) $lbl3 = GUICtrlCreateLabel( "", 170, 40, 30, 20 ) Local $btn = GUICtrlCreateButton( "Stop", 10, 60, 50, 20 ) GUICtrlSetOnEvent( -1, "Stop" ) Local $sText = "Hi There" GUISetState() For $i = 1 to 100 If $i = 10 Then Run( @AutoItExe & ' /AutoIt3ExecuteLine "DllCall(''user32.dll'', ''lresult'', ''SendMessageW'', ''hwnd'', ""' & $hGui & '"", ''uint'', ""' & $WM_USER & '"", ''wparam'', ""' & $i & '"", ''lparam'', MsgBox( ""' & $MB_OKCANCEL & '"", ""' & $sText & '"", ''I was '' & ""' & $i & '"" ))"' ) If $i = 15 Then Run( @AutoItExe & ' /AutoIt3ExecuteLine "DllCall(''user32.dll'', ''lresult'', ''SendMessageW'', ''hwnd'', ""' & $hGui & '"", ''uint'', ""' & $WM_USER & '"", ''wparam'', ""' & $i & '"", ''lparam'', MsgBox( ""' & $MB_YESNOCANCEL & '"", ""' & $sText & '"", ''I was '' & ""' & $i & '"" ))"' ) If $i = 20 Then Run( @AutoItExe & ' /AutoIt3ExecuteLine "DllCall(''user32.dll'', ''lresult'', ''SendMessageW'', ''hwnd'', ""' & $hGui & '"", ''uint'', ""' & $WM_USER & '"", ''wparam'', ""' & $i & '"", ''lparam'', MsgBox( ""' & $MB_RETRYCANCEL & '"", ""' & $sText & '"", ''I was '' & ""' & $i & '"" ))"' ) If $iStop Then Exitloop GuiCtrlSetData( $lbl1, $i ) Sleep(300) Next Func Stop() $iStop = 1 EndFunc Func WM_MSGBOX( $hWnd, $iMsg, $wParam, $lParam ) Switch $wParam Case 10, 15, 20 GuiCtrlSetData( $lbl2, Int( $wParam ) ) GuiCtrlSetData( $lbl3, Int( $lParam ) ) EndSwitch EndFunc Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions
Gianni Posted June 10, 2015 Posted June 10, 2015 (edited) one more waythis can spawn an external independant MsgBox detached from the main script, but from the main script you can still check what has been pressed on the external MsgBox. This mode can also be used for InputBox as wellLocal $pid = SpawnMsgBox(1, "Extern MsgBox", "I am detached from the main script") ; Spawn an independant msgbox Local $msg = "Hi" & @CRLF & " hit OK to check external MsgBox status" While 1 MsgBox(0, "internal MsgBox", $msg) Switch CheckExternal($pid) Case 1 ; OK Button Pressed MsgBox(0, "Result", "OK button was pressed on external MsgBox") Exit Case 2 ; Cancel Button Pressed MsgBox(0, "Result", "Cancel button was pressed on external MsgBox") Exit Case -1 ; MsgBox(0, "Result", "External MsgBox closed for timeout") Exit EndSwitch $msg = "At " & @HOUR & ":" & @MIN & ":" & @SEC & " external MsgBox was still there" WEnd ; this receives result from the external MsgBox Func CheckExternal($pid) Return StdoutRead($pid) EndFunc ;==>CheckExternal ; This spawn an MsgBox and returns the related PID Func SpawnMsgBox($iflag = 0, $sTitle = "", $sText = "", $iTimeout = 0) Return Run(@AutoItExe & ' /AutoIt3ExecuteLine "ConsoleWrite(MsgBox(' & $iflag & ', ''' & $sTitle & ''', ''' & $sText & ''', ' & $iTimeout & '))"', "", "", 0x2) ; 0x2 ($STDOUT_CHILD) EndFunc ;==>SpawnMsgBox Edited June 10, 2015 by Chimp pixelsearch 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
pixelsearch Posted October 20, 2022 Posted October 20, 2022 Hi everybody I'm aware Gianni's last post just above was written 7 years ago, but there's something important to add to his script. First of all, the script is great because it returns (simply) what has been pressed by the user on the external MsgBox, which is a crucial information when more than 1 button can be pressed in this external MsgBox. The script runs fine when it's not compiled, but it doesn't work when compiled... unless we add the following line at the beginning of the script : #pragma compile(AutoItExecuteAllowed, True) I just found this line in one of Nine's script and it's also in AutoIt help file, at the very end of the topic Running Scripts (chapter "Important notes") Gianni 1 "I think you are searching a bug where there is no bug... don't listen to bad advice."
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