TrailFox Posted January 12, 2012 Posted January 12, 2012 My Timers and the rest of the execution of my script stops when using MsgBoxes. How can i avoid that? Ty
BrewManNH Posted January 12, 2012 Posted January 12, 2012 Don't use a MsgBox. MsgBox is a blocking function, meaning the script halts until the box is closed. Make your own MsgBox using a GUI instead of the built-in msgbox function. 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
andygo Posted January 13, 2012 Posted January 13, 2012 simple own msgbox: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $action = "" Opt("GUIOnEventMode", 0) $gui_3 = GUICreate("msgbox", 326, 145, -1, -1, $WS_CAPTION) $gui_3text = GUICtrlCreateLabel("text", 10, 50, 306, 20, $SS_CENTER) $gui_3ja = GUICtrlCreateButton("Yes", 75, 90, 50, 20) $gui_3nein = GUICtrlCreateButton("No", 201, 90, 50, 20) GUISetState() while 1 sleep(20) $mMsg = GUIGetMsg(1) Switch $mMsg[0] case $gui_3ja $action = "yes" exitloop case $gui_3nein $action = "no" exitloop EndSwitch wend msgbox(64, "info", "you clicked "&$action)
funkey Posted January 13, 2012 Posted January 13, 2012 Or if you do not need the return value of the MsgBox you could use something like this: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'', 10)"') For $i = 10 To 1 Step -1 ToolTip($i) Sleep(1000) Next Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
wraithdu Posted January 13, 2012 Posted January 13, 2012 I've used CreateThread with MessageBoxIndirect successfully in the past. It doesn't seem to crash autoit like creating threads on internal callback pointers (for example).
wraithdu Posted January 13, 2012 Posted January 13, 2012 Example: Main() Func Main() Local $hThread For $i = 1 To 5 $hThread = _ErrorBox("Here I am: #" & $i) If $hThread Then DllCall("kernel32.dll", "bool", "CloseHandle", "handle", $hThread) Next GUICreate("Wait for it...") GUISetState() Do Until GUIGetMsg() = -3 EndFunc Func _ErrorBox($szMessage) Local $tMSG = "uint cbSize;hwnd hwndOwner;ptr hInstance;ptr lpszText;ptr lpszCaption;dword dwStyle;ptr lpszIcon;dword dwContextHelpId;" & _ "ptr lpfnMsgBoxCallback;dword dwLanguageId" Local $MSG = DllStructCreate($tMSG) DllStructSetData($MSG, "cbSize", DllStructGetSize($MSG)) Local $pText = DllStructCreate("wchar[" & StringLen($szMessage) + 1 & "]") DllStructSetData($pText, 1, $szMessage & ChrW(0)) ; terminating null DllStructSetData($MSG, "lpszText", DllStructGetPtr($pText)) DllStructSetData($MSG, "lpszCaption", 0) DllStructSetData($MSG, "dwStyle", 16) ; MB_OK|MB_ICONERROR Local $hMod = DllCall("kernel32.dll", "handle", "GetModuleHandleW", "wstr", "user32.dll") Local $pMBIW = DllCall("kernel32.dll", "ptr", "GetProcAddress", "handle", $hMod[0], "str", "MessageBoxIndirectW") Local $hThread = DllCall("kernel32.dll", "handle", "CreateThread", "ptr", 0, "dword", 0, "ptr", $pMBIW[0], "ptr", DllStructGetPtr($MSG), "dword", 0, "ptr", 0) If $hThread[0] Then WinWait("Error", $szMessage, 5) ; wait for message box to be displayed Return $hThread[0] EndFunc ;==>_ErrorBox
FaridAgl Posted January 14, 2012 Posted January 14, 2012 (edited) Or if you do not need the return value of the MsgBox you could use something like this: Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'', 10)"') For $i = 10 To 1 Step -1 ToolTip($i) Sleep(1000) Next Wow, interesting. Can i use this to execute a multiline script? Edited January 14, 2012 by D4RKON3 http://faridaghili.ir
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