Deye Posted March 22, 2015 Posted March 22, 2015 Hi, What conditions do i need to set to an initiated MsgBox command so I can close it when something changes via $WM_COMMAND like for instance when WM_DEVICECHANGE sees a different drive (while MsgBox is still showing) so I can close the MsgBox from there ($WM-Function) with auto answering "no" to it I see there is a command like _GUICtrlButton_Click that may be used for this but I'm guessing I need the MsgBox's win-handle for this to work or can the win-handle be retrieved as soon as the MsgBox is launched What would be the right way to handle this Msgbox TIA for any idea's on this
JohnOne Posted March 23, 2015 Posted March 23, 2015 (edited) Treat a third party message box as you would any other external window. If it's an autoit MsgBox, then that is a blocking function because it's main purpose is for user interaction. Suggest you create custom GUI to emulate MsgBox so a script loop can still be operating. Edited March 23, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Deye Posted March 23, 2015 Author Posted March 23, 2015 Here is an example in code expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ $WM_DEVICECHANGE = 0x0219 $dbt_deviceremovecomplete = "0x00008004" $dbt_devicearrival = "0x00008000" $hGUI = GUICreate("GUI",200,200) $Label1 = GUICtrlCreateLabel("insert a pen drive", 100, 100, 101, 17) $Label2 = GUICtrlCreateLabel("insert a pen drive", 24, 152, 106, 20) GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") AdlibRegister('_AdlibCall') GUIRegisterMsg($WM_DEVICECHANGE, "MyFunc") GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func MyFunc($hWndGUI, $MsgID, $wParam, $lParam) If $wParam == $dbt_devicearrival Or $wParam == $dbt_deviceremovecomplete Then Global $read2 = "1" Global $read1 = "1" EndIf EndFunc Func _AdlibCall() If IsDeclared("read2") Then If $read1 = $read2 Then Global $read1 = "2" Local $confirm = MsgBox(36, "test", "pull out PenDrive and auto close me when device status has changed") EndIf EndIf EndFunc
JohnOne Posted March 23, 2015 Posted March 23, 2015 That's great. My suggestion still stands. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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