James Posted August 31, 2009 Share Posted August 31, 2009 (edited) I found this function today and thought that a lot of people would probably find it useful! Basically with this function you'll be able to create a message box looking like this: The return values are the same as any other message box: Button PressedReturn Value OK 1CANCEL 2ABORT 3RETRY 4IGNORE 5YES 6NO 7TRY AGAIN **10CONTINUE **11 If the user presses the "In the future, do not show me this dialog box" checkbox, that message will never appear again - not even if you call it. It's all based on the RegVal: A pointer to a null-terminated string that contains a unique stringvalue to associate with this message. To avoid collisions with valuesused by Microsoft, this string should include a GUID. This string mustnot exceed REGSTR_MAX_VALUE_LENGTH characters in length, including theterminating null character. So the code: $hMsg = MsgBoxC(4, "Warning", "AutoIt just did something useful!", "{d9108ba3-9a61-4398-bfbc-b02102c77e8c}") MsgBox(0, "Return Value:", "$hMsg returned: " & $hMsg) Func MsgBoxC($dwType, $lpszTitle, $lpszText, $lpszId) $Ret = DllCall("shlwapi.dll", "long", "SHMessageBoxCheck", "long", ControlGetHandle("Program Manager", "", "SysListView32"), "string", $lpszText, _ "string", $lpszTitle, "long", $dwType, "long", 0, "string", $lpszId) Return $Ret[0] EndFunc Have fun! Edited August 31, 2009 by JamesBrooks Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
MrCreatoR Posted August 31, 2009 Share Posted August 31, 2009 Not supported in Win XP? I get this error: Subscript used with non-Array variable.: Return $Ret[0] Return $Ret^ ERROR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
shadowhacker Posted August 31, 2009 Share Posted August 31, 2009 Nice one man, i will defanately use this kind of msgbox. But one thing, are the button and flag codes the same like the normal msgbox codes ? Link to comment Share on other sites More sharing options...
James Posted August 31, 2009 Author Share Posted August 31, 2009 Not supported in Win XP? I get this error: Subscript used with non-Array variable.: Return $Ret[0] Return $Ret^ ERROR MSDN says the minimum operating systems are; Windows 2000, Windows 2000 Server, Windows Server 2003, Windows XP. Remove the array [0] then, I never noticed anything different about using it or not. Nice one man, i will defanately use this kind of msgbox. But one thing, are the button and flag codes the same like the normal msgbox codes ? Thanks shadowhacker! Yes flags and return codes are just the same. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
trancexx Posted August 31, 2009 Share Posted August 31, 2009 Not supported in Win XP? I get this error: Subscript used with non-Array variable.: Return $Ret[0] Return $Ret^ ERROR Read this. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
James Posted August 31, 2009 Author Share Posted August 31, 2009 Read this.Beat me to it, and your code has error handling. Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
MrCreatoR Posted August 31, 2009 Share Posted August 31, 2009 Remove the array [0] then, I never noticed anything different about using it or not.But the function still not called Read this.Thanks, that solves the issue. Althought it's not supporting all the flags that msgbox does (262144 for example, it's «MsgBox has top-most attribute set»). P.S But anyway, i personally prefer to use custom MsgBox (GUI), where i can retrieve value base on selected (or not) checkbox, registry usage is not so convinient for those purposes. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
Yashied Posted August 31, 2009 Share Posted August 31, 2009 But anyway, i personally prefer to use custom MsgBox (GUI), where i can retrieve value base on selected (or not) checkbox, registry usage is not so convinient for those purposes.I too, but anyway it`s a good addition. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
MrCreatoR Posted August 31, 2009 Share Posted August 31, 2009 I too, but anyway it`s a good addition.Yes yes, i agree, it's very nice adition for simple tasks. Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
reb Posted August 31, 2009 Share Posted August 31, 2009 Thanks it works great! Question? Can you get it back by reg edit. I have never used it before and I am very nervous about doing anything to it. Yes I did check the box and it does not work any more. REB MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
MrCreatoR Posted August 31, 2009 Share Posted August 31, 2009 Here is how we can use it better: $sIdentifier = "{D9108BA3-9A61-4398-BFBC-B02102C77E8C}" ;Just to allow the example to run every time If _MessageBoxCheck_GetIDAnswer($sIdentifier) = "no" Then _MessageBoxCheck_RemoveIDAnswer($sIdentifier) $iRet = _MessageBoxCheck(36, "Title", "Text", $sIdentifier) ConsoleWrite("@error: " & @error & @CRLF & "@extended: " & @extended & @CRLF & "$iRet: " & $iRet & @CRLF) Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault=0, $hWnd=0, $iTimeout = 0) Local $a_iCall = DllCall("shlwapi.dll", "int", 191, _; "SHMessageBoxCheckW" exported by ordinal prior Vista "hwnd", $hWnd, _ "wstr", $sText, _ "wstr", $sTitle, _ "dword", $iFlag, _ "int", $iDefault, _ "wstr", $sIdentifier) If @error Or $a_iCall[0] = -1 Then Return SetError(1, 0, MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd)) Return SetError(0, Number(_MessageBoxCheck_GetIDAnswer($sIdentifier) = "no"), $a_iCall[0]) EndFunc Func _MessageBoxCheck_GetIDAnswer($sIdentifier) Return RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndFunc Func _MessageBoxCheck_RemoveIDAnswer($sIdentifier) Return RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndFunc So now the @extended will be set to 1 if the checkbox is checked. Or, another version, to return additional flag of 32 in return value for checkbox state: $sIdentifier = "{D9108BA3-9A61-4398-BFBC-B02102C77E8C}" $iShowMsg = 1 $iRet = _MessageBoxCheck(36, "Test 1", "Text", $sIdentifier) ConsoleWrite("@error: " & @error & @CRLF & "$iRet: " & $iRet & @CRLF) $iShowMsg = (Not BitAND($iRet, 32)) ;If the checkbox checked, this dialog will not be shown If $iShowMsg Then _MessageBoxCheck(36, "Test 2", "Text", $sIdentifier) Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault=0, $hWnd=0, $iTimeout = 0) Local $a_iCall = DllCall("shlwapi.dll", "int", 191, _; "SHMessageBoxCheckW" exported by ordinal prior Vista "hwnd", $hWnd, _ "wstr", $sText, _ "wstr", $sTitle, _ "dword", $iFlag, _ "int", $iDefault, _ "wstr", $sIdentifier) If @error Or $a_iCall[0] = -1 Then Return SetError(1, 0, MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd)) If RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) = "no" Then $a_iCall[0] = BitOR($a_iCall[0], 32) ;32 is the checked checkbox indicator ;Remove the registry entries RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
reb Posted August 31, 2009 Share Posted August 31, 2009 Here is how we can use it better: $sIdentifier = "{D9108BA3-9A61-4398-BFBC-B02102C77E8C}" ;Just to allow the example to run every time If _MessageBoxCheck_GetIDAnswer($sIdentifier) = "no" Then _MessageBoxCheck_RemoveIDAnswer($sIdentifier) $iRet = _MessageBoxCheck(36, "Title", "Text", $sIdentifier) ConsoleWrite("@error: " & @error & @CRLF & "@extended: " & @extended & @CRLF & "$iRet: " & $iRet & @CRLF) Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault=0, $hWnd=0, $iTimeout = 0) Local $a_iCall = DllCall("shlwapi.dll", "int", 191, _; "SHMessageBoxCheckW" exported by ordinal prior Vista "hwnd", $hWnd, _ "wstr", $sText, _ "wstr", $sTitle, _ "dword", $iFlag, _ "int", $iDefault, _ "wstr", $sIdentifier) If @error Or $a_iCall[0] = -1 Then Return SetError(1, 0, MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd)) Return SetError(0, Number(_MessageBoxCheck_GetIDAnswer($sIdentifier) = "no"), $a_iCall[0]) EndFunc Func _MessageBoxCheck_GetIDAnswer($sIdentifier) Return RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndFunc Func _MessageBoxCheck_RemoveIDAnswer($sIdentifier) Return RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndFunc So now the @extended will be set to 1 if the checkbox is checked. Or, another version, to return additional flag of 32 in return value for checkbox state: $sIdentifier = "{D9108BA3-9A61-4398-BFBC-B02102C77E8C}" $iShowMsg = 1 $iRet = _MessageBoxCheck(36, "Test 1", "Text", $sIdentifier) ConsoleWrite("@error: " & @error & @CRLF & "$iRet: " & $iRet & @CRLF) $iShowMsg = (Not BitAND($iRet, 32)) ;If the checkbox checked, this dialog will not be shown If $iShowMsg Then _MessageBoxCheck(36, "Test 2", "Text", $sIdentifier) Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault=0, $hWnd=0, $iTimeout = 0) Local $a_iCall = DllCall("shlwapi.dll", "int", 191, _; "SHMessageBoxCheckW" exported by ordinal prior Vista "hwnd", $hWnd, _ "wstr", $sText, _ "wstr", $sTitle, _ "dword", $iFlag, _ "int", $iDefault, _ "wstr", $sIdentifier) If @error Or $a_iCall[0] = -1 Then Return SetError(1, 0, MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd)) If RegRead("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) = "no" Then $a_iCall[0] = BitOR($a_iCall[0], 32) ;32 is the checked checkbox indicator ;Remove the registry entries RegDelete("HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", $sIdentifier) EndIf Return SetError(0, 0, $a_iCall[0]) EndFunc Thanks MRCreatoR The examples work and will be a source of study for me. REB MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
James Posted August 31, 2009 Author Share Posted August 31, 2009 Ahh good idea MrCreator! I didn't think of doing that Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
corgano Posted September 1, 2009 Share Posted September 1, 2009 This will be really useful to someone out there some day..... just not me or right now. Good job 0x616e2069646561206973206c696b652061206d616e20776974686f7574206120626f64792c20746f206669676874206f6e6520697320746f206e657665722077696e2e2e2e2e Link to comment Share on other sites More sharing options...
Tacomas Posted August 19, 2013 Share Posted August 19, 2013 This will be really useful to someone out there some day..... just not me or right now. Good job It definitely is! Thanks a lot, MrCreatoR. Link to comment Share on other sites More sharing options...
James Posted August 19, 2013 Author Share Posted August 19, 2013 It definitely is! Thanks a lot, MrCreatoR. Thanks for using the function, but way to go reviving a 4 year old topic... Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ 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