perfaram Posted April 19, 2014 Share Posted April 19, 2014 (edited) Hi ! Here's a short code that creates a MsgBox with a "don't show this message anymore" checkbox. Also provided, a function to clear this setting. Moreover, at the end of the script you'll find a GUID generator : you will have to use a different one for each of yours msgboxes, otherwise the "don't show..." will apply everywhere (and none of your boxes will show !) In the following code, uncomment the eighth line (;_RestoreDefaultSettings()) to clear the settings. expandcollapse popup$hGui=GUICreate("GUI principale", 300, 300) GUISetState() Local $sIdentifier = "{315Ef1E9-1078-4E74-8AB4-171BE0D793E71}" Local $iDefault = 1 ;_RestoreDefaultSettings() $msgNr=_MessageBoxCheck(33, 'TITRE', 'Bonjour,'&@CRLF&'Qui es-tu, toi qui joue avec le registre ?', $sIdentifier, $iDefault, $hGui) ConsoleWrite('MsgBox returned : '&$msgNr) ; #FUNCTION# ================================================================================================= ; Name...........: _MessageBoxCheck ; Description ...: Creates a MessageBox with a "Do not show me this message again" checkbox. ; Syntax.........: _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault, $hWnd, $iTimeout = 0) ; Parameters....: $iFlag - MsgBox flag ; $sTitle - MsgBox title ; $sText - MsgBox text ; $sIdentifier - Unique GUID, that identifies the MsgBox in the registry (for the "Do not show..." setting) ; $iDefault - Default button ; $hWnd - MsgBox's parent ; $iTimeout - Timeout value ; Return values .: Success - The index of the button ; Author ........: Perceval FARAMAZ (perfaram) ; Remarks .......: This function will create an classic MsgBox in case the MessageBoxCheckW interface is not available ; ================================================================================================= Func _MessageBoxCheck($iFlag, $sTitle, $sText, $sIdentifier, $iDefault, $hWnd, $iTimeout = 0) Local $msgN_Call = DllCall("shlwapi.dll", "int", "SHMessageBoxCheckW", _ "hwnd", $hWnd, "wstr", $sText, "wstr", $sTitle, _ "dword", $iFlag, "int", $iDefault, "wstr", $sIdentifier) If @error Or $msgN_Call[0] = -1 Then $iRet=MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd) Return SetError(1, 0, $iRet) ;fallback EndIf Return $msgN_Call[0] EndFunc ; #FUNCTION# ================================================================================================= ; Name...........: _RestoreDefaultSettings ; Description ...: Clear user's setting for "Do not show me this message again" checkbox. ; Author ........: Perceval FARAMAZ (perfaram) ; Remarks .......: You must change the GUID (in the registry path below), to match the one you used to call the MsgBoxCheck ; ================================================================================================= Func _RestoreDefaultSettings() RegDelete("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain", "{315Ef1E9-1078-4E74-8AB4-171BE0D793E71}") EndFunc ;taken from : http://www.autoitscript.com/forum/topic/134387-version-4-uuid-generator/ Func uuid() Return StringFormat('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', _ Random(0, 0xffff), Random(0, 0xffff), _ Random(0, 0xffff), _ BitOR(Random(0, 0x0fff), 0x4000), _ BitOR(Random(0, 0x3fff), 0x8000), _ Random(0, 0xffff), Random(0, 0xffff), Random(0, 0xffff) _ ) EndFunc That's all, folks ! Edited April 19, 2014 by perfaram Mat 1 Never forget to mark a question as resolved, this button has been purposely created :-P Link to comment Share on other sites More sharing options...
Kilmatead Posted April 19, 2014 Share Posted April 19, 2014 (edited) Nice! As a less-invasive rewrite of the above (will not any leave permanent registry entries), where the script itself is subsequently responsible for showing or hiding the msgbox (storing the response in an INI file or whatever) consider: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPIDlg.au3> Local $msgNr = _WinAPI_ShellMessageBoxCheck($MB_OK + $MB_ICONINFORMATION, "SHMessageBoxCheckW Test", "Ne pas perdre sa vie à la gagner") MsgBox(0, "", "Msgbox = " & $msgNr & @LF & "CheckState = " & ((@extended = $GUI_CHECKED) ? "$GUI_CHECKED" : "$GUI_UNCHECKED")) Func _WinAPI_ShellMessageBoxCheck($iFlag, $sTitle, $sText, $iTimeout = 0, $hWnd = Null) Local Const $ShowMeNot = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\DontShowMeThisDialogAgain" Local Const $sID = "_WinAPI_ShellMessageBoxCheck" Local $bCheckbox = $GUI_UNCHECKED Local $msgN_Call = _WinAPI_MessageBoxCheck($iFlag, $sTitle, $sText, $sID, 0, $hWnd) If @error Or $msgN_Call = -1 Then $iRet = MsgBox($iFlag, $sTitle, $sText, $iTimeout, $hWnd) Return SetError(1, $bCheckbox, $iRet) EndIf If RegDelete($ShowMeNot, $sID) Then $bCheckbox = $GUI_CHECKED Return SetExtended($bCheckbox, $msgN_Call) EndFunc It just returns @Extended as $GUI_CHECKED or $GUI_UNCHECKED for quick reference. Like I said, this could just be stored in an INI/Array so there's no need for persistent registry spam, GUID's, or anything like that (making it easier for a user to "reset" individual message-states in the future). That being said, if someone did prefer the original method where the system itself suppresses the msgbox call, I suggest using _WinAPI_CreateGUID to generate a true GUID, as randomising can never be considered "unique". Just a thought. Edited April 20, 2014 by Kilmatead Link to comment Share on other sites More sharing options...
guinness Posted April 20, 2014 Share Posted April 20, 2014 This function is already in the AutoIt UDFs I thought? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Kilmatead Posted April 20, 2014 Share Posted April 20, 2014 It is, but in the same way as you'll never learn anything about Mont Saint-Michel from Google Street View (except how not to do it), no one ever learned anything from a generically codified dllcall/@error trap, which is all the WinAPIDlg header gives you. We're here to play, after all. Link to comment Share on other sites More sharing options...
perfaram Posted April 20, 2014 Author Share Posted April 20, 2014 @Kilmatead : THIS is totally true ! Moreover, my function has a fallback in case the MessageBoxCheckW interface is not available Never forget to mark a question as resolved, this button has been purposely created :-P Link to comment Share on other sites More sharing options...
guinness Posted April 20, 2014 Share Posted April 20, 2014 Alright, just saying. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
FireFox Posted April 20, 2014 Share Posted April 20, 2014 (edited) It is, but in the same way as you'll never learn anything about Mont Saint-Michel from Google Street View (except how not to do it), no one ever learned anything from a generically codified dllcall/@error trap, which is all the WinAPIDlg header gives you. We're here to play, after all.It is for you but not for others, so I don't see the point to post an existing function. Edit : And FYI, this is the right way to generate a GUID :#include <WinAPICom.au3> ConsoleWrite(_WinAPI_CreateGUID() & @Lf)But I guess you wanted to do it yourself too _Br, FireFox. Edited April 20, 2014 by FireFox Link to comment Share on other sites More sharing options...
perfaram Posted April 21, 2014 Author Share Posted April 21, 2014 @FireFox : Well... no, I didn't know... BTW, the GUID generator I used isn't mine, it comes from here : '?do=embed' frameborder='0' data-embedContent>> Never forget to mark a question as resolved, this button has been purposely created :-P Link to comment Share on other sites More sharing options...
FireFox Posted April 21, 2014 Share Posted April 21, 2014 No problem 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