Leaderboard
Popular Content
Showing content with the highest reputation on 01/25/2025 in all areas
-
Installer for execute a3x-Files
SOLVE-SMART reacted to Schnuffel for a topic
So, here is my work with which you can compile an installer that installs the existing AutoIt3.exe / AutoIt3_x64.exe on another PC and registers the file type a3x. This allows you to perform this installation on others and then distribute your work as an a3x file, update it etc. Support for 64-bit a3x compiled files is also integrated. The file extension for these files must be .a3x_64. This file type is then executed with AutoIt_x64.exe. Attention, as this is not an official installation routine, the file type .a3x_64 is not supported in an official installation of AutoIt3! I thank @Jos and @Argumentum for their suggestions. I would be pleased if one or the other would try this out, especially with regard to “false positive” messages from virus scanners concerning a3x files. Since the script is a bit longer due to the inserted files (icon and logo), I am only providing it here as an attachment file. As always, suggestions, wishes, praise, criticism, questions and constructive criticism are very welcome. :clap 09.02.2025: in the last upload the script was broken, bugs corrected ... thx to @Argumentum for Input. ^^ a3x_Setup.au31 point -
approach as function for reusing #include <Array.au3> #include <File.au3> Global $salesData = [ _ ["Product", "Region", "Sales"], _ ["Laptop", "North", 150], _ ["Smartphone", "South", 200], _ ["Laptop", "South", 100], _ ["Tablet", "North", 75], _ ["Smartphone", "North", 180], _ ["Desktop", "South", 300], _ ["Laptop", "North", 250], _ ["Smartphone", "North", 120]] Global $aSumTbl = _ArrayCrosstab($salesData, 0, 1, 2, 1) _ArrayDisplay($aSumTbl, "$aSumTbl") _ArrayCrosstab ; https://www.autoitscript.com/forum/topic/212654-help-with-data-processing-and-reporting/#findComment-1540469 #include <Array.au3> #include <File.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Global $aTbl = _GetAsTable(@ScriptDir & "\OP example.txt", 0) ; "\Lite_Data.txt" If Not IsArray($aTbl) Then Exit MsgBox(16, "Error", "Failed to load the table from the file.") _ArrayDisplay($aTbl, "$aTbl") Global $aSumTbl = _ArrayCrosstab($aTbl, 0, 7, 9) _ArrayDisplay($aSumTbl, "$aSumTbl") ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _ArrayCrosstab ; Description....: Summarize an array by grouping and counting values. ; Syntax.........: _ArrayCrosstab(Const ByRef $aArray, $iRowHeading, $iColumnHeading, $iValue, $iBase = 0, $iValueType = 1) ; Parameters.....: $aArray - The array to summarize. ; $iRowHeading - The column number for the Row Heading value in the cross-tabulation. ; $iColumnHeading - The column number for the Column Heading value in the cross-tabulation. ; $iValue - The column number of the value to sum or count or max or min, in the cross-tabulation. ; $iBase - [Optional] The array is 0-based or 1-based. Default 0 = 0-based. ; $iValueType - [Optional] The type of value to summarize. Default is 1 = sum. ; 1 = sum - Default ; 2 = cnt ; 3 = max ; 4 = min (excluding null or zero) ; Return values..: A two-dimensional array containing the aggregated data. ; Author ........: ioa747 ; Notes .........: This function uses the _ArrayUnique() function to get unique values for $iRowHeading, $iColumnHeading ; Link ..........: ; Dependencies...: #include <Array.au3>, #include <File.au3> ;-------------------------------------------------------------------------------------------------------------------------------- Func _ArrayCrosstab(Const ByRef $aArray, $iRowHeading, $iColumnHeading, $iValue, $iBase = 0, $iValueType = 1) If $iValueType < 1 Or $iValueType > 4 Then $iValueType = 1 If $iBase < 0 Or $iBase > 1 Then $iBase = 0 If Not IsArray($aArray) Then Return SetError(1, 0, "Is Not Array") Local $mRow[], $mCol[] ; Get the Row Heading values Local $aRow = _ArrayUnique($aArray, $iRowHeading, $iBase) For $i = 1 To $aRow[0] $mRow[$aRow[$i]] = $i Next ; Get the Column Heading values Local $aCol = _ArrayUnique($aArray, $iColumnHeading, $iBase) For $i = 1 To $aCol[0] $mCol[$aCol[$i]] = $i Next ; initialize the Result array Local $aResult[UBound($aRow)][UBound($aCol)] ; add Column Heading to Result array For $i = 1 To $aCol[0] $aResult[0][$i] = $aCol[$i] Next ; add Row Heading to Result array For $i = 1 To $aRow[0] $aResult[$i][0] = $aRow[$i] Next $aResult[0][0] = $aRow[0] ; fill the Values to Result array Switch $iValueType Case 1 ; sum For $i = $iBase To UBound($aArray) - 1 $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] += $aArray[$i][$iValue] Next Case 2 ; cnt For $i = $iBase To UBound($aArray) - 1 $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] += 1 Next Case 3 ; max For $i = $iBase To UBound($aArray) - 1 Local $currentValue = $aArray[$i][$iValue] If $currentValue > $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] Then $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] = $currentValue EndIf Next Case 4 ; min (excluding null or zero) For $i = $iBase To UBound($aArray) - 1 Local $currentValue = $aArray[$i][$iValue] If $currentValue <> 0 And $currentValue <> "" Then If $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] = 0 Or _ $currentValue < $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] Then $aResult[$mRow[$aArray[$i][$iRowHeading]]][$mCol[$aArray[$i][$iColumnHeading]]] = $currentValue EndIf EndIf Next EndSwitch Return $aResult EndFunc ;==>_ArrayCrosstab ;--------------------------------------------------------------------------------------- Func _GetAsTable($sFileName, $iBase = 1, $sDelimiter = @TAB) Local $vReturn ; Read the file into an array _FileReadToArray($sFileName, $vReturn, $iBase, $sDelimiter) ;_ArrayDisplay($vReturn) ; Extract the model name from the 4th column and put it in the 1st column (it was empty) For $i = 0 To UBound($vReturn) - 1 Local $aModel = StringSplit($vReturn[$i][4], "_") ; model data $vReturn[$i][0] = ($aModel[0] > 0 ? StringTrimLeft($aModel[1], 3) : $aModel[1]) Next Return $vReturn EndFunc ;==>_GetAsTable Happy coding!1 point
-
Installer for execute a3x-Files
argumentum reacted to Schnuffel for a topic
Many thanks for the advice. I have corrected and replaced the script in #1.Thanks for the tips1 point -
How to automate photos editor/viewer in windows
argumentum reacted to water for a topic
I suggest IrfanView. It has a batch mode, so there is no need to automate the Photo Viewer1 point -
Help with data processing and reporting.
Trong reacted to pixelsearch for a topic
@Trong Hi Here is a quick attempt using only AutoIt, it seems to work fine. I have a concern when "Big_Data.txt" is used, because 222 columns are generated (222 unique process names) Also I don't know if the columns names (the process names) need to be ordered in a specific way, in which case some code should be added, you'll see. I'm using in this script a great function from @AspirinJunkie initially named _StringSplit2D, I tweaked it a bit to add a couple of parameters and make it even more flexible, it's very useful. Your function _Get_ModelName() is in the script, untouched, to extract the model name and place it in a new column #13 ... while _StringSplit2D is performing, best moment to do this ! #include <Array.au3> #include <MsgBoxConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration _GetYield() ;============================================== Func _GetYield() Local $sFileName = @ScriptDir & "\OP example.txt" ; Local $sFileName = @ScriptDir & "\Lite_Data.txt" ; Local $sFileName = @ScriptDir & "\Big_Data.txt" If Not FileExists($sFileName) Then Exit MsgBox($MB_TOPMOST, "Error", _ $sFileName & @crlf & @crlf & "File doesn't exist") Local $sFileRead = FileRead($sFileName) If @error Then Exit MsgBox($MB_TOPMOST, "FileRead : error " & @error, "") Local $aArray = _StringSplit2D_EX($sFileRead, @TAB, @CRLF, False, 1) ; last param. 1 => add 1 column on the right (column 13) If @error Then Exit MsgBox($MB_TOPMOST, "_StringSplit2D_EX : error " & @error, _ "All rows don't have the same number of columns" & @crlf & @crlf & _ "line 0 versus line " & @extended) _ArrayDisplay($aArray, "Initial data + column 13 added on the right") Local $aModel = _ArrayUnique($aArray, 13, 0, 0, $ARRAYUNIQUE_NOCOUNT) _ArrayDisplay($aModel, "Unique Models") Local $aProcess = _ArrayUnique($aArray, 7, 0, 0, $ARRAYUNIQUE_NOCOUNT) _ArrayDisplay($aProcess, "Unique Process") Local $aResult[Ubound($aModel)][Ubound($aProcess) + 1], $mModel[], $mProcess[], $sHeader, $iRow, $iCol ; Final array : fill the model column with unique model names For $i = 0 To Ubound($aModel) - 1 $aResult[$i][0] = $aModel[$i] $mModel[$aModel[$i]] = $i Next ; Final array : prepare the headers with unique process names For $j = 0 To Ubound($aProcess) - 1 $sHeader &= $aProcess[$j] & "|" $mProcess[$aProcess[$j]] = $j Next ; Final array : update any cell with its new value For $i = 0 To Ubound($aArray) - 1 $iRow = $mModel[$aArray[$i][13]] $iCol = $mProcess[$aArray[$i][7]] $aResult[$iRow][$iCol + 1] += $aArray[$i][9] Next _ArrayDisplay($aResult, "Result", Default, $ARRAYDISPLAY_NOROW, Default, "Models|" & $sHeader) EndFunc ;==>_GetYield ;============================================== Func _StringSplit2D_EX(ByRef $sString, $sDelim_Col = "|", $sDelim_Row = @CRLF, $bExpand = False, $iAdd_EmptyCol = 0) ; based on AspirinJunkie's function _StringSplit2D found at https://autoit.de/thread/85380-1d-array-in-2d-array-splitten/ ; Thanks Nine for suggesting the 4th parameter $bExpand, to allow or not the same number of fields per row (as in _FileReadToArray) Local $a_FirstDim = StringSplit($sString, $sDelim_Row, $STR_ENTIRESPLIT + $STR_NOCOUNT) Local $iKeep_NbCol = Ubound(StringSplit($a_FirstDim[0], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT)) ; keep nb cols row 0 Local $a_Out[UBound($a_FirstDim)][1 + $iAdd_EmptyCol], $a_Line, $i_2DMax = 1 For $i = 0 To UBound($a_FirstDim) - 1 $a_Line = StringSplit($a_FirstDim[$i], $sDelim_Col, $STR_ENTIRESPLIT + $STR_NOCOUNT) If (Not $bExpand) And (Ubound($a_Line) <> $iKeep_NbCol) Then Return SetError(3, $i, 0) ; same error # as _FileReadToArray If UBound($a_Line) > $i_2DMax Then ; when $bExpand = False, this test will be True maximum 1 time, never more. $i_2DMax = UBound($a_Line) ReDim $a_Out[UBound($a_Out)][$i_2DMax + $iAdd_EmptyCol] EndIf For $j = 0 To UBound($a_Line) - 1 $a_Out[$i][$j] = $a_Line[$j] Next $a_Out[$i][$j] = _Get_ModelName($a_Line[4]) ; model name in last column added on the right Next Return $a_Out EndFunc ;==>_StringSplit2D_EX ;============================================== Func _Get_ModelName($iLine = ',,,,', $iRetunNoCountry = True) Local $aLine = StringSplit($iLine & ',,,,', ',', 3) If IsArray($aLine) Then StringReplace($iLine, ',', '') If (@extended < 2) Then If (StringLen($aLine[0]) > 1) And (StringLen($aLine[1]) > 1) Then ;ConsoleWrite('-0: ' & $aLine[0] & ' -1: ' & $aLine[1] & ' -2: ' & $aLine[2] & ' -3: ' & $aLine[3] & @CRLF) $iLine = StringReplace($aLine[0] & '_' & $aLine[1], ' ', '-') Return $iLine EndIf Else If (StringLen($aLine[1]) > 1) Then ;ConsoleWrite('-0: ' & $aLine[0] & ' -1: ' & $aLine[1] & ' -2: ' & $aLine[2] & ' -3: ' & $aLine[3] & @CRLF) $iLine = StringReplace($aLine[1], '_NA', '') If (StringStripWS($iLine, 8) <> '') Then If $iRetunNoCountry Then Return $iLine If StringInStr($aLine[2], 'Packing ASSY FCC') Then Return $iLine & '_FCC' ElseIf StringInStr($aLine[2], 'Packing ASSY US') Then Return $iLine & '_US' ElseIf StringInStr($aLine[2], 'Packing ASSY WW') Then Return $iLine & '_WW' ElseIf StringInStr($aLine[2], 'Packing ASSY EU') Then Return $iLine & '_EU' ElseIf StringInStr($aLine[2], 'Packing ASSY UK') Then Return $iLine & '_UK' Else Return $iLine EndIf EndIf Return '' EndIf EndIf EndIf EndFunc ;==>_Get_ModelName Apart from the "Lite_Data.txt" and the "Big_Data.txt" you provided in your 1st post, I attach below your example (with Tab separators) in a file named "OP example.txt", the famous example where results equal 140 OP example.txt1 point -
Help with data processing and reporting.
Trong reacted to AspirinJunkie for a topic
Ok, with the information I have refined the script a little so that it may come closer to your requirements. You can certainly do the fine-tuning yourself. #include "TableData.au3" ; Transfer data to table type - customize attribute names in the header to your needs $mData = _td_fromCsv("Big_Data.txt", @TAB, 0, "Attrib1|Attrib2|Attrib3|Model|Attrib5|Attrib6|Process|Quantity|Produced|Unproduced|Attrib11|Attrib12") ; filter the data so that only elements whose process begins with "FATP_" are retained $mData = _td_filter($mData, 'StringRegExp($x.Process, "^FATP_.*")') ; [optional] sort by model and process for a better overview _td_sort($mData, "__extractModel($x.Model) & $x.Process ") ; display data _td_display($mData, "Big_Data - filtered dataset") ;group by model and process - the example here attempts to extract the model from the model column and concat it with the process to form a group string For $aGroupData In _td_groupBy($mData, "__extractModel($x.Model) & ' | ' & $x.Process") ; Go through the individual groups and process them. Here you could do your sums or whatever ; convert the datasets to key-value maps where the keys are the attributes for better handling (access the values by attribute name instead of index number) $aGroup = _td_toObjects($aGroupData) ; calculate the sum over the "Produced" attribute for the current group $fSum = _td_reduce($aGroupData, "+ $x.Produced", 0) ; print the model, the process and the sum of produced units ConsoleWrite(StringFormat("%-27s %-18s: %5d\n", __extractModel($aGroup[0].Model), $aGroup[0].Process, $fSum)) Next ; auxiliary function to extract the model name from the total string in the 4th column. You will certainly have to adapt this to your needs Func __extractModel($sString) Local $aSplit = StringSplit($sString, ",", 3) If UBound($aSplit) < 2 Then Return $sString Return StringRegExpReplace($aSplit[1], '\h*_.+$', '') EndFunc1 point -
The Microsoft Windows Task Scheduler offers a lot of features. The two existing UDFs are a bit "complex" to use and miss help files and examples for each function. Based on a discussion on the german forum we would like to create a new UDF based on the existing "template" UDFs. Which functions do you miss in the existing UDFs? Should there be more examples? Should there be a help file? Should there be a wiki entry explaining the concepts? Which functions should be made easier to use? What else? Basic conditions Only Task Scheduler 2.0 will be supported (>= Windows Vista, Windows Server 2008). The UDF will use COM; neither AT.exe nor SCHTASKS.exe will be used. It will support as many of the objects and parameters as sensible. The UDF should be useable for everyone (beginners and experts) to suit their needs. Completed functions (fully documented including examples) - last changed: 2019-12-03 Planned functions (functions we are working on) - last changed: 2019-10-25 Suggested functions (we need to discuss if they schould be implemented) - last changed: 2025-01-25 Postponed functions (we will discuss this functions when the need arises) - last changed: 2019-09-301 point