Leaderboard
Popular Content
Showing content with the highest reputation on 12/04/2013 in all areas
-
Using this script you can analyze the old scripts and search for keywords like: Local Global Dim Static Search only the above keywords used inside the Loop statements like: For ... Next While ... Wend Do ... Until For ... In ... Next This script parses a other script and reports on incorrect variable declarations within loops. Remark: Variable declaration is needed but it should be done outside the loop. Basic information of this script: Currently, the script provides two functions: _Check_Local_In_Loop__File() _Check_Local_In_Loop__Folder () Using functions: _Check_Local_In_Loop__File() You can specify a single file *. Au3 file will be checked for using the keyword "Local" inside the Loop Statements According to the used parameters the result will be send to SciTE console, Clipboard, eventualy displayed using _ArrayDisplay(). Using functions: _Check_Local_In_Loop__Folder () You can specify the folder containing the files *. Au3 All files in the given directory will be subject to analysis like above. The use of parameters, the internal functions: _Check_Local_In_Loop_Check_File ($ HFile, $ fArrayDisplay = True) additionally determines the manner of presenting the results of the work of this script. First Version 2013/12/03 02:00 AM EXAMPLE 1: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: array.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|While 1 1|Local $aiCurItems[1] = [0] 2|Local $aiCurItems[1] = [0] Explanation: Open this file in SciTE.exe and search text: Local $aiCurItems[1] = [0] You'll notice that this text is inside: While 1 EXAMPLE 2: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: ie.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|For $o_window In $o_ShellWindows 1|Local $f_found = False 2|Local $f_found = False Explanation: Open this file in SciTE.exe and search text: Local $f_found = False You'll notice that this text is inside: For $o_window In $o_ShellWindows EXAMPLE 3: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: GuiListView.au3 (from include AutoIt 3.3.9.23) results: Row |Col 0 0|For $i = 0 To $items - 1 1|Local $a_indices[2] 2|Local $a_indices[2] Explanation: Open this file in SciTE.exe and search text: Local $a_indices[2] You'll notice that this text is inside: For $i = 0 To $items - 1 EXAMPLE 4: Run that script in Current Beta: AutoIt 3.3.9.23 select Au3 file for example: array.au3 (from include AutoIt 3.3.8.1) results: Row |Col 0 0|While 1 1|Local $sClip = "" Local $aiCurItems[1] = [0] 2|Local $aiCurItems[1] = [0] Row |Col 0 0|For $x = 1 To 255 1|Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) 2|Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) Explanation: Open this file in SciTE.exe and search text: Local $sClip = "" Local $aiCurItems[1] = [0] You'll notice that this text is inside: While 1 search text: Local $sFind = _ArraySearch($avArray, Chr($x), 0, 0, 0, 1) You'll notice that this text is inside: For $x = 1 To 255 Version 2013/12/03 05:34 PM _Check_Local_In_Loop__Folder() ---> FileSelectFolder () parameter $fArrayDisplay = True parameter $fReturnAsString = False Version 2013/12/04 01:42 AM removed parameter $fReturnAsString added output to SciTE console removed not needed info from SciTE console Fixed problem with Loop statements on the begining of script added option (MsgBox) to choose "File or Folder" added option (MsgBox) to choose "Open file" see attached au3 file !!! NEW Version 2013/12/05 01:40 AM added checking for Global Dim and Static some other modyfication in REGEXP pattern see attached: BestCodingPractice_Analyzer__Version_20131205_0140_AM.zip BestCodingPractice_Analyzer.au3 BestCodingPractice_Analyzer__Version_20131205_0140_AM.zip1 point
-
Here my version (a little bit late): Global $aString[18] = ["x1", "x1", "x2", "x4", "x4", "x4", "x5", "x6", "001", "002", "002", "002", "003", "004", "004", "004", "004", "005"] ;~ Global $aString = StringSplit(StringStripCR(FileRead(@ScriptDir & "\1.txt")), @LF, 2) ConsoleWrite(FindDup($aString) & @LF) Func FindDup($aArray, $iMinDuplicates = 3) Local $i, $z = 1, $sResult For $i = 1 To UBound($aArray) - 1 If $aArray[$i - 1] = $aArray[$i] Then $z += 1 If $z = $iMinDuplicates Then $sResult &= $aArray[$i] & @CRLF Else $z = 1 EndIf Next Return $sResult EndFunc Edit: made some modifications. Br, UEZ1 point
-
Fr33b0w, This will work for any content on a line: #include <Array.au3> #include <File.au3> $aLines = FileReadToArray("Lines.txt") Global $aCounter[1000][2] = [[0]] ; Enough elements to match all possible values in the array For $i = 1 To UBound($aLines) - 1 ; Loop through the lines $sItem = $aLines[$i] ; Ignore blanks If $sItem Then ; Does it exist in the array so far? $iIndex = _ArraySearch($aCounter, $sItem, 1, 0, 2) If $iIndex >0 Then ; If it exists, increase the count $aCounter[$iIndex][1] += 1 Else ; It does not, so add it $aCounter[0][0] += 1 $aCounter[$aCounter[0][0]][0] = $sItem ; This is the item value $aCounter[$aCounter[0][0]][1] = 1 ; This is the instance count EndIf EndIf Next _ArrayDisplay($aCounter, "Counter") ; Now see if any items have the required number of matches $iRequired = 3 $sMatches = "" For $i = 1 To UBound($aCounter) - 1 If $aCounter[$i][1] = $iRequired Then ; Add to string $sMatches &= $aCounter[$i][0] & "|" EndIf Next ; Convert string to array $aMatches = StringSplit(StringTrimRight($sMatches, 1), "|") _ArrayDisplay($aMatches, "Matches at " & $iRequired) I used this file: x1 x2 x3 x4 x4 x4 x5 x6 001 003 005 006 007 008 009 010 011 012ab 014 015 016 017 018 021 022 023 024ab 025 026 028 030 031abc 032 033 034 035 036 NED Ibrahim Afellay NED Nigel De Jong NED Rafael Van Der Vaart NED Eljero Elia NED Georginio Wijnaldum NED John Heitinga NED Maarten Stekelenburg CZE Tomas Sivok CZE Milan Baros CZE Jaroslav Plasil CZE Tomas Hubschman CZE Zdenek Pospech CZE Michal Kadlec ENG Ashley Cole aa bb cc dd ee ff gg a b c d e f g and it returned "x4" - which is what I expected. M23 Edit: mikell, Clever.1 point
-
Here is a different route. Created a function to return an array of all counts of a line. You can then loop through that return for what you need. Global Enum $iData_String, $iData_Count, $iData_UBound ; example of something read from a file, via _FileReadToArray Local $aData[18] = ["x1","x2","x3","x4","x4","x4","x5","x6","001","002","002","002","003","004","004","004","005","006"] $aReturn = CountLines($aData) ; Loop through and get where count = 3 or 4 For $i = 0 To UBound($aReturn)-1 If $aReturn[$i][$iData_Count] = 3 Or $aReturn[$i][$iData_Count] = 4 Then ; your code ConsoleWrite("Line=[" & $aReturn[$i][$iData_String] & "] contains count=[" & $aReturn[$i][$iData_Count] & "]" & @CRLF) EndIf Next _ArrayDisplay($aReturn) Exit Func CountLines($aData) ; Get unique values and sorted data Local $aDataUnique = _ArrayUnique($aData) ; Remove counts _ArrayDelete($aDataUnique,0) _ArraySort($aData) ; Create new array to house counts/data Local $aDataWithCounts[UBound($aDataUnique)][$iData_UBound] ; Populate the new array For $i = 0 To UBound($aDataUnique)-1 $aDataWithCounts[$i][$iData_String] = $aDataUnique[$i] Next ; Get counts in sorted, to insert into $aDataWithCounts Local $sLast, $iCount = 0 For $i = 0 to UBound($aData) - 1 If $aData[$i] == $sLast Then $iCount += 1 Else $sLast = $aData[$i] $iCount = 1 EndIf $aDataWithCounts[_ArraySearch($aDataWithCounts,$sLast,0,0,0,0,1,0)][$iData_Count] = $iCount Next If $iCount > 0 Then $aDataWithCounts[_ArraySearch($aDataWithCounts,$sLast)][$iData_Count] = $iCount Return $aDataWithCounts EndFunc output: Line=[x4] contains count=[3] Line=[002] contains count=[3] Line=[004] contains count=[3]1 point
-
Thanks Looks like function _AD_ObjectExists causes the error = 1. The passed group name is used in a LDAP search. This means the escape characters you provided are needed. My _AD_FixSpecialChars function only seems to work for FQDN. I will have to verify that.1 point
-
Looks like I need to do some more investigation ...1 point
-
The only way out of your while loop is "Return" so I guess this is inside a function. If you are returning, then you are ending the function completely, both the For loop and the While loop. EDIT: In other words, there is no way for the script to ever make it to "Next".1 point
-
Reinhardt1julian, The problem is obvious - in line 35829 you are not furgling the qualopper. ;.... Seriously, what on earth do you expect us to say when faced with a small syntactically incorrect snippet like that? Post the whole code and then you might stand a chance of getting a sensible answer. m231 point
-
I always considered Tidy a best coding practice analyzer.1 point
-
Check out the coordinates you want to capture -> it shouldn't be strings in this case because "760" is greater than "1068" and error -1 will be set. #include <ScreenCapture.au3> dim $sFilePath = "E:\tmp.BMP" dim $OCR_Rectangle[4] = [760, 480, 1068, 522] ConsoleWrite(_ScreenCapture_Capture($sFilePath,$OCR_Rectangle[0], $OCR_Rectangle[1], $OCR_Rectangle[2], $OCR_Rectangle[3],False) & @LF) Unfortunately _ScreenCapture_Capture() doesn't convert the input to an integer value automatically. Br, UEZ1 point
-
It is precisely for this, going. I am doing script analyzer. Although this task may seem ridiculous, it is a very good job of learning. Or maybe this will be an additional benefit in the form of a script in the "Example Scirpts" EDIT: I have some old scripts, the number of errors occurring in them is staggering. So I wanted to automate some amendments. So I am in the process of development .....1 point
-
Take a look at '?do=embed' frameborder='0' data-embedContent>> Although it is for XML, the first post contains the code that will work with every file (after some modifications)1 point
-
Kovacic, I have answered this here. And now we will keep that pesky bird in its cage.... M231 point
-
Kovacic, people are already using AutoIt to control Arduino's. You can use my udf for serial comms (see my signature) The point of this thread is to produce an AutoIt udf which doesn't use a dll like mine does, but if you aren't worried about the dll then there is no need to wait. (You don't need to know anything about using a dll to use my udf by the way.)1 point
-
Tray Icon Disappearing Problem
coffeeturtle reacted to rover for a topic
if explorer crashes, a WM_TASKBARCREATED message is broadcast to all windows once explorer is re-created so applications can re-create their tray icons. apps call RegisterWindowMessage API and register message "TaskbarCreated" AutoIt handles this message internally and re-creates the icon in the Notification Area. some apps don't bother to monitor for this message. this is how icons fail to re-appear in the Notification Area. you would have to enumerate the tray icons to see if your app is not among them (hidden) and try running TraySetState(1) or TraySetIcon(@AutoItExe, 1) I don't see how the icon is not being re-created internally by AutoIt if that is in fact the problem the icon is always re-created by AutoIt using the Shell_NotifyIconW API if Explorer crashes/closes. what is AutoIt version of compiled app and machines OS? (sometimes people who post here are using older AutoIt versions and don't state it) OS of the machines problem occurs on? problem with icon in compiled app? (clarification: if you are adding your own icon not shown in your posted script) Edit: example script shows how you could monitor for Explorer closure/crash and write to log if this is an old AutoIt version bug or OS problem related to Explorer then if icon has disappeared and crash is logged that might help in troubleshooting I can also post a tray icon enumerating script that lists visible and hidden icons (some hidden icons are not listed in taskbar hide inactive icons list. e.g. 4 Explorer Connections Tray icons) ;example script shows how WM_TASKBARCREATED message is received ;Author: rover ;if explorer closed or crashed, WM_TASKBARCREATED message received by window after Explorer is re-created #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <guiconstantsex.au3> #include <windowsconstants.au3> Opt('MustDeclareVars', 1) Global $WM_TASKBARCREATED Global $aRet = DllCall("User32.dll", "int", "RegisterWindowMessageW", "wstr", "TaskbarCreated") If @error Or UBound($aRet) <> 2 Then Exit $WM_TASKBARCREATED = $aRet[0] ConsoleWrite('+$WM_TASKBARCREATED = ' & Hex($WM_TASKBARCREATED) & @CRLF) _Main() Func _Main() GUICreate("WM_TASKBARCREATED", 400, 200) GUIRegisterMsg($WM_TASKBARCREATED, "WM_TASKBARCREATED") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc;==>_Main Func WM_TASKBARCREATED($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam, $ilParam ConsoleWrite('!WM_TASKBARCREATED = ' & $iMsg & @CRLF) Beep(1000, 5) Return $GUI_RUNDEFMSG EndFunc;==>WM_TASKBARCREATED1 point