Jump to content

MsgBox parameter checker?


Recommended Posts

Before I try to reinvent the wheel, let me ask if anyone else has worked on this problem:

Has anyone written a MsgBox parameter checker? Recently a script of mine stopped working correctly, and it took me an hour before I figured out that I had omitted a digit from the first parameter of a MsgBox statement. Because the number was an "impossible" one, the script simply returned from the function that contained the message box, without actually performing the function.

So, is there a script out there that will test all MsgBoxes in a script and warn if any of them are invalid?

Thanks for any information or suggestions.

Edited by emendelson
Link to comment
Share on other sites

  • Replies 43
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I dont think so. The script would need to be run separately from the source script too. What was the "impossible" value?

Link to comment
Share on other sites

I had this happen the other day where I wrote MsgBox(4095, ... instead of 4096 but was quick to spot the mistake.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Link to comment
Share on other sites

If I was going to do it that's how I could go about it or using _StringBetween for ease and then BitAND to check for valid flags,

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

then BitAND to check for valid flags,

Thats what I'm trying to do right now but I'm getting stuck. My heads going to pop. :) Do you have that part?
Link to comment
Share on other sites

I'll have a try tomorrow if I can remember.

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I'll have a try tomorrow if I can remember.

No big deal. Its my own personal annoyance. Id much rather you spend your time fixing/improving AutoIt. (You've been awesome at doing that.)
Link to comment
Share on other sites

This works for me:

Global Const $variable = BitOR(1,2,3,4,5,6,16,32,48,64,256,512,4096,8192,262144,524288)

ConsoleWrite(BitAND($variable, 0) & @CRLF)
ConsoleWrite(BitAND($variable, 1) & @CRLF)
ConsoleWrite(BitAND($variable, 2) & @CRLF)
ConsoleWrite(BitAND($variable, 3) & @CRLF)
ConsoleWrite(BitAND($variable, 4) & @CRLF)
ConsoleWrite(BitAND($variable, 5) & @CRLF)
ConsoleWrite(BitAND($variable, 6) & @CRLF)
ConsoleWrite(BitAND($variable, 16) & @CRLF)
ConsoleWrite(BitAND($variable, 32) & @CRLF)
ConsoleWrite(BitAND($variable, 48) & @CRLF)
ConsoleWrite(BitAND($variable, 64) & @CRLF)
ConsoleWrite(BitAND($variable, 256) & @CRLF)
ConsoleWrite(BitAND($variable, 512) & @CRLF)
ConsoleWrite(BitAND($variable, 4096) & @CRLF)
ConsoleWrite(BitAND($variable, 8192) & @CRLF)
ConsoleWrite(BitAND($variable, 262144) & @CRLF)
ConsoleWrite(BitAND($variable, 524288) & @CRLF & @CRLF)
ConsoleWrite(BitAND($variable, 12) & @CRLF & @CRLF) ; test

No, nevermind, I did a more thorough test. It fails badly.

OK, I think that MsgBox doesn't use a bitmask. I think bitmasks have to be made up of powers of two.

Edited by LaCastiglione
Link to comment
Share on other sites

Think I got it

For $i = 1 To 10000
     If _VerifyMsgBoxFlag($i) Then
          ConsoleWrite($i & ': Valid' & @LF)
     Else
          ConsoleWrite('-' & $i & ': Invalid' & @LF)
     EndIf
Next

Func _VerifyMsgBoxFlag($iFlag)

     Static Local $aValid = StringSplit('1,2,3,4,5,6,16,32,48,64,256,512,4096,8192,262144,524288', ',')
     Local $iBackup = $iFlag

     ;For each valid flag, subtract it from the original flag
     ;if its a combination of valid flags the end value should be 0
     For $i = 1 To $aValid[0]
          If BitAND($iFlag, $aValid[$i]) Then $iFlag -= $aValid[$i]
     Next

     If Not $iFlag Then
          ;but heres an exception, your flag includes 1+2+4. These are all valid flags, but conflict with each other
          If BitAND(1, $iBackup) And BitAND(2, $iBackup) And BitAND(4, $iBackup) Then Return False
          ;otherwise its ok
          Return True
     Else
          ;Flag is positive so its invalid
          Return False
     EndIf

EndFunc   ;==>_VerifyMsgBoxFlag
Edited by Beege
Link to comment
Share on other sites

I was about to start and saw you had posted a solution, nice. You love using Static I've noticed. :)

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

This is what I was working on, but instead I opted for Beege's method. This will check all the MsgBox's in a Script and report back which ones one valid and not. This can be improved upon but it gives you an idea.

#AutoIt3Wrapper_Outfile=MsgBoxCheck.exe
#include <Array.au3>

_Main()

Func _Main()
    If $CmdLine[0] Then
        Local $aArray = _CheckMsgBox($CmdLine[1])
        Exit _ArrayDisplay($aArray)
    EndIf
EndFunc   ;==>_Main

; #FUNCTION# ====================================================================================================================
; Name ..........: _CheckMsgBox
; Description ...: Check a MsgBox's flags are correct.
; Syntax ........: _CheckMsgBox($sFilePath)
; Parameters ....: $sFilePath - A valid filepath of an AutoIt script file.
; Return values .: Success: Array of MsgBox flags and whether they are valid or not.
;                  Failure: Sets @error to non-zero and an array with the count set as 1 and the 1st element set with the filepath passed to the _CheckMsgBox.
; Author ........: guinness and Beege.
; Example .......: Yes
; ===============================================================================================================================
Func _CheckMsgBox($sFilePath)
    Local $aError[1] = [1, $sFilePath], $aValid[17] = [16, 1, 2, 3, 4, 5, 6, 16, 32, 48, 64, 256, 512, 4096, 8192, 262144, 524288], $iBackup
    Local $hFileOpen = FileOpen($sFilePath, 0)
    If $hFileOpen = -1 Then
        Return SetError(1, 0, $aError)
    EndIf
    Local $sData = FileRead($hFileOpen)
    FileClose($hFileOpen)

    Local $aReturn = StringRegExp('MsgBox(0, "_CheckMsgBox", "_CheckMsgBox")' & @CRLF & $sData, '(?s)(?i)MsgBox((.*?),', 3)
    If @error Then
        Return SetError(2, 0, $aError)
    EndIf
    $aReturn[0] = UBound($aReturn, 1) - 1

    For $i = 1 To $aReturn[0]
        $aReturn[$i] = Number($aReturn[$i])
        $iBackup = $aReturn[$i]
        For $j = 1 To $aValid[0]
            If BitAND($aReturn[$i], $aValid[$j]) Then
                $aReturn[$i] -= $aValid[$j]
            EndIf
        Next

        If Not $aReturn[$i] Then
            If BitAND(1, $iBackup) And BitAND(2, $iBackup) And BitAND(4, $iBackup) Then
                $aReturn[$i] = "MsgBox(" & $iBackup & " >> InValid"
            Else
                $aReturn[$i] = "MsgBox(" & $iBackup & " >> Valid"
            EndIf
        Else
            $aReturn[$i] = "MsgBox(" & $iBackup & " >> InValid"
        EndIf
    Next
    Return $aReturn
EndFunc   ;==>_CheckMsgBox
Edited by guinness

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Think I got it

For $i = 1 To 10000
     If _VerifyMsgBoxFlag($i) Then
          ConsoleWrite($i & ': Valid' & @LF)
     Else
          ConsoleWrite('-' & $i & ': Invalid' & @LF)
     EndIf
Next

Func _VerifyMsgBoxFlag($iFlag)

     Static Local $aValid = StringSplit('1,2,3,4,5,6,16,32,48,64,256,512,4096,8192,262144,524288', ',')
     Local $iBackup = $iFlag

     ;For each valid flag, subtract it from the original flag
     ;if its a combination of valid flags the end value should be 0
     For $i = 1 To $aValid[0]
          If BitAND($iFlag, $aValid[$i]) Then $iFlag -= $aValid[$i]
     Next

     If Not $iFlag Then
          ;but heres an exception, your flag includes 1+2+4. These are all valid flags, but conflict with each other
          If BitAND(1, $iBackup) And BitAND(2, $iBackup) And BitAND(4, $iBackup) Then Return False
          ;otherwise its ok
          Return True
     Else
          ;Flag is positive so its invalid
          Return False
     EndIf

EndFunc   ;==>_VerifyMsgBoxFlag

Isn't 10 a valid flag?

Edit: No, it isn't. Help file says any combination of values. What gives?

I see now. Nvm.

Edited by LaCastiglione
Link to comment
Share on other sites

Edit: No, it isn't. Help file says any combination of values. What gives?

How did you come up with 10?

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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I was adding 6 and 4. I took it literally when the help says the parameter could be any combination of values. :)

Edited by LaCastiglione
Link to comment
Share on other sites

I was about to start and saw you had posted a solution, nice.

Thanks! It was killing me.

You love using Static I've noticed. :)

Hahaha. You caught that huh ;)
Link to comment
Share on other sites

Hello again - this is the OP finally getting back to this thread. I unexpectedly had to go away from a day, and didn't see this thread again until now. So here's a belated but heartfelt THANK YOU for this script, which is going to save a lot of trouble for anyone who mistypes a number.

Is there any hope this can be incorporated somehow into SciTE??

Link to comment
Share on other sites

This is what I was working on, but instead I opted for Beege's method. This will check all the MsgBox's in a Script and report back which ones one valid and not. This can be improved upon but it gives you an idea.

#include <Array.au3>

Global $aArray = _CheckMsgBox("Example.au3")
_ArrayDisplay($aArray)

Func _CheckMsgBox($sFilePath) ; Valid parameter checking by Beege & reading an au3 file by guinness.
    Local $aValid[17] = [16, 1, 2, 3, 4, 5, 6, 16, 32, 48, 64, 256, 512, 4096, 8192, 262144, 524288], $iBackup
    Local $hFileOpen = FileOpen($sFilePath, 0)
    Local $sData = FileRead($hFileOpen)
    FileClose($hFileOpen)

    Local $aError[1] = [0]
    Local $aReturn = StringRegExp('MsgBox(0, "_CheckMsgBox", "_CheckMsgBox")' & @CRLF & $sData, '(?s)(?i)MsgBox\((.*?),', 3)
    If @error Then
        Return SetError(1, 0, $aError)
    EndIf
    $aReturn[0] = UBound($aReturn, 1) - 1

    For $i = 1 To $aReturn[0]
        $aReturn[$i] = Number($aReturn[$i])
        $iBackup = $aReturn[$i]
        For $j = 1 To $aValid[0]
            If BitAND($aReturn[$i], $aValid[$j]) Then
                $aReturn[$i] -= $aValid[$j]
            EndIf
        Next

        If Not $aReturn[$i] Then
            If BitAND(1, $iBackup) And BitAND(2, $iBackup) And BitAND(4, $iBackup) Then
                $aReturn[$i] = "MsgBox(" & $iBackup & " >> InValid"
            EndIf
            $aReturn[$i] = "MsgBox(" & $iBackup & " >> Valid"
        Else
            $aReturn[$i] = "MsgBox(" & $iBackup & " >> InValid"
        EndIf
    Next
    Return SetError(0, 0, $aReturn)
EndFunc   ;==>_CheckMsgBox

Guinness, I think that last part would need to an Else statement, otherwise it just gets written over.

If BitAND(1, $iBackup) And BitAND(2, $iBackup) And BitAND(4, $iBackup) Then
     $aReturn[$i] = "MsgBox(" & $iBackup & " >> InValid"
Else
     $aReturn[$i] = "MsgBox(" & $iBackup & " >> Valid"
EndIf
Link to comment
Share on other sites

  • Moderators

emendelson,

any hope this can be incorporated somehow into SciTE??

You can do that yourself very easily:

- First compile your script and store it somewhere. I have a folder "Program FilesAutoIt3SciTESciTE Utils where I keep a lot of my own compiled scripts that do various things to help me when I code in AutoIt. ;)

- Open <Options - Open au3.properties>. Look for the long series of "command" lines that begin about Line 64 (#x 00 Beta RUN) and go down to the last one - for me it is Line 277 (#~ # 34 Generate UDF header). You need to find the highest value used so far - 34 in my case.

- Open <Options - User Options File>. Then BETWEEN the following lines:

# END => DO NOT CHANGE ANYTHING BEFORE THIS LINE #-#-#-#-#-#

>>>>>>>>>>> in here!!!! <<<<<<<<<<<<<

#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#

# START: DO NOT CHANGE ANYTHING AFTER THIS LINE #-#-#-#-#

you enter the following:

# 35 Utility_Name

command.35.$(au3)="$(SciteDefaultHome)SciTE UtilsUtility.exe"

command.name.35.$(au3)=Utility_Name

command.subsystem.35.$(au3)=2

command.save.before.35.$(au3)=2

command.quiet.35.$(au3)=1

If you have a different value for the final "command" in the au3.properties file than adjust the 35 value accordingly and you can obviously put the compiled exe file where you want and amend the path in the inserted text.

- Save the files, restart SciTE and you will find "Utility_Name" in the <Tools> menu. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...