MHz Posted April 15, 2007 Share Posted April 15, 2007 (edited) Summary:I have been using this script for quite some time to change the descriptions used in the calltips of Scite4AutoIt3 to instead show me the return values and any other information that I consider helpful. New users of AutoIt should probably remain with the original calltip descriptions until understanding of the function does as described.UpdateDefs.exe can be executed to return your calltips back to default if you choose to go back.Download:Update_Au3.api.zipScript:_linenums:0'>expandcollapse popup; Au3 API Update script (Changes Comments in Calltip) ; Constants Global Const $IDNO = 7 Global Const $TITLE = 'Au3 API Updater' ; Files to use $ini_file = @ScriptDir & '\Update_Au3_Config.ini' ; Ini file $api_original = @ProgramFilesDir & '\AutoIt3\Scite\api\au3.api' ; Original api file $api_temporary = _TempFile() ; Temp api file ; Confirm files existance Select Case Not FileExists($ini_file) MsgBox(0x40000, $TITLE, $ini_file & ' not found') Exit 1 Case Not FileExists($api_original) $dir = FileSelectFolder('Locate directory that contains the au3.api file', @HomeDrive, 2) If FileExists($dir) And FileChangeDir($dir) And FileExists(@WorkingDir & '\au3.api') Then $api_original = @WorkingDir & '\au3.api' Else MsgBox(0x40000, $TITLE, 'Au3.api does not exist within the selected folder' & @CRLF & $title & ' will now close') Exit 2 EndIf EndSelect ; Choose to continue with update process $api_original_size = Int(FileGetSize($api_original) / 1000) If MsgBox(0x40024, $TITLE, _ 'Do you want to proceed to update this file' & _ @CRLF & @CRLF & 'API File: " ' & $api_original & ' "' & _ @CRLF & 'FileSize: ' & $api_original_size & ' kb') = $IDNO Then Exit EndIf ; Open the files $handle_read = FileOpen($api_original, 0) $handle_write = FileOpen($api_temporary, 2) _FileOpenCheck($handle_read, $handle_write) ; These prefix items are simply written without further processing Global $filter[11] = [10, _ '_', '@', '#', 'AutoItSetOption', 'ControlCommand', _ 'ControlListView', 'Opt', 'TimerStart', 'TimerStop', 'WinShow'] ; Read the comments from the ini file Global $ini_section_comments, $ini_section_returns $array_comments = IniReadSection($ini_file, 'comments') If Not @error Then $ini_section_comments = True $array_returns = IniReadSection($ini_file, 'returns') If Not @error Then $ini_section_returns = True ; Read, check with ini file then write Global $done_msgbox, $done_fileopen, $done_drivegetdrive While 1 $comment = '' $line = FileReadLine($handle_read) If @error = -1 Then ; Write final lines to file If $done_msgbox Then _MsgBox($done_msgbox) If $done_fileopen Then _FileOpen($done_fileopen) If $done_drivegetdrive Then _DriveGetDrive($done_drivegetdrive) ExitLoop EndIf $line = StringStripWS($line, 3) ; Check for duplicates or empty lines Select Case $line = '' ContinueLoop Case StringLeft($line, 6) = 'MsgBox' And $done_msgbox ContinueLoop Case StringLeft($line, 9) = 'FileOpen ' And $done_fileopen ContinueLoop Case StringLeft($line, 8) = 'DriveGetDrive' And $done_drivegetdrive ContinueLoop EndSelect ; Search for items to simply write without change For $i = 1 To $filter[0] $length = StringLen($filter[$i]) If StringLeft($line, $length) = $filter[$i] Then FileWriteLine($handle_write, $line) ContinueLoop 2 EndIf Next ; Search for function name $count = StringInStr($line, '(') $temp = StringLeft($line, $count - 2) ; Return value from function key within the ini file $value = IniRead($ini_file, 'functions', $temp, '') If Not $value Then ; If function name not in ini file or no value returned then just write it FileWriteLine($handle_write, $line) ContinueLoop Else $return = '' ; Split ini value that contains a pipe char $value_split = StringSplit($value, '|'); If Not @error And $value_split[0] = 2 Then ; Line: Split If StringIsDigit($value_split[1]) Then $return = _SectionReturn($value_split[2]) $comment = _SectionComment($value_split[1]) Else $return = _SectionReturn($value_split[1]) $comment = _SectionComment($value_split[2]) EndIf Else ; Line: UnSplit If StringIsDigit($value) Then $comment = _SectionComment($value) Else $return = _SectionReturn($value) EndIf EndIf ; Prepare the new line Select Case $return And $comment $return &= ' (' & $comment & ')' ;~ Case $return ;~ $return = $return Case $comment $return = $comment EndSelect ; $count = StringInStr($line, ')') $line = StringLeft($line, $count) & ' Return: ' & $return EndIf ; Flag these items as done only once to prevent duplicates Select Case StringLeft($line, 6) = 'MsgBox' $done_msgbox = StringLeft($line, $count) Case StringLeft($line, 9) = 'FileOpen ' $done_fileopen = StringLeft($line, $count) Case StringLeft($line, 13) = 'DriveGetDrive' $done_drivegetdrive = StringLeft($line, $count) EndSelect ; Write the changed line FileWriteLine($handle_write, $line) WEnd ; Close the open files FileClose($handle_read) FileClose($handle_write) Sleep(100) ; Replace API file and message the result $api_temporary_size = Int(FileGetSize($api_temporary) / 1000) If FileExists($api_original) And FileExists($api_temporary) Then If FileMove($api_temporary, $api_original, 1) Then MsgBox(0x40000, $TITLE, 'Completed Successfully' & _ @CRLF & @CRLF & 'API File: " ' & $api_original & ' "' & _ @CRLF & 'FileSize: ' & Int(FileGetSize($api_original) / 1000) & ' kb' & _ @CRLF & @CRLF & 'Reduced by: ' & $api_original_size - $api_temporary_size & ' kb' & _ @CRLF & @CRLF & 'Use UpdateDefs to restore the original API file if required') Else MsgBox(0x40030, $TITLE, 'The original API file was not replaced') EndIf EndIf Exit Func _FileOpenCheck(ByRef $handle_read, ByRef $handle_write) ; Check both opened files are open for use Select Case $handle_read <> - 1 And $handle_write <> - 1 Return 1 Case $handle_read = -1 MsgBox(0x40030, "Error", "Unable to open file for read") If $handle_write <> - 1 Then FileClose($handle_write) Exit 3 Case $handle_write = -1 MsgBox(0x40030, "Error", "Unable to open file for write") If $handle_read <> - 1 Then FileClose($handle_read) Exit 4 EndSelect EndFunc Func _SectionComment($udf_value) ; Loops through the Comments Ini Section Array and Returns the value of a match. Dim $ini_section_comments Local $udf_comment If $ini_section_comments Then For $i = 1 To $array_comments[0][0] If StringInStr($udf_value, $array_comments[$i][0]) Then $udf_comment = StringStripWS($array_comments[$i][1], 3) EndIf Next EndIf Return $udf_comment EndFunc Func _SectionReturn($udf_value) ; Loops through the Returns Ini Section Array and Returns the value of a match. Dim $ini_section_returns Local $udf_returns If $ini_section_returns Then For $i = 1 To $array_returns[0][0] If StringInStr($udf_value, $array_returns[$i][0]) Then $udf_returns = $udf_returns & ', ' & $array_returns[$i][1] EndIf Next EndIf If StringLeft($udf_returns, 2) = ', ' Then $udf_returns = StringTrimLeft($udf_returns, 2) If StringRight($udf_returns, 2) = ', ' Then $udf_returns = StringTrimRight($udf_returns, 2) Return $udf_returns EndFunc Func _DriveGetDrive($line) ; Add extra line for DriveGetDrive. FileWriteLine($handle_write, $line & _ ' Type: "ALL", "CDROM", "REMOVABLE", "FIXED", "NETWORK", "RAMDISK", "UNKNOWN"') EndFunc Func _FileOpen($line) ; Add extra line for FileOpen. FileWriteLine($handle_write, $line & _ ' Mode: 0 = Read, 1 = Write(append), 2 = Write(erase), 4 = Read raw, 8 = Create directory') EndFunc Func _MsgBox($line) ; Add extra lines for MsgBox. FileWriteLine($handle_write, $line & _ ' Button: 0x0 OK, 0x1 OK-Cancel, 0x2 Abort-Retry-Ignore, 0x3 Yes-No-Cancel,' & _ ' 0x4 Yes-No, 0x5 Retry-Cancel, 0x6 Cancel-Try~Again-Continue') FileWriteLine($handle_write, $line & _ ' Icon: 0x0 None, 0x10 Stop, 0x20 Question, 0x30 Exclaimation, 0x40 Information') FileWriteLine($handle_write, $line & _ ' Default-Button: 0x0 1st, 0x100 2nd, 0x200 3rd') FileWriteLine($handle_write, $line & _ ' Modality: 0x0 Application, 0x1000 System, 0x2000 Task') FileWriteLine($handle_write, $line & _ ' Misc: 0x0 None, 0x40000 Top-Most, 0x80000 Right-Justified') EndFunc Func OnAutoItStart() ; A 2nd script instance will exit. Local $interpreter $interpreter = StringTrimRight(@ScriptName, 4) & ' Script Interpreter' If WinExists($interpreter) Then Exit AutoItWinSetTitle($interpreter) EndFunc Func _TempFile($s_DirectoryName = @TempDir, $s_FilePrefix = "~", $s_FileExtension = ".tmp", $i_RandomLength = 7) Local $s_TempName ; Check parameters If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @TempDir ; First reset to default temp dir If Not FileExists($s_DirectoryName) Then $s_DirectoryName = @ScriptDir ; Still wrong then set to Scriptdir ; add trailing \ for directory name If StringRight($s_DirectoryName, 1) <> "\" Then $s_DirectoryName = $s_DirectoryName & "\" Do $s_TempName = "" While StringLen($s_TempName) < $i_RandomLength $s_TempName = $s_TempName & Chr(Random(97, 122, 1)) WEnd $s_TempName = $s_DirectoryName & $s_FilePrefix & $s_TempName & $s_FileExtension Until Not FileExists($s_TempName) Return ($s_TempName) EndFuncInifile:[returns]b = Booleane = Errorx = Extendedn = None[comments]1 = if window is not found2 = if no title match3 = if the function is not supported on an OS4 = end of file5 = always returns 16 = if RunErrorsFatal = 0 for silent error7 = if the button is not in the list8 = if the direction is not recognized9 = if window/control is not found10 = "UNKNOWN", "READY", "NOTREADY", "INVALID"11 = -1 if error occurs12 = -1 Timeout, 1 OK, 2 Cancel, 3 Abort, 4 Retry, 5 Ignore, 6 Yes, 7 No, 10 Try Again, 11 Continue13 = 1 Success, 0 Key/Value does not exist, 2 Delete error14 = Error for occurance parameter was 0[functions]Abs = ACos = AdlibDisable = nAdlibEnable = nAsc = ASin = Assign = bATan =AutoItWinGetTitle = nAutoItWinSetTitle = nBeep = 5BinaryString = BitAND = BitNOT = BitOR = BitRotate = BitShift = BitXOR = BlockInput = nBreak = nCall = eCDTray = bCeiling =Chr =ClipGet = eClipPut = bConsoleRead = e|4ConsoleWrite = nConsoleWriteError = nControlClick = bControlDisable = bControlEnable = bControlFocus = bControlGetFocus = beControlGetHandle = beControlGetPos = eControlGetText = beControlHide = b|9ControlMove = b|9ControlSend = b|9ControlSetText = b|9ControlShow = b|9Cos = Dec = beDirCopy = bDirCreate = bDirGetSize = eDirMove = bDirRemove = bDllCall = eDllClose = nDllOpen = DllStructCreate = beDllStructGetData = beDllStructGetPtr = beDllStructGetSize = beDllStructSetData = beDriveGetDrive = eDriveGetFileSystem = eDriveGetLabel = eDriveGetSerial = eDriveGetType = eDriveMapAdd = beDriveMapDel = bDriveMapGet = eDriveSetLabel = bDriveSpaceFree = beDriveSpaceTotal = eDriveStatus = 10EnvGet = bEnvSet = bEnvUpdate = eEval = beExecute = eExp =FileChangeDir = bFileClose = bFileCopy = bFileCreateNTFSLink = bFileCreateShortcut = bFileDelete = bFileExists = bFileFindFirstFile = 11FileFindNextFile = eFileGetAttrib = beFileGetLongName = eFileGetShortcut = eFileGetShortName = eFileGetSize = eFileGetTime = eFileGetVersion = eFileInstall = bFileMove = bFileOpen = 11FileOpenDialog = eFileRead = eFileReadLine = eFileRecycle = bFileRecycleEmpty = bFileSaveDialog = eFileSelectFolder = beFileSetAttrib = bFileSetTime = bFileWrite = bFileWriteLine = bFloor =FtpSetProxy = bGUICreate = beGUICtrlCreateAvi = bGUICtrlCreateButton = bGUICtrlCreateCheckbox = bGUICtrlCreateCombo = bGUICtrlCreateContextMenu = bGUICtrlCreateDate = bGUICtrlCreateDummy = bGUICtrlCreateEdit = bGUICtrlCreateGraphic = bGUICtrlCreateGroup = bGUICtrlCreateIcon = bGUICtrlCreateInput = bGUICtrlCreateLabel = bGUICtrlCreateList = bGUICtrlCreateListView = bGUICtrlCreateListViewItem = bGUICtrlCreateMenu = bGUICtrlCreateMenuitem = bGUICtrlCreateMonthCal = bGUICtrlCreateObj = bGUICtrlCreatePic = bGUICtrlCreateProgress = bGUICtrlCreateRadio = bGUICtrlCreateSlider = bGUICtrlCreateTab = bGUICtrlCreateTabItem = bGUICtrlCreateTreeView = bGUICtrlCreateTreeViewItem = bGUICtrlCreateUpdown = bGUICtrlDelete = bGUICtrlGetHandle = bGUICtrlGetState = bGUICtrlRead = bGUICtrlRecvMsg = bGUICtrlRegisterListViewSort = bGUICtrlSendMsg = bGUICtrlSendToDummy = bGUICtrlSetBkColor = bGUICtrlSetColor = bGUICtrlSetCursor = bGUICtrlSetData =GUICtrlSetFont = bGUICtrlSetGraphic =GUICtrlSetImage = bGUICtrlSetLimit = bGUICtrlSetOnEvent = bGUICtrlSetPos = bGUICtrlSetResizing = bGUICtrlSetState = bGUICtrlSetStyle = bGUICtrlSetTip = bGUIDelete = bGUIGetCursorInfo =GUIGetMsg = bGUIRegisterMsg = bGUISetBkColor = bGUISetCoord = bGUISetCursor = bGUISetFont = bGUISetHelp = bGUISetIcon = bGUISetOnEvent = bGUISetState = bGUIStartGroup = bGUISwitch = bHex = bHotKeySet = bHttpSetProxy = bHWnd = eInetGet = bInetGetSize = beIniDelete = bIniRead = IniReadSection = eIniReadSectionNames = eIniRenameSection = bIniWrite = bIniWriteSection = beInputBox = beInt = beIsAdmin = bIsArray = bIsBinaryString = bIsBool = bIsDeclared = bIsFloat = bIsHWnd = bIsInt = bIsKeyword = bIsNumber = bIsObj = bIsString = bLog =MemGetStats =Mod =MouseClick = b|7MouseClickDrag = b|7MouseDown = b|7MouseGetCursor = bMouseGetPos = eMouseMove =MouseUp = b|7MouseWheel = b|8MsgBox = 12Number =ObjCreate = beObjEvent = beObjGet = beObjName = bePing = bePixelChecksum =PixelGetColor =PixelSearch = ePluginClose = bPluginOpen = bProcessClose = n|5ProcessExists = bProcessList = eProcessSetPriority = beProcessWait = bProcessWaitClose = bProgressOff = nProgressOn = nProgressSet = nRandom = beRegDelete = 13RegEnumKey = beRegEnumVal = bexRegRead = bexRegWrite = bRound =Run = e|6RunAsSet =RunWait = e|6Send = nSetError =SetExtended =ShellExecute = e|6ShellExecuteWait = e|6Shutdown = bSin =Sleep = nSoundPlay = nSoundSetWaveVolume = beSplashImageOn = nSplashOff = nSplashTextOn = nSqrt =StatusbarGetText = beStderrRead = eStdinWrite = eStdoutRead = eString =StringAddCR =StringFormat =StringInStr = beStringIsAlNum = bStringIsAlpha = bStringIsASCII = bStringIsDigit = bStringIsFloat = bStringIsInt = bStringIsLower = bStringIsSpace = bStringIsUpper = bStringIsXDigit = bStringLeft =StringLen =StringLower =StringMid =StringRegExp = exStringRegExpReplace = exStringReplace = xStringRight =StringSplit = eStringStripCR =StringStripWS =StringTrimLeft =StringTrimRight =StringUpper =Tan =TCPAccept = eTCPCloseSocket = eTCPConnect = eTCPListen = eTCPNameToIP = eTCPRecv = eTCPSend = eTCPShutdown = beTCPStartup = beTimerDiff =TimerInit =ToolTip = nTrayCreateItem = bTrayCreateMenu = bTrayGetMsg = bTrayItemDelete = bTrayItemGetHandle = bTrayItemGetState = bTrayItemGetText = bTrayItemSetOnEvent = bTrayItemSetState = bTrayItemSetText = bTraySetClick = bTraySetIcon = bTraySetOnEvent = bTraySetPauseIcon = bTraySetState = bTraySetToolTip = bTrayTip = nUBound = beUDPBind = eUDPCloseSocket = beUDPOpen = eUDPRecv = beUDPSend = eUDPShutdown = beUDPStartup = beWinActivate = b|1WinActive = b|1WinClose = b|1WinExists = bWinFlash = nWinGetCaretPos = eWinGetClassList = beWinGetClientSize = eWinGetHandle = beWinGetPos = eWinGetProcess =WinGetState = beWinGetText = b|2WinGetTitle = b|2WinKill = nWinList =WinMenuSelectItem = bWinMinimizeAll = nWinMinimizeAllUndo = nWinMove = b|1WinSetOnTop = b|1WinSetState = b|1WinSetTitle = b|1WinSetTrans = b|3WinWait = bWinWaitActive = bWinWaitClose = bWinWaitNotActive = bEdit:Updated to Beta 3.2.3.5 Edited April 16, 2007 by MHz Link to comment Share on other sites More sharing options...
Skrip Posted April 15, 2007 Share Posted April 15, 2007 Nice job! [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
MHz Posted April 16, 2007 Author Share Posted April 16, 2007 Nice job!Thanks Firestorm.Now updated to Autoit beta 3.2.3.5. Link to comment Share on other sites More sharing options...
BillLuvsU Posted April 16, 2007 Share Posted April 16, 2007 Ok, so this updates the calltips to the beta definitions? Very usefull. [center][/center]Working on the next big thing.Currently Playing: Halo 4, League of LegendsXBL GT: iRememberYhslaw Link to comment Share on other sites More sharing options...
MHz Posted April 16, 2007 Author Share Posted April 16, 2007 Ok, so this updates the calltips to the beta definitions? Very usefull.The change accommodates for the binary function changes in the AutoIt Beta that Jon brought in. 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