Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

MsgBox parameter checker?


  • Please log in to reply
43 replies to this topic

#1 emendelson

emendelson

    Prodigy

  • Active Members
  • PipPipPip
  • 180 posts

Posted 29 January 2012 - 10:53 PM

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, 31 January 2012 - 06:37 PM.








#2 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 29 January 2012 - 11:51 PM

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

#3 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 29 January 2012 - 11:58 PM

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#4 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 30 January 2012 - 12:07 AM

Ahh damn your right. I'm stuck thinking about this now.

#5 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 30 January 2012 - 12:21 AM

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,

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#6 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 30 January 2012 - 12:37 AM

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?

#7 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 30 January 2012 - 01:04 AM

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#8 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 30 January 2012 - 01:16 AM

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.)

#9 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 3,237 posts

Posted 30 January 2012 - 03:12 AM

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, 30 January 2012 - 04:03 AM.


#10 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 30 January 2012 - 06:17 AM

Think I got it
AutoIt         
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, 30 January 2012 - 06:18 AM.


#11 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 30 January 2012 - 08:30 AM

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

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#12 Chimaera

Chimaera

    Sorry .. Where am i again?

  • Active Members
  • PipPipPipPipPipPip
  • 2,032 posts

Posted 30 January 2012 - 08:54 AM

You guys are proper out there...

Code fixing code whats next... :)

If Ive just helped you ... miracles do happen. Chimaera 

 

CopyRobo() * Hidden Admin Account Enabler * Software Location From Registry * Find Display Resolution * _ChangeServices()


#13 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 30 January 2012 - 09:16 AM

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.

AutoIt         
#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, 01 February 2012 - 08:06 PM.

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#14 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 3,237 posts

Posted 30 January 2012 - 02:07 PM

Think I got it

AutoIt         
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, 30 January 2012 - 02:19 PM.


#15 guinness

guinness

    all-consuming swarm in inconspicuous disguise

  • Developers
  • 17,659 posts

Posted 30 January 2012 - 02:14 PM

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

How did you come up with 10?

Example List: _AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_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()CodingDirToHTML5FileInstallrGeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()LockFile()Mapping CtrlIDsParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...
Updated: 26/09/2014


#16 jaberwacky

jaberwacky

    RegExp("\m/")

  • Active Members
  • PipPipPipPipPipPip
  • 3,237 posts

Posted 30 January 2012 - 02:38 PM

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, 30 January 2012 - 02:39 PM.


#17 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 30 January 2012 - 11:16 PM

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 ;)

#18 emendelson

emendelson

    Prodigy

  • Active Members
  • PipPipPip
  • 180 posts

Posted 31 January 2012 - 04:23 AM

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??

#19 Beege

Beege

    Universalist

  • MVPs
  • 895 posts

Posted 31 January 2012 - 04:34 AM

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.

AutoIt         
#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


#20 Melba23

Melba23

    I'm old - what's your excuse?

  • Moderators
  • 22,104 posts

Posted 31 January 2012 - 09:17 AM

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
StringSize - Automatically size controls to fit text                                                               ExtMsgBox - A user customisable replacement for MsgBox
Toast - Small GUIs which pop out of the Systray                                                                Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command                                   GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI                                      NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure      Notify - Small notifications on the edge of the display
Date_Time_Convert - Easily convert date/time formats, including the language               GUIListViewEx - Insert, delete, move, drag, sort and edit ListView items




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users