Leaderboard
Popular Content
Showing content with the highest reputation since 05/06/2025 in all areas
-
_StringToTable() – Convert Text\array to a text formatted table The _StringToTable() function allows you to convert structured text (like tab-separated data), or array into a formatted, aligned table using Unicode box-drawing characters. Ideal for displaying readable output in console-based tools or logs. Example1: string to table Local $sData = _ "Company" & @TAB & "Contact" & @TAB & "Revenue" & @CRLF & _ "Alfreds Futterkiste" & @TAB & "Maria Anders" & @TAB & "1200" & @CRLF & _ "Centro Moctezuma" & @TAB & "Francisco Chang" & @TAB & "950" & @CRLF & _ "Island Trading" & @TAB & "Helen Bennett" & @TAB & "15800" ConsoleWrite(_StringToTable($sData, 3, @TAB, "L,C,R") & @CRLF) ┌──────────────────────┬───────────────────┬──────────┐ │ Company │ Contact │ Revenue │ ├──────────────────────┼───────────────────┼──────────┤ │ Alfreds Futterkiste │ Maria Anders │ 1200 │ │ Centro Moctezuma │ Francisco Chang │ 950 │ │ Island Trading │ Helen Bennett │ 15800 │ └──────────────────────┴───────────────────┴──────────┘ Example2: array to table ; Make example array Local $aArray[10][5] For $i = 0 To 9 For $j = 0 To 4 $aArray[$i][$j] = $i & "-" & $j Next Next ;_ArrayDisplay($aArray, "example array") ; Make header and insert to array (when needed) Local $sHeader = "Column 0|Column 1|Column 2|Column 3|Column 4" _ArrayInsert($aArray, 0, $sHeader) If @error Then Exit MsgBox(16, "@error: " & @error, "Something went wrong with _ArrayInsert()") Local $sOut = _StringToTable($aArray, 3, @TAB, "C,C,C,C,C") ConsoleWrite($sOut & @CRLF & @CRLF) ┌──────────┬──────────┬──────────┬──────────┬──────────┐ │ Column 0 │ Column 1 │ Column 2 │ Column 3 │ Column 4 │ ├──────────┼──────────┼──────────┼──────────┼──────────┤ │ 0-0 │ 0-1 │ 0-2 │ 0-3 │ 0-4 │ │ 1-0 │ 1-1 │ 1-2 │ 1-3 │ 1-4 │ │ 2-0 │ 2-1 │ 2-2 │ 2-3 │ 2-4 │ │ 3-0 │ 3-1 │ 3-2 │ 3-3 │ 3-4 │ │ 4-0 │ 4-1 │ 4-2 │ 4-3 │ 4-4 │ │ 5-0 │ 5-1 │ 5-2 │ 5-3 │ 5-4 │ │ 6-0 │ 6-1 │ 6-2 │ 6-3 │ 6-4 │ │ 7-0 │ 7-1 │ 7-2 │ 7-3 │ 7-4 │ │ 8-0 │ 8-1 │ 8-2 │ 8-3 │ 8-4 │ │ 9-0 │ 9-1 │ 9-2 │ 9-3 │ 9-4 │ └──────────┴──────────┴──────────┴──────────┴──────────┘ Example4: Example floating point format $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF $sOut = _StringToTable($sData, 3, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ┌──────────────────────┬──────────┬────────┬──────────┬───────────┬────────┬─────────┬────────┐ │ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range │ ├──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┤ │ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 │ │ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 │ │ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 │ │ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 │ │ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 │ └──────────────────────┴──────────┴────────┴──────────┴───────────┴────────┴─────────┴────────┘ Thanks to pixelsearch's magic filter on Regex pattern allowing the user to have the possibility to indicate not only [LRClrc] or [0-9] but also any valid StringFormat expression (starting with %). A big thank you to pixelsearch 🏆 for his contribution Made with ❤️ for readable and elegant output. ; https://www.autoitscript.com/forum/topic/212876-_stringtotable/ ;---------------------------------------------------------------------------------------- ; Title...........: _StringToTable.au3 ; Description.....: Converts a string to a formatted table with alignment and frame options. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.6 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Array.au3> #include <String.au3> Example1() ; Example string to table ;~ Example2() ; Example 2D array to table ;~ Example3() ; Example 1D array to table ;~ Example4() ; Example floating point format ;~ Example5() ; Example for new frame style ;~ Example6() ; Example StringFormat expression ;~ Example7() ; Example from clopboard ;--------------------------------------------------------------------------------------- Func Example1() ; Example string to table Local $sSum, $sOut Local $sData = _ "Company" & @TAB & "Contact" & @TAB & "Revenue" & @CRLF & _ "Alfreds Futterkiste" & @TAB & "Maria Anders" & @TAB & "1200" & @CRLF & _ "Centro Moctezuma" & @TAB & "Francisco Chang" & @TAB & "950" & @CRLF & _ "Island Trading" & @TAB & "Helen Bennett" & @TAB & "15800" $sOut = _StringToTable($sData, 0, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF $sOut = _StringToTable($sData, 1, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF $sOut = _StringToTable($sData, 2, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) $sSum &= $sOut & @CRLF & @CRLF & @CRLF $sSum &= "Notes: For the correct display of output, it is recommended to use a MonoSpace font." & @CRLF $sSum &= "Window MonoSpace font: Consolas, DejaVu Sans Mono, Courier New, Lucida Console" & @CRLF ClipPut($sSum) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example1 ;--------------------------------------------------------------------------------------- Func Example2() ; Example 2D array to table ; Make example array Local $aArray[10][5] For $i = 0 To 9 For $j = 0 To 4 $aArray[$i][$j] = $i & "-" & $j Next Next ;_ArrayDisplay($aArray, "example array") ; Make header and insert to array (when needed) Local $sHeader = "Column 0|Column 1|Column 2|Column 3|Column 4" _ArrayInsert($aArray, 0, $sHeader) If @error Then Exit MsgBox(16, "@error: " & @error, "Something went wrong with _ArrayInsert()") Local $sOut = _StringToTable($aArray, 3, -1, "C,C,C,C,C") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example2 ;--------------------------------------------------------------------------------------- Func Example3() ; Example 1D array to table Local $sMonth = "Months, January, February, March, April, May, June, July, August, September, October, November, December" Local $aMonth = StringSplit($sMonth, ", ", 3) Local $sOut = _StringToTable($aMonth, 3, -1, "C") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example3 ;--------------------------------------------------------------------------------------- Func Example4() ; Example floating point format Local $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF Local $sOut = _StringToTable($sData, 3, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example4 ;--------------------------------------------------------------------------------------- Func Example5() ; Example for new frame style Local $sData = "" ; from https://www.autoitscript.com/forum/topic/212833-json-udf-using-json-c/#findComment-1542670 $sData &= " name | time[ms] | factor | Std. Dev | Std. Err. | min | max | range |" & @CRLF $sData &= " StringRegExp only | 1.691 | 1 | 0.351 | 0.035 | 1.304 | 3.167 | 1.863 |" & @CRLF $sData &= " jq UDF | 32.933 | 19.48 | 2.929 | 0.293 | 29.308 | 43.169 | 13.861 |" & @CRLF $sData &= " JsonC-UDF | 51.086 | 30.21 | 3.205 | 0.321 | 45.625 | 63.46 | 17.835 |" & @CRLF $sData &= " pure AutoIt JSON-UDF | 97.916 | 57.9 | 5.685 | 0.569 | 86.362 | 113.467 | 27.105 |" & @CRLF $sData &= " JSMN-based JSON-UDF | 108.248 | 64.01 | 5.512 | 0.551 | 99.029 | 130.864 | 31.835 |" & @CRLF Local $sOut = _DblFrame($sData, "|", "L,3,2,3,3,3,3,3") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example5 ;--------------------------------------------------------------------------------------- Func Example6() ; Example StringFormat expression ; Make example array Local $aArray[10][6] For $i = 0 To 9 For $j = 0 To 5 $aArray[$i][$j] = $i & "." & $j If $j > 2 Then $aArray[$i][$j] = $i * 1000000 Next Next ;_ArrayDisplay($aArray, "example array") ; Make header and insert to array (when needed) Local $sHeader = "Column 0|Column 1|Column 2|Column 3|Column 4|Column 5" _ArrayInsert($aArray, 0, $sHeader) If @error Then Exit MsgBox(16, "@error: " & @error, "Something went wrong with _ArrayInsert()") ; accept any valid string format expression (starting with %) Local $sOut = _StringToTable($aArray, 3, -1, "%03i,2,3,0,%#08x,%06x") ConsoleWrite($sOut & @CRLF & @CRLF) ClipPut($sOut) ShellExecute("notepad.exe") WinWaitActive("[CLASS:Notepad]", "", 5) Sleep(100) Send("^v") EndFunc ;==>Example6 ;--------------------------------------------------------------------------------------- Func Example7() ; Example from clopboard ; ### First copy the following to the clipboard, and then run example 7 ### ;name time[ms] factor Std. Dev Std. Err. min max range ;StringRegExp only 1.691 1.00 0.351 0.035 1.304 3.167 1.863 ;jq UDF 32.933 19.48 2.929 0.293 29.308 43.169 13.861 ;JsonC-UDF 51.086 30.21 3.205 0.321 45.625 63.460 17.835 ;pure AutoIt JSON-UDF 97.916 57.90 5.685 0.569 86.362 113.467 27.105 ;JSMN-based JSON-UDF 108.248 64.01 5.512 0.551 99.029 130.864 31.835 Local $sData = ClipGet() Sleep(100) Local $sOut = _StringToTable($sData) ConsoleWrite($sOut & @CRLF & @CRLF) EndFunc ;==>Example7 ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _StringToTable ; Description....: Converts a string or array to a formatted table with alignment and frame options. ; Syntax.........: _StringToTable( $vString [, $iFrame = 2 [, $sSeparator = @TAB [, $sAlign = ""]]] ) ; Parameters.....: $vString - The input string or array containing data values. ; $iFrame - [optional] Frame type (0=NoFrame, 1=FrameNoHeader, 2=FrameAndHeader. (Default is 2) ; $sSeparator - [optional] Separator used in the input string. (Default is @TAB) ; $sAlign - [optional] Alignment options for each column "L,R,C,[0-9],[%..]". (Default is "" (left-aligned)) ; L=Left, R=Right, C=Center, [0-9]=digits after decimal point, [%..]=Any valid StringFormat(starting with %) ; Return values..: The formatted table as a string. ; Author ........: ioa747 ; Notes .........: For the correct display of output, it is recommended to use a MonoSpace font. ; Window MonoSpace font: Consolas, DejaVu Sans Mono, Courier New, Lucida Console ; Link ..........: https://www.autoitscript.com/forum/topic/212876-_stringtotable/ ; Dependencies...: __FormatCell() ;-------------------------------------------------------------------------------------------------------------------------------- Func _StringToTable($vString, $iFrame = 2, $sSeparator = @TAB, $sAlign = "") ;Local $hTimer = TimerInit() If $iFrame < 0 Or $iFrame > 2 Or $iFrame = Default Then $iFrame = 2 If $sSeparator = Default Or $sSeparator = -1 Then $sSeparator = @TAB ; Convert array to string If IsArray($vString) Then Local $b2D = (UBound($vString, 0) = 1 ? False : True) If Not $b2D Then _ArrayColInsert($vString, 1) $vString = _ArrayToString($vString, $sSeparator) EndIf ;Prepare string $vString = StringRegExpReplace($vString, "(\r\n|\n)", @CRLF) $vString = StringReplace($vString, $sSeparator & @CRLF, @CRLF) $vString = StringReplace($vString, @CRLF & $sSeparator, @CRLF) $vString = StringStripCR(StringRegExpReplace($vString, "(\r\n)$", "")) ;ConsoleWrite($vString & @CRLF) Local $aRows = StringSplit($vString, @LF, 1) If $aRows[0] = 0 Then Return SetError(1, 0, "") Local $aTable[UBound($aRows)][0] Local $iLen, $iCols = 0 ; initialize rows and columns For $i = 1 To $aRows[0] Local $aCols = StringSplit($aRows[$i], $sSeparator, 1) If $i = 1 Then $iCols = $aCols[0] ReDim $aTable[$aRows[0]][$iCols] Else If $aCols[0] < $iCols Then ReDim $aCols[$iCols + 1] ;** EndIf For $j = 0 To $iCols - 1 $aTable[$i - 1][$j] = StringStripWS($aCols[$j + 1], 3) Next Next ; find the max column widths Local $aColWidths[$iCols] For $j = 0 To $iCols - 1 $aColWidths[$j] = 0 For $i = 0 To UBound($aTable) - 1 $iLen = StringLen($aTable[$i][$j]) If $aColWidths[$j] < $iLen Then $aColWidths[$j] = $iLen Next Next ; Alignment initialize Local $aAlign[$iCols] If $sAlign <> "" Then Local $aFormat Local $aRawAlign = StringSplit($sAlign, ",", 2) Local $iRawCnt = UBound($aRawAlign) For $j = 0 To $iCols - 1 If $j >= $iRawCnt Then $aAlign[$j] = "L" Else $aAlign[$j] = StringStripWS($aRawAlign[$j], 3) $aFormat = StringRegExp($aAlign[$j], "^([LRClrc]|[0-9]|%[\-+0\x20#]?\d*(?:\.\d+)?[diouxXeEfgGs])$", 3) Select Case (Not IsArray($aFormat)) Or UBound($aFormat) > 1 $aAlign[$j] = "L" Case StringIsAlpha($aFormat[0]) ; LRClrc => nothing to do Case Else ; 0-9 OR %... (StringFormat indicated by user) ; re-find the max column widths For $i = 0 To UBound($aTable) - 1 $iLen = StringLen(StringFormat( _ (StringIsDigit($aFormat[0]) ? ("%." & $aAlign[$j] & "f") : $aAlign[$j]), _ $aTable[$i][$j])) If $iLen > $aColWidths[$j] Then $aColWidths[$j] = $iLen Next EndSelect EndIf Next Else For $j = 0 To $iCols - 1 $aAlign[$j] = "L" Next EndIf Local Const $TL = "┌", $TR = "┐", $BL = "└", $BR = "┘", $H = "─", $V = "│", _ $C = "┼", $TH = "┬", $CH = "┴", $LH = "├", $RH = "┤" Local $bHeader = ($iFrame = 2) Local $bBorder = ($iFrame = 1 Or $iFrame = 2) Local $sPre = ($iFrame = 0 ? "" : " ") Local $sResult = "" ; Top border If $bBorder Then $sResult &= $TL For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) $sResult &= ($j < $iCols - 1) ? $TH : $TR Next $sResult &= @LF EndIf ; Header row If $bHeader Then $sResult &= $V For $j = 0 To $iCols - 1 $sResult &= $sPre & __FormatCell($aTable[0][$j], $aColWidths[$j], $aAlign[$j]) & " " If $j < $iCols - 1 Then $sResult &= $V Next $sResult &= $V & @LF ; Header separator $sResult &= $LH For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) $sResult &= ($j < $iCols - 1 ? $C : $RH) Next $sResult &= @LF EndIf ; Data rows For $i = ($bHeader ? 1 : 0) To UBound($aTable) - 1 If $bBorder = 2 Then $sResult &= $V For $j = 0 To $iCols - 1 $sResult &= $sPre & __FormatCell($aTable[$i][$j], $aColWidths[$j], $aAlign[$j]) & " " If $j < $iCols - 1 Then $sResult &= $bBorder ? $V : "" Next If $bBorder Then $sResult &= $V $sResult &= @LF Next ; Bottom border If $bBorder Then $sResult &= $BL For $j = 0 To $iCols - 1 $sResult &= _StringRepeat($H, $aColWidths[$j] + 2) $sResult &= ($j < $iCols - 1) ? $CH : $BR Next EndIf ;$sResult = BinaryToString(StringToBinary($sResult, 4), 1) ; * ?? ;ConsoleWrite("> processed in: " & Round(TimerDiff($hTimer)) & " ms " & @LF) Return $sResult EndFunc ;==>_StringToTable ;--------------------------------------------------------------------------------------- Func __FormatCell($text, $width, $align) ; internal Switch $align Case "L" Return StringFormat("%-" & $width & "s", $text) Case "R" Return StringFormat("%" & $width & "s", $text) Case "C" Local $pad = $width - StringLen($text) Local $left = Floor($pad / 2) Local $right = $pad - $left Return _StringRepeat(" ", $left) & $text & _StringRepeat(" ", $right) Case Else ; 0-9 OR %... (StringFormat indicated by user) If StringRegExp($text, "^[+\-]?(\d*\.\d+|\d+\.?)$") Then ; numeric column (data) Return StringFormat("%" & $width & "s", StringFormat( _ (StringIsDigit($align) ? ("%." & $align & "f") : $align), _ $text)) Else ; numeric column (header) align header usually to right (or to left if "%-" found) Return StringFormat("%" & _ ((StringLeft($align, 2) = "%-") ? "-" : "") & _ $width & "s", $text) EndIf EndSwitch EndFunc ;==>__FormatCell ;--------------------------------------------------------------------------------------- Func _DblFrame($vString, $sSeparator = @TAB, $sAlign = "") ; * style template Local $sData = _StringToTable($vString, 3, $sSeparator, $sAlign) Local $aData = StringSplit($sData, @LF, 3) Local $iCnt = UBound($aData) - 1 Local $sOut For $i = 0 To $iCnt Switch $i Case 0 $aData[$i] = StringReplace($aData[$i], "┌", "╔", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┬", "╤", 0, 2) $aData[$i] = StringReplace($aData[$i], "┐", "╗", -1, 2) Case 2 $aData[$i] = StringReplace($aData[$i], "├", "╟", 1, 2) $aData[$i] = StringReplace($aData[$i], "┤", "╢", -1, 2) Case $iCnt $aData[$i] = StringReplace($aData[$i], "└", "╚", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┴", "╧", 0, 2) $aData[$i] = StringReplace($aData[$i], "┘", "╝", -1, 2) Case Else $aData[$i] = StringReplace($aData[$i], "│", "║", 1, 2) $aData[$i] = StringReplace($aData[$i], "│", "║", -1, 2) EndSwitch $sOut &= $aData[$i] & @CRLF Next $sOut = StringReplace($sOut, @CRLF, "", -1, 2) Return $sOut EndFunc ;==>_DblFrame ;--------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much Relative: https://www.autoitscript.com/forum/topic/211237-treestructuredir/11 points
-
_StringToTable
WildByDesign and 3 others reacted to ioa747 for a topic
I agree with argumentum above, it's easier to do everything with double lines, than just the outline. Adding more frame types, requires more nested if, then , which has implications for all frame types. I'm thinking of removing frame =2 as well, right now it doesn't seem appealing to me, it will reduce both response time and readability of the script. as well However, the idea is not bad, and it's nice to get what you want. For this (and for the coding challenge) in the next version I will put a helper function that will do it. Which, (those reading) can have by now #include <Array.au3> #include <String.au3> _test() ;--------------------------------------------------------------------------------------- Func _test() Local $sTxt, $sOut Local $sData = _ "Company" & @TAB & "Contact" & @TAB & "Revenue" & @CRLF & _ "Alfreds Futterkiste" & @TAB & "Maria Anders" & @TAB & "1200" & @CRLF & _ "Centro Moctezuma" & @TAB & "Francisco Chang" & @TAB & "950" & @CRLF & _ "Island Trading" & @TAB & "Helen Bennett" & @TAB & "15800" $sOut = _DblFrame($sData, @TAB, "L,C,R") ConsoleWrite($sOut & @CRLF & @CRLF) EndFunc ;==>_test ;--------------------------------------------------------------------------------------- Func _DblFrame($vString, $sSeparator = @TAB, $sAlign = "") Local $sData = _StringToTable($vString, 3, $sSeparator, $sAlign) Local $aData = StringSplit($sData, @LF, 3) Local $iCnt = UBound($aData) -1 Local $sOut For $i = 0 To $iCnt Switch $i Case 0 $aData[$i] = StringReplace($aData[$i], "┌", "╔", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┬", "╤", 0, 2) $aData[$i] = StringReplace($aData[$i], "┐", "╗", -1, 2) Case 2 $aData[$i] = StringReplace($aData[$i], "├", "╟", 1, 2) $aData[$i] = StringReplace($aData[$i], "┤", "╢", -1, 2) Case $iCnt $aData[$i] = StringReplace($aData[$i], "└", "╚", 1, 2) $aData[$i] = StringReplace($aData[$i], "─", "═", 0, 2) $aData[$i] = StringReplace($aData[$i], "┴", "╧", 0, 2) $aData[$i] = StringReplace($aData[$i], "┘", "╝", -1, 2) Case Else $aData[$i] = StringReplace($aData[$i], "│", "║", 1, 2) $aData[$i] = StringReplace($aData[$i], "│", "║", -1, 2) EndSwitch $sOut &= $aData[$i] & @CRLF Next Return $sOut EndFunc ;==>_DblFrame4 points -
_StringToTable
Musashi and 3 others reacted to SOLVE-SMART for a topic
First of all and to clarify: I don't see this as a competition - just in case you folks would think of this regarding @ioa747 and me 😆 . I agree. I guess extending the border styles (frame types) is just a gimmick. Nevertheless, I played a bit with my version of DataToTable.au3 which lead to v0.2.0. In the README.md section output-result you can see a fourth border style "4=BorderAndHeaderEdgesWithAccent" as a example. In the CHANGELOG.md you will find how I changed it. To achieve the styling above (shared by @argumentum) it would lead to some more code adjustments, but at the moment I don't have the desire to implement it - sorry @WildByDesign 😅 . Best regards Sven4 points -
Uploaded an updated Beta version of SciTE zipfiles containing a fix for the lexer colors.3 points
-
_StringToTable
pixelsearch and 2 others reacted to ioa747 for a topic
Thanks to pixelsearch's magic filter on Regex pattern allowing the user to have the possibility to indicate not only [LRClrc] or [0-9] but also any valid StringFormat expression (starting with %). A big thank you to pixelsearch 🏆 for his contribution3 points -
2025-May-18, Changelog v17 > v18 Updated - Ported SMF to x64 Info - Some DLLs like 7Zip, TRiD and some hashes only work in the x86 version Fixed - Long-standing startup bug be gone (hopefully) Updated - Improved visual experience of report, it now runs much more smoothly Updated - Implemented @UEZ's excellent WEBP UDF for icons and thumbnails Info - WEBP now preferred image format (good compression and supports transparency) Updated - Report icons and thumbnails now cached by default (as WEBP) Updated - Added encryption for cached thumbnails and icons Updated - Lots of other small bug fixes and style changes Source and Executable are available at https://funk.eu Best Regards Updated first Post... Enjoy ...3 points
-
UDF "data-to-table.au3"
mLipok and 2 others reacted to SOLVE-SMART for a topic
data-to-table.au3 UDF Description This library (UDF) allows you to transform input data, like strings or arrays, to a nice readable table output with different border styles and aligned table cell content. Output your data to console, file or GUI. 👉 Please check out the upcoming features section. Acknowledgements The UDF is highly inspired by the great UDF "StringToTable.au3" by @ioa747 . Thank you! Forum thread link: https://www.autoitscript.com/forum/topic/212876-_stringtotable/ All credits for the original logic go to @ioa747 who made the UDF with ❤️ for a readable and elegant output. Input ==> Output From string ... ; The $sData string is separated (columns) by tabs. Local Const $sData = _ 'Language Popularity (%) Job Demand Typical Use' & @CRLF & _ 'JavaScript 62.3 Very High Web Development, Frontend/Backend' & @CRLF & _ 'C# 27.1 High Game Development, Windows Apps, Web Dev' & @CRLF & _ 'Go 13.8 Growing Cloud Services, System Programming' & @CRLF & _ 'PowerShell 13.5 Low to Moderate Task Automation, DevOps, System Admin' & @CRLF & _ 'AutoIt 0.5 Low Windows GUI Automation, Scripting' ... or array ... ; Default separator is @TAB. Local Const $aData[][5] = _ [ _ ['Language', 'Popularity (%)', 'Job Demand', 'Typical Use' ], _ ['JavaScript', '62.3', 'Very High', 'Web Development, Frontend/Backend' ], _ ['C#', '27.1', 'High', 'Game Development, Windows Apps, Web Dev' ], _ ['Go', '13.8', 'Growing', 'Cloud Services, System Programming' ], _ ['PowerShell', '13.5', 'Low to Moderate', 'Task Automation, DevOps, System Admin' ], _ ['AutoIt', '0.5', 'Low', 'Windows GUI Automation, Scripting' ] _ ] ... to ... ╔────────────┬────────────────┬─────────────────┬─────────────────────────────────────────╗ │ Language │ Popularity (%) │ Job Demand │ Typical Use │ ├────────────┼────────────────┼─────────────────┼─────────────────────────────────────────┤ │ JavaScript │ 62.3 │ Very High │ Web Development, Frontend/Backend │ │ C# │ 27.1 │ High │ Game Development, Windows Apps, Web Dev │ │ Go │ 13.8 │ Growing │ Cloud Services, System Programming │ │ PowerShell │ 13.5 │ Low to Moderate │ Task Automation, DevOps, System Admin │ │ AutoIt │ 0.5 │ Low │ Windows GUI Automation, Scripting │ ╚────────────┴────────────────┴─────────────────┴─────────────────────────────────────────╝ ... or other border styles (see below). Links of interest 👀 README ✨ the UDF (library) 🏃♂️ usage example 📑 CHANGELOG 🚀 Latest release Border styles Contribution, BUGs, issues, suggestions, wishes via GitHub issues / GitHub pull requests and/or here in the forum (also fine) Support give the project a ⭐ on GitHub follow me there come up with questions, suggestions, wishes 😀 Licenses Distributed under the MIT License. So don't worry and do whatever you want with it 😀 . -------------- Best regards Sven3 points -
_StringToTable
SOLVE-SMART and 2 others reacted to argumentum for a topic
Now this looks better: ╭──────────────────────┬──────────┬────────┬──────────┬───────────┬────────┬─────────┬────────╮ │ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range │ ├──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┤ │ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 │ │ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 │ │ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 │ │ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 │ │ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 │ ╰──────────────────────┴──────────┴────────┴──────────┴───────────┴────────┴─────────┴────────╯ with round corners ( mac / win11 style ) Joke aside, about making the char(s) an array and use the "set" array so the whole code don't have to change because someone came up with something "new" ? ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ █ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range █ █══════════════════════╪══════════╪════════╪══════════╪═══════════╪════════╪═════════╪════════█ █ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 █ █ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 █ █ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 █ █ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 █ █ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 █ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ ┏━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━━━━┯━━━━━━━━┯━━━━━━━━━┯━━━━━━━━┓ ┃ name │ time[ms] │ factor │ Std. Dev │ Std. Err. │ min │ max │ range ┃ ┠──────────────────────┼──────────┼────────┼──────────┼───────────┼────────┼─────────┼────────┨ ┃ StringRegExp only │ 1.691 │ 1.00 │ 0.351 │ 0.035 │ 1.304 │ 3.167 │ 1.863 ┃ ┃ jq UDF │ 32.933 │ 19.48 │ 2.929 │ 0.293 │ 29.308 │ 43.169 │ 13.861 ┃ ┃ JsonC-UDF │ 51.086 │ 30.21 │ 3.205 │ 0.321 │ 45.625 │ 63.460 │ 17.835 ┃ ┃ pure AutoIt JSON-UDF │ 97.916 │ 57.90 │ 5.685 │ 0.569 │ 86.362 │ 113.467 │ 27.105 ┃ ┃ JSMN-based JSON-UDF │ 108.248 │ 64.01 │ 5.512 │ 0.551 │ 99.029 │ 130.864 │ 31.835 ┃ ┗━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━━━━┷━━━━━━━━┷━━━━━━━━━┷━━━━━━━━┛ and what I would call "24 pin dot matrix"3 points -
_StringToTable
Musashi and 2 others reacted to WildByDesign for a topic
My initial thought with this was to make some elegant and beautiful MsgBox's, particularly About dialogs, etc. But I realized that the output from _stringtotable simply wasn't lining up properly in a MsgBox. So I decided try it with the ExtMsgBox UDF since it has more customizing options. That also came up all scrambled. Until... I realized that I would need to use a monospaced font like in other projects. Cascadia Mono didn't look as nice. So I did Consolas and it looked great. Basically, the following code was added: #include "ExtMsgBox.au3" _ExtMsgBoxSet(1, 4, 0x202020, 0xe0e0e0, -1, "Consolas", 1200, 1200) _ExtMsgBox (0, 0, "_ExtMsgBox", $sOut) The _ExtMsgBox (0, 0, "_ExtMsgBox", $sOut) just needed to be adapted into the right area of examples, of course. Screenshots: So this opens up some nice possibilities for my usage of it. Thanks again for sharing this. Also, @SOLVE-SMART I am going to follow your progress on this as well.3 points -
I don't know if you remember, or even if I wrote about it in general on the open forum or in private chats with @Jos, but In the past I had big problems with performance on most of my projects. After replacing the computer a few years ago, from i7 3gen to a brand new DELL I5 10Gen with an NVME (Micron) drive, the problems were partially solved. The last few months were a surprise to me because I felt an unexpected, significant drop in performance (switching between different files in SciTE took me up to a dozen or so seconds). I was really pissed off. As it turned out, it was all the fault of a weak FLASH PENDRIVE drive (that's how I had my projects). Interestingly, there must have been some changes in the file subsystems or in Antiviruses, because even transferring from USB FLASH to the original DELL NVME (Micron) didn't improve the situation. A month ago I got pissed off. Using the AS SSD Benchmark tool, I performed performance tests for: USB PENDRIVE, NVME (Micron) and a regular Samsung 960 256GB NVME drive (not the PRO version) and bought a new fast Samsung 980 PRO 1TB NVME drive After installing and mirroring the system (without fresh installation), everything started working almost in the blink of an eye I'll just say that currently my new NVME is almost 10 times faster than the USB PENDRIVE and about 3 times faster than the old NVME drive (Micron). Interestingly, I wanted to continue working with the USB Pendrive, so that I could work on a portable development environment at the client's site. I looked for statistics at https://ssd-tester.pl/pendrive_test.php I bought a fast PENDRIVE and as a result, my portable work environment also works fast enough not to get frustrated. I just wanted to end this story with a happy ending by saying that my performance problem in the context of the Dynamic Lua feature only occurred to me because my INCLUDE file set contains 265 non-standard UDFs + 149 Standard AutoIt UDF files, so a total of 414 AU3 files to track by Dynamic LUA script invocation. However, if your non-standard UDF set is small, you should not have any performance problems. And if someone has a problem with the speed of operation, I recommend working on the performance of your system, with particular attention to the disk speed. Regardless of the adventures I've had, writing advanced scripts has become easier, especially if they're based on many different, often constantly modified UDFs. So I'm currently happy with how Dynamic Lua feature works, and grateful for the work @Jos put in SciTE4AutoIt.2 points
-
Thank you, I feel better day by day.2 points
-
DwmColorBlurMica
Parsix and one other reacted to WildByDesign for a topic
This script is evolving quite rapidly, therefore changes will be ongoing. This is inspired by the Great @argumentum and Win11myOwnBorderColor as much of the framework comes from that script. Note: This is for Windows 11 build 22621+ Using that script as a basis, I have since: Added separate variable for title bar color Added the ability to change window corner preference (eg. rounded corners, square corners, etc.) Added the ability to extend the frame into the client area Added ability to apply backdrop material (eg. Mica, Acrylic, Mica Alt (Tabbed), etc.) Fixed child windows not having colors applied (changed to SetWinEventHook) TO DO list at top of script of stuff that I still need to add At the moment, the script is running without Admin, therefore will only apply to user-mode apps. If you want to apply to all apps, remove the comment before #RequireAdmin. Eventually, I am going to add the ability to create a scheduled task (like Win11myOwnBorderColor already does). I already have an AutoIt tray tool, so I will probably integrate this into my other tray tool. I may keep it as a separate executable which would then be run as a scheduled task. Problems: If you run into any problems with any apps, you can press Esc key to close DwmColorBlurMica and any apps that were not happy with it, simply restart them. I have excluded some apps in the script, such as Explorer and Start menu. But I still need to work on an exclusion list (and maybe inclusion list) that is either in the INI file or other file. I would like to be able to eventually load those into an array at some point. Hotkey WinKey + Esc will exit the program and undo all changes made except DwmExtendFrameIntoClientArea. Features: Change border color to any color Change title bar color to any color Enable dark mode app settings (particularly dark mode title bar) Apply backdrop material (eg. Mica, Acrylic, Mica Alt (Tabbed), etc.) to the title bar Applies settings to all currently running windows and new windows Extend title bar color and materials to client area * * Please note that the extending of color and materials to client area (DwmExtendFrameIntoClientArea) works best with pure dark themes. For example, Rectify11's Black (Mica) theme. Also, some apps simply don't work well with it. It is a feature that really should be Opt-in per process which is something that I still need to implement. The possibilities (especially when mixing some of these options) are almost endless. The screenshots below only show a small amount of what is possible. Screenshots: Changelog: Current script version: 0.9 DwmColorBlurMica-0.9-Source.7z2 points -
Try: #include <WinAPISys.au3> $t = _WinAPI_GetStartupInfo() $tP = DllStructCreate("wchar title[255]", $t.Title) ConsoleWrite($tP.title & @CRLF) I was too slow...2 points
-
2 points
-
I divide the project into parts for easier management. The project is in early beta stage, for research and development. 🚀 AI_Assistant.au3 which is included in SciTE_AI_Assistant.au3, but can also be used as a standalone UDF in which I #include "StringSize.au3" ; "https://www.autoitscript.com/forum/topic/114034-stringsize-m23-bugfix-version-27-dec-23" by Melba23 - thanks for that So that it folds the console output, and is visible within its boundaries (especially when it is on the side and is slim) for more comfortable reading works directly with the ollama. I use a small models qwen2.5-coder:3b as default, llama3.2:3b , phi4-mini:3.8b so that I don't have to wait too long for a response. However, I have set as a parameter which model it calls, so that it changes the model per job if necessary AI_Assistant.au3 #include-once ; #INDEX# ======================================================================================================================= ; Title .........: AI_Assistant.au3 ; AutoIt Version : v3.3.16.1 or higher ; Language ......: English ; Description ...: AI assistant - Need Ollama installed (https://ollama.com/download) ; Remarks .......: Recommended small models: llama3.2:3b , qwen2.5-coder:3b (https://ollama.com/library) ; Note ..........: Script Version: 0.10 Testet in Win10 22H2 ; Author(s) .....: ioa747 ; Link ..........: https://www.autoitscript.com/forum/topic/212888-scite-ai-assistant ; =============================================================================================================================== ;~ #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ; #INCLUDES# ==================================================================================================================== #include "StringSize.au3" ;"https://www.autoitscript.com/forum/topic/114034-stringsize-m23-bugfix-version-27-dec-23" ; #GLOBAL VARIABLES# ============================================================================================================ Global $g__AI_DebugInfo = False ; True = debug info * <-- _AI_DebugInfo(True\False) Global $g__AI_ObjErr = ObjEvent("AutoIt.Error", "__AI_ObjAutoItErrorEvent") ; #FUNCTION# ==================================================================================================================== ; Name...........: _AI_Call ; Description....: Call the AI model with given prompt, assistant, system, endpoint, temperature, and seed. ; Syntax.........: _AI_Call( $sPrompt [, $sAssistant = "llama3.2:3b" [, $sSystem = "You are a helpful assistant" [, $iEndpoint = 1 [, $fTemperature = 0.3 [, $iSeed = 0]]]] ) ; Parameters.....: $sPrompt - The prompt to be sent to the AI model. ; $sAssistant - [optional] The name of the AI model. (Default is "llama3.2:3b") ; $sSystem - [optional] The system instruction provided by the user. (Default is "You are a helpful assistant.") ; $iEndpoint - [optional] The API endpoint to use. (1 for /api/chat, 2 for /api/generate) ; $fTemperature - [optional] The temperature value for the AI model's output. (Default is 0.3) ; $iSeed - [optional] The seed value for the AI model's response. (Default is 0) ; Return values .: Success: Returns the output from the AI model. ; Failure: Sets @error and returns an empty string with a custom message. ; @error = 13: Invalid endpoint specified. Must be 1 or 2. ; Author ........: ioa747 ; Modified ......: ; Remarks .......: This function sends a request to the AI model API using WinHttp. ; Related .......: None ; Link ..........: ; Example .......: _AI_Call("What is your name?", "llama3.2:3b", "You are an AI assistant.") ; =============================================================================================================================== Func _AI_Call($sPrompt, $sAssistant = "llama3.2:3b", $sSystem = "You are a helpful assistant", $iEndpoint = 1, $fTemperature = 0.3, $iSeed = 0) If $sAssistant = "" Or $sAssistant = -1 Or $sAssistant = Default Then $sAssistant = "llama3.2:3b" If $sSystem = "" Or $sSystem = -1 Or $sSystem = Default Then $sSystem = "You are a helpful assistant" If $fTemperature = "" Or $fTemperature = -1 Or $fTemperature = Default Then $fTemperature = 0.3 If $iSeed = "" Or $iSeed = -1 Or $iSeed = Default Then $iSeed = 0 ToolTip("AI Processing...", @DesktopWidth - 90, @DesktopHeight - 60) Local $sOut, $iError Local $hTimer = TimerInit() If $iEndpoint = 1 Then ; Endpoint to /api/chat $sOut = __AI_ToChat($sPrompt, $sAssistant, $sSystem, $fTemperature, $iSeed) If @error Then $iError = @error ElseIf $iEndpoint = 2 Then ; Endpoint to /api/generate $sOut = __AI_ToGenerate($sPrompt, $sAssistant, $sSystem, $fTemperature, $iSeed) If @error Then $iError = @error Else $sOut = "! @error: _AI_Call() => $iEndpoint out of range (1=chat, 2=Generate)" SetError(13) EndIf ToolTip("") If $iError Then Return SetError($iError, 0, ($iEndpoint = 1 ? "/api/chat: " : "/api/generate: ") & $sOut) Else If $g__AI_DebugInfo Then Return "> " & $sAssistant & " processed in: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds " & @CRLF & $sOut Else Return $sOut EndIf EndIf EndFunc ;==>_AI_Call ; #FUNCTION# ==================================================================================================================== ; Name ..........: _AI_CW ; Description ...: Adjusts the text size in a SciTE console window to fit within its boundaries. ; Syntax ........: _AI_CW($sText) ; Parameters ....: $sText - The text to ConsoleWrite ; Return values .: Success: None (Write the adjustsed $sText to the SciTE Console). ; Failure: None (bypass adjusts the text size). ; @error = 1: An error occurred during font sizing, but processing continues. ; Author ........: ioa747 ; Modified ......: ; Remarks .......: Skip adjusts the text size, between triple backticks (```) block. ; Related .......: using the StringSize.au3 UDF from Melba23 ; Link ..........: https://www.autoitscript.com/forum/topic/114034-stringsize-m23-bugfix-version-27-dec-23 ; Example .......: _AI_CW("Adjusts the text size in a SciTE console window to fit within its boundaries.") ; =============================================================================================================================== Func _AI_CW($sText) Local $aPos = ControlGetPos("[CLASS:SciTEWindow]", "", "Scintilla2") Local $sNewText, $aStrSZ Local $aText = StringSplit($sText, '```', 1) ; _StringSize fit only no code part For $i = 1 To $aText[0] If Mod($i, 2) = 0 Then $sNewText &= "```" & $aText[$i] & "```" Else $aStrSZ = _StringSize($aText[$i], 11, Default, Default, "Cascadia Code", $aPos[2]) If @error Then $sNewText &= $aText[$i] Else $sNewText &= $aStrSZ[0] EndIf EndIf Next ConsoleWrite($sNewText) EndFunc ;==>_AI_CW ; #FUNCTION# ==================================================================================================================== ; Name...........: _AI_DebugInfo ; Description....: Enables or disables debug information output. ; Syntax.........: _AI_DebugInfo( [$bEnable] ) ; Parameters.....: $bEnable - [optional] True to enable debugging, False to disable (Default is True). ; Return values .: Success: None. ; Failure: None. ; Author ........: ioa747 ; Modified ......: ; Remarks .......: This function controls whether debug information is displayed in the console or not. ; Related .......: ; Link ..........: ; Example .......: _AI_DebugInfo(True) to enable debugging. ; =============================================================================================================================== Func _AI_DebugInfo($bEnable = True) $g__AI_DebugInfo = $bEnable EndFunc ;==>_AI_DebugInfo #Region ; === Internal use Functions === Func __AI_ToChat($sPrompt, $sAssistant = -1, $sSystem = -1, $fTemperature = -1, $iSeed = -1) ; Sets default values If $sSystem = "" Or $sSystem = -1 Or $sSystem = Default Then $sSystem = "You are a helpful assistant" If $sAssistant = "" Or $sAssistant = -1 Or $sAssistant = Default Then $sAssistant = "llama3.2:3b" If $fTemperature = "" Or $fTemperature = -1 Or $fTemperature = Default Then $fTemperature = 0.3 If $iSeed = "" Or $iSeed = -1 Or $iSeed = Default Then $iSeed = 0 ; Avoiding problems with special characters in JSON __AI_Json_EscapeString($sAssistant) __AI_Json_EscapeString($sSystem) __AI_Json_EscapeString($sPrompt) ; Creating the JSON request payload /api/chat Local $sRequest = '{' $sRequest &= '"model": "' & $sAssistant & '", ' $sRequest &= '"messages": [' $sRequest &= '{"role": "system", "content": "' & $sSystem & '"},' $sRequest &= '{"role": "user", "content": "' & $sPrompt & '"}' $sRequest &= '], ' $sRequest &= '"stream": false, ' $sRequest &= '"temperature": ' & $fTemperature & ', ' $sRequest &= '"seed": ' & $iSeed $sRequest &= '}' __AI_DW("$sRequest=>" & $sRequest & @CRLF) ; _FileWriteLog(@ScriptDir & "\SciTE_AI_Assistant.log", $sRequest) ; debugging ; Create HTTP Request object Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") ; ResolveTimeout: 5 sec ; ConnectTimeout: 10 sec ; SendTimeout: 60 sec ; ReceiveTimeout: 120 sec $oHttp.SetTimeouts(5000, 10000, 60000, 120000) ; Endpoint to /api/chat $oHttp.Open("POST", "http://localhost:11434/api/chat", False) ; <-- localhost:11434 $oHttp.SetRequestHeader("Content-Type", "application/json") $oHttp.Send($sRequest) If @error Then Return SetError(1, 0, "Error: " & @error & ", Extended: " & @extended & " during HttpSend operation.") ; Check if request was successful If $oHttp.Status <> 200 Then Local $aErr = __AI_HTTP_STATUS_CODES($oHttp.Status) Return SetError(2, 0, $oHttp.ResponseText & " => " & $oHttp.Status & ": " & $aErr[1] & " " & $aErr[2]) EndIf ; Get the answer Local $sResponse = $oHttp.ResponseText __AI_DW("$sResponse=>" & $sResponse & @CRLF) ; Parse response => suporting value: .model, .created_at, .role, .content, .done_reason Local $mJson = __AI_Json_Map($sResponse) ; Access the content of the response ($mJson.content) If Not MapExists($mJson, "content") Then MsgBox(16, "AskToAI() l: " & @ScriptLineNumber, "__JsonMap() fail to find 'content' in response") Return SetError(2, 0, "__JsonMap() fail to find 'content' in response") EndIf $sResponse = $mJson.content Return $sResponse EndFunc ;==>__AI_ToChat ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_ToGenerate($sPrompt, $sAssistant = -1, $sSystem = -1, $fTemperature = -1, $iSeed = -1) ; Sets default values If $sSystem = "" Or $sSystem = -1 Or $sSystem = Default Then $sSystem = "You are a helpful assistant" If $sAssistant = "" Or $sAssistant = -1 Or $sAssistant = Default Then $sAssistant = "llama3.2:3b" If $fTemperature = "" Or $fTemperature = -1 Or $fTemperature = Default Then $fTemperature = 0.3 If $iSeed = "" Or $iSeed = -1 Or $iSeed = Default Then $iSeed = 0 __AI_Json_EscapeString($sAssistant) __AI_Json_EscapeString($sSystem) __AI_Json_EscapeString($sPrompt) Local $sRequest = '{' $sRequest &= '"model": "' & $sAssistant & '", ' $sRequest &= '"system": "' & $sSystem & '", ' $sRequest &= '"prompt": "' & $sPrompt & '", ' $sRequest &= '"stream": false, ' $sRequest &= '"temperature": ' & $fTemperature & ', ' $sRequest &= '"seed": ' & $iSeed $sRequest &= '}' __AI_DW("$sRequest=>" & $sRequest & @CRLF) ;_FileWriteLog(@ScriptDir & "\SciTE_AI_Assistant.log", $sRequest) ; Endpoint to /api/generate Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") ; ResolveTimeout: 5 sec ; ConnectTimeout: 10 sec ; SendTimeout: 30 sec ; ReceiveTimeout: 120 sec $oHttp.SetTimeouts(5000, 10000, 30000, 120000) $oHttp.Open("POST", "http://localhost:11434/api/generate", False) $oHttp.SetRequestHeader("Content-Type", "application/json") $oHttp.Send($sRequest) If @error Then Return SetError(1, 0, "Error: " & @error & ", Extended: " & @extended & " during HttpSend operation.") ; Check if request was successful If $oHttp.Status <> 200 Then Local $aErr = __AI_HTTP_STATUS_CODES($oHttp.Status) Return SetError(2, 0, $oHttp.ResponseText & " => " & $oHttp.Status & ": " & $aErr[1] & " " & $aErr[2]) EndIf Local $sResponse = $oHttp.ResponseText __AI_DW("$sResponse=>" & $sResponse & @CRLF) ; Parse response => suporting value: .model ; .created_at ; .response ; .done_reason Local $mJson = __AI_Json_Map($sResponse) ; __AI_DW("$mJson.response=" & $mJson.response & @CRLF) ; For /api/generate, the response is usually in .response If Not MapExists($mJson, "response") Then MsgBox(16, "AskToAI_FIM() l: " & @ScriptLineNumber, "_JsonMap() fail to find 'response'") Return SetError(2, 0, "_JsonMap() fail to find 'response'") EndIf $sResponse = $mJson.response Return $sResponse EndFunc ;==>__AI_ToGenerate ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_Json_EscapeString(ByRef $sString) ;=== Converts normal string to a JSON-safe string === ; Escape backslashes first to avoid double-processing $sString = StringReplace($sString, '\', '\\', 0, 1) ; Escape known JSON control characters $sString = StringReplace($sString, Chr(8), '\b', 0, 1) ; Backspace $sString = StringReplace($sString, Chr(12), '\f', 0, 1) ; Formfeed $sString = StringReplace($sString, @CRLF, '\n', 0, 1) ; CRLF → \n $sString = StringReplace($sString, @LF, '\n', 0, 1) ; LF → \n $sString = StringReplace($sString, @CR, '\r', 0, 1) ; CR → \r $sString = StringReplace($sString, @TAB, '\t', 0, 1) ; Tab → \t ; Escape double quotes $sString = StringReplace($sString, '"', '\"', 0, 1) ; Escape \u00XX characters ; nothing yet ; Strip_ControlChars (< 32) For $i = 0 To 31 Switch $i Case 8, 9, 10, 12, 13 ; Already handled above Case Else $sString = StringReplace($sString, Chr($i), "") EndSwitch Next Return $sString EndFunc ;==>__AI_Json_EscapeString ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_Json_UnEscapeString(ByRef $sString) ;=== Converts a JSON-escaped string back into normal string === If StringInStr($sString, '\') = 0 Then Return $sString ; Unescape quotes and backslashes first $sString = StringReplace($sString, '\"', '"', 0, 1) $sString = StringReplace($sString, '\\', '\', 0, 1) ; Unescape standard control characters $sString = StringReplace($sString, '\b', Chr(8), 0, 1) $sString = StringReplace($sString, '\f', Chr(12), 0, 1) $sString = StringReplace($sString, '\n', @LF, 0, 1) $sString = StringReplace($sString, '\r', @CR, 0, 1) $sString = StringReplace($sString, '\t', @TAB, 0, 1) ; Unescape \u00XX characters $sString = StringReplace($sString, '\u003c', '<', 0, 1) $sString = StringReplace($sString, '\u003e', '>', 0, 1) $sString = StringReplace($sString, '\u0026', '&', 0, 1) Return $sString EndFunc ;==>__AI_Json_UnEscapeString ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_Json_Map($sJson) ;=== It not support numbers, booleans, arrays or nested objects. === Local $mJson[] ; Remove curly braces and trim $sJson = StringStripWS(StringTrimLeft(StringTrimRight($sJson, 1), 1), 3) ; Match all "key": "value" pairs Local $aPairs = StringRegExp($sJson, '"([^"]+)"\s*:\s*"((?:\\.|[^"\\])*)"', 3) If @error Then Return SetError(2, 0, 0) For $i = 0 To UBound($aPairs) - 1 Step 2 Local $sKey = $aPairs[$i] Local $sVal = $aPairs[$i + 1] __AI_Json_UnEscapeString($sVal) $mJson[$sKey] = $sVal ; ConsoleWrite("$sKey=" & $sKey & @CRLF) Next Return $mJson EndFunc ;==>__AI_Json_Map ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_Json_GetModels() Local $oHttp = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHttp.Open("GET", "http://localhost:11434/api/tags", False) $oHttp.Send() If $oHttp.Status <> 200 Then SetError(1) Return "" EndIf Return $oHttp.ResponseText EndFunc ;==>__AI_Json_GetModels ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_DW($sString, $iNoErrorNoLine = 0, $iLine = @ScriptLineNumber, $iError = @error, $iExtended = @extended) If Not $g__AI_DebugInfo Then Return SetError($iError, $iExtended, 0) ; Return Value: The amount of data written. Local $iReturn, $sLine = "@@(" & $iLine & ") :: " If $iNoErrorNoLine And Not $iError Then $sLine = "" If $iError Then $iReturn = ConsoleWrite("@@(" & $iLine & ") :: @error:" & $iError & ", @extended:" & $iExtended & ", " & $sString) Else $iReturn = ConsoleWrite($sLine & $sString) EndIf ; Remarks: The @error and @extended are not set on return leaving them as they were before calling. Return SetError($iError, $iExtended, $iReturn) EndFunc ;==>__AI_DW ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_ObjAutoItErrorEvent() If IsObj($g__AI_ObjErr) Then ; Use error data __AI_DW('AutoIt.Error Event: Desc.: "' & $g__AI_ObjErr.description & '"' & @CRLF, 0, $g__AI_ObjErr.scriptline) ;~ MsgBox(0, "COM Error", "Description: " & $g__AI_ObjErr.Description & @CRLF & _ ;~ "Number: " & Hex($g__AI_ObjErr.Number, 8) & @CRLF & _ ;~ "Source: " & $g__AI_ObjErr.Source & @CRLF & _ ;~ "HelpFile: " & $g__AI_ObjErr.HelpFile & @CRLF & _ ;~ "HelpContext: " & $g__AI_ObjErr.HelpContext & @CRLF & _ ;~ "LastDllError: " & $g__AI_ObjErr.LastDllError & @CRLF & _ ;~ "ScriptLine: " & $g__AI_ObjErr.ScriptLine) ; We clear the properties of ObjEvent AFTER we have used them. $g__AI_ObjErr.Description = "" $g__AI_ObjErr.Number = 0 EndIf EndFunc ;-------------------------------------------------------------------------------------------------------------------------------- Func __AI_HTTP_STATUS_CODES($iStatus) Local $aResult[3] = [$iStatus, "Unknown Status", "An unknown HTTP status code was returned."] Local $HTTP_STATUS_CODES[41][3] = [[40, "HTTP status", "description"] _ , [100, "CONTINUE", "The request can be continued."] _ , [101, "SWITCH_PROTOCOLS", "The server has switched protocols in an upgrade header."] _ , [200, "OK", "The request completed successfully."] _ , [201, "CREATED", "The request has been fulfilled and resulted in the creation of a new resource."] _ , [202, "ACCEPTED", "The request has been accepted for processing, but the processing has not been completed."] _ , [203, "PARTIAL", "The returned meta information in the entity-header is not the definitive set available from the originating server."] _ , [204, "NO_CONTENT", "The server has fulfilled the request, but there is no new information to send back."] _ , [205, "RESET_CONTENT", "The request has been completed, and the client program should reset the document view that caused the request to be sent to allow the user to easily initiate another input action."] _ , [206, "PARTIAL_CONTENT", "The server has fulfilled the partial GET request for the resource."] _ , [207, "WEBDAV_MULTI_STATUS", "During a World Wide Web Distributed Authoring and Versioning (WebDAV) operation, this indicates multiple status codes for a single response. The response body contains Extensible Markup Language (XML) that describes the status codes."] _ , [300, "AMBIGUOUS", "The requested resource is available at one or more locations."] _ , [301, "MOVED", "The requested resource has been assigned to a new permanent Uniform Resource Identifier (URI), and any future references to this resource should be done using one of the returned URIs."] _ , [302, "REDIRECT", "The requested resource resides temporarily under a different URI."] _ , [303, "REDIRECT_METHOD", "The response to the request can be found under a different URI and should be retrieved using a GET HTTP verb on that resource."] _ , [304, "NOT_MODIFIED", "The requested resource has not been modified."] _ , [305, "USE_PROXY", "The requested resource must be accessed through the proxy given by the location field."] _ , [307, "REDIRECT_KEEP_VERB", "The redirected request keeps the same HTTP verb. HTTP/1.1 behavior."] _ , [400, "BAD_REQUEST", "The request could not be processed by the server due to invalid syntax."] _ , [401, "DENIED", "The requested resource requires user authentication."] _ , [402, "PAYMENT_REQ", "Not implemented in the HTTP protocol."] _ , [403, "FORBIDDEN", "The server understood the request, but cannot fulfill it."] _ , [404, "NOT_FOUND", "The server has not found anything that matches the requested URI."] _ , [405, "BAD_METHOD", "The HTTP verb used is not allowed."] _ , [406, "NONE_ACCEPTABLE", "No responses acceptable to the client were found."] _ , [407, "PROXY_AUTH_REQ", "Proxy authentication required."] _ , [408, "REQUEST_TIMEOUT", "The server timed out waiting for the request."] _ , [409, "CONFLICT", "The request could not be completed due to a conflict with the current state of the resource. The user should resubmit with more information."] _ , [410, "GONE", "The requested resource is no longer available at the server, and no forwarding address is known."] _ , [411, "LENGTH_REQUIRED", "The server cannot accept the request without a defined content length."] _ , [412, "PRECOND_FAILED", "The precondition given in one or more of the request header fields evaluated to false when it was tested on the server."] _ , [413, "REQUEST_TOO_LARGE", "The server cannot process the request because the request entity is larger than the server is able to process."] _ , [414, "URI_TOO_LONG", "The server cannot service the request because the request URI is longer than the server can interpret."] _ , [415, "UNSUPPORTED_MEDIA", "The server cannot service the request because the entity of the request is in a format not supported by the requested resource for the requested method."] _ , [449, "RETRY_WITH", "The request should be retried after doing the appropriate action."] _ , [500, "SERVER_ERROR", "The server encountered an unexpected condition that prevented it from fulfilling the request."] _ , [501, "NOT_SUPPORTED", "The server does not support the functionality required to fulfill the request."] _ , [502, "BAD_GATEWAY", "The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request."] _ , [503, "SERVICE_UNAVAIL", "The service is temporarily overloaded."] _ , [504, "GATEWAY_TIMEOUT", "The request was timed out waiting for a gateway."] _ , [505, "VERSION_NOT_SUP", "The server does not support the HTTP protocol version that was used in the request message."]] For $i = 1 To $HTTP_STATUS_CODES[0][0] If $HTTP_STATUS_CODES[$i][0] = $iStatus Then ;$aResult[0] = $HTTP_STATUS_CODES[$i][0] $aResult[1] = $HTTP_STATUS_CODES[$i][1] $aResult[2] = $HTTP_STATUS_CODES[$i][2] ExitLoop EndIf Next Return $aResult EndFunc ;==>__AI_HTTP_STATUS_CODES ;-------------------------------------------------------------------------------------------------------------------------------- #EndRegion ; === Internal use Functions === AI_Assistant_Example.au3 #include "AI_Assistant.au3" _Example1() Func _Example1() ; Example WordGenerator Local $sKeyword = "WORD GENERATOR" Local $iCount = 6, $iMin = 4 Local $aLetter = StringSplit($sKeyword, "") Local $sSystemPrompt = _ "You are a word generator AI. For each given letter, respond with exactly " & $iCount & " common English words " & _ "that start with that letter. Words must be at least " & $iMin & " letters long. " & _ "No duplicates allowed. Only return words separated by commas—no explanations, no extra text." Local $sRaw, $sAnswer = "" For $i = 1 To $aLetter[0] If StringRegExp($aLetter[$i], "^[A-Za-z]$") Then $sRaw = _AI_Call($aLetter[$i], "llama3.2:3b", $sSystemPrompt, 1) $sAnswer &= $aLetter[$i] & " - " & $sRaw & @LF Else $sAnswer &= $aLetter[$i] & @LF EndIf Next ConsoleWrite($sAnswer & @CRLF) EndFunc ;==>_Example1 #CS output: W - Wager, Wallet, Waves, Wishes, Winds, Winter O - Ocean, Owner, Oxygen, Orange, Open, Option R - Racket, Razor, Ruler, Rainbow, Rhythm, Router D - Dance, Digger, Doctor, Dog, Donor, Dragon G - Ghost, Glide, Glass, Goat, Glow, Graph E - Eagle, Elastic, Energetic, Elegant, Emerald, Escape N - Nest, Night, Noise, Normal, North, Notify E - Eagle, Earthy, Elegant, Earnest, Embark, Energize R - Ranch, Razor, Ruler, Rock, Rocket, River A - Amaze, Alert, Amber, Arise, Aspect, Angel T - Tiger, Tank, Taste, Topic, Total, Trouble O - Ocean, Owner, Open, Operation, Origin, Overshare R - Racket, Radar, Ranges, Raven, Reaction, Radius #CE SciTE_AI_Assistant.au3 I changed the approach, and made it as SciTE tool. This way, the selection process, and console writing, is handled internally by SciTE. To do this you need to add the following to SciTEUser.properties (Adding_utilities_to_the_SciTE_Tools_menu) #------------------------------------------------------------------------------ # 41 SciTE_AI_Assistant command.41.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_AI_Assistant\SciTE_AI_Assistant.au3" command.subsystem.41.$(au3)=0 command.name.41.$(au3)=SciTE AI Assistant command.shortcut.41.*.au3=F10 command.save.before.41.$(au3)=2 # command.replace.selection.41.$(au3)=1 # command.quiet.41.$(au3)=0 # command.input.41.$(au3)=$(CurrentSelection) #------------------------------------------------------------------------------ #---------------------- Contex Menu ------------------------------------------- user.context.menu=\ ||\ >>> SciTE AI Assistant <<< |1141|\ ||\ Execute Selected Path|IDM_OPENSELECTED|\ #------------------------------------------------------------------------------ and make the necessary adjustments e.g. in command.41.$(au3)="$(SciteDefaultHome)\..\AutoIt3.exe" "D:\i\Pro\.AutoIT\SciTE_AI_Assistant\SciTE_AI_Assistant.au3" your path for the d:\your\location\SciTE_AI_Assistant\SciTE_AI_Assistant.au3 You may need to adjust the 41 to the first tool number available to you. in this case, change the >>> SciTE AI Assistant <<< |1141|\ as well in the Context Menu After that, select the text in the SciTE, right-click and select 'instruction' from the context menu '>>> SciTE AI Assistant <<<' Prompt Builder GUI The script described is an advanced AI prompt builder tool The tool provides a user-friendly interface that allows users to create, manage, and execute AI prompts based on predefined templates or customizable settings from .ini file. macros in the Prompt Builder GUI @Selection@ = the Selection of SciTE @ScriptName@ = the Script Name (useful as title) @ScriptFullPath@ = all the content of Script @ClipGet@ = the content of Clipboard @FileRead(FilePath)@ = the content of FilePath FIM (Fill-in-the-Middle <??> ) when it comes to FIM (Fill-in-the-Middle <??> ), the '<??>' tag is to specify the-Middle e.g. as in the example below, highlight the text , right click , and select, >>> SciTE AI Assistant <<< , FIM (Fill-in-the-Middle <??> ) Func SumNumbers($aNumbers) Local $iTotal = 0 For $i = 0 To UBound($aNumbers) - 1 <??> Next Return $iTotal EndFunc I will update the thread as soon as anything new comes up. SciTE_AI_Assistant_0.10.zip Please, every comment is appreciated! leave your comments and experiences here! Thank you very much2 points
-
autoit problem
Musashi and one other reacted to pixelsearch for a topic
Yes that's the reason, for example with a simplified script (Esc to quit the script), have a look at the Console #include <File.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) ;0=no, 1=require pre-declaration Opt("GUIOnEventMode", 1) ; Event Mode ON Global $aTradeRows[0] Global $AllertNotify Global $gGroupDynamic = 0 ConsoleWrite("$gGroupDynamic = " & $gGroupDynamic & @crlf) main() While 1 Sleep(100) WEnd ;=========================== Func main() ; === GUI === Local $guiWidth = 685, $guiHeight = 40 $AllertNotify = GUICreate("Trades", $guiWidth, $guiHeight, -1, -1, _ BitOR($WS_POPUP, $WS_BORDER, $WS_CLIPSIBLINGS)) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") WinSetOnTop($AllertNotify, "", 1) GUISetState(@SW_SHOW) LoadTradesFromFile() AdlibRegister("ReloadTrades", 3000) EndFunc ;=========================== Func LoadTradesFromFile() Local $symbol = "symbol" Local $ticket = "ticket" Local $net = "net" Local $text = StringFormat("%s | %s", $symbol, $net) Local $textSize = StringLen($text) * 7 ; Associa label e button al gruppo dinamico! Local $label = GUICtrlCreateLabel($text, 10, 10, $textSize, 22, 0, $gGroupDynamic) ConsoleWrite("$label = " & $label & " $gGroupDynamic = " & $gGroupDynamic & @crlf) _ArrayAdd($aTradeRows, $label) Local $btn = GUICtrlCreateButton($ticket, 10 + $textSize, 10, 60, 24, $gGroupDynamic) ConsoleWrite("$btn = " & $btn & " $gGroupDynamic = " & $gGroupDynamic & @crlf) GUICtrlSetData($btn, $ticket) _ArrayAdd($aTradeRows, $btn) Local $tradeCount = 1 ; Bottone "Chiudi tutto" fuori dal ciclo, associato anch'esso al gruppo Local $closeAllBtnX = 685 - 35 Local $btnCloseAll = GUICtrlCreateButton("X", $closeAllBtnX + 10, 5, 20, 20, $gGroupDynamic) ConsoleWrite("$btnCloseAll = " & $btnCloseAll & " $gGroupDynamic = " & $gGroupDynamic & @crlf & @crlf) Return $tradeCount EndFunc ;=========================== Func ReloadTrades() If $gGroupDynamic Then GUICtrlDelete($gGroupDynamic) ; cancella il contenitore $gGroupDynamic = GUICtrlCreateGroup("", 0, 0, 685, 30) ; contenitore invisibile ConsoleWrite("$gGroupDynamic = " & $gGroupDynamic & @crlf) GUICtrlSetState($gGroupDynamic, $GUI_HIDE) ReDim $aTradeRows[0] LoadTradesFromFile() GUICtrlSetState($gGroupDynamic, $GUI_SHOW) EndFunc ;=========================== Func _Exit() Exit EndFunc $gGroupDynamic = 0 $label = 3 $gGroupDynamic = 0 $btn = 4 $gGroupDynamic = 0 $btnCloseAll = 5 $gGroupDynamic = 0 $gGroupDynamic = 6 $label = 7 $gGroupDynamic = 6 $btn = 8 $gGroupDynamic = 6 $btnCloseAll = 9 $gGroupDynamic = 6 $gGroupDynamic = 6 $label = 10 $gGroupDynamic = 6 $btn = 11 $gGroupDynamic = 6 $btnCloseAll = 12 $gGroupDynamic = 6 You apply the value of $gGroupDynamic to your 3 controls, in Style or ExStyle and it creates a mess. For example, see how a value of 6 changes the button style in this script, turning it to a checkbox : #include <GUIConstantsEx.au3> Example() Func Example() Local $hGUI = GUICreate("Example", 300, 200) ; Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25) ; ok Local $idButton_Close = GUICtrlCreateButton("Close", 210, 170, 85, 25, 6) ; Style 2 to 7 => checkbox, style 10 hides etc... GUISetState(@SW_SHOW, $hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idButton_Close ExitLoop EndSwitch WEnd GUIDelete($hGUI) EndFunc ;==>Example2 points -
As you can see, I can't test the script, so I'm just speculating At first glance, there are some irregularities here Local $label = GUICtrlCreateLabel($text, $x, $y + 3, $textSize, 22, 0, $gGroupDynamic) Local $btn = GUICtrlCreateButton($ticket, $x + $textSize, $y - 1, 60, 24, $gGroupDynamic) Local $btnCloseAll = GUICtrlCreateButton("X", $closeAllBtnX + 10, 5, 20, 20, $gGroupDynamic) you use as style or as exStyle to $gGroupDynamic = GUICtrlCreateGroup("", 0, 0, 685, 30) ; contenitore invisibile which doesn't seem right to me.2 points
-
AutoIt Snippets
ioa747 and one other reacted to argumentum for a topic
If Not FileExists(@TempDir & "\YouAreHERE") Then DirCreate(@TempDir & "\YouAreHERE") ; Run(@ComSpec & " /K @SET PROMPT=$E[32m$C$E[94m" & "$D" & "@" & "$T" & "$E[32m$F-[$E[90m$P$E[32m]$_$G$E[33m", @TempDir & "\YouAreHERE") ; date@time Run(@ComSpec & " /K @SET PROMPT=$E[32m$C$E[94m" & @UserName & "@" & @ComputerName & "$E[32m$F-[$E[90m$P$E[32m]$_$S$E[33m", @TempDir & "\YouAreHERE") May be silly but this "most awesome code™" opens a cmd in a folder without consequence and leaves a prompt with enough room to type even in long paths. For more "prompt creativity", visit https://ss64.com/nt/prompt.html Edit: made an icon for it too cmdWprompt.ico.zip2 points -
$cv.Mat.create($image, _OpenCV_Rect($left, $top, $width, $height)).copy()2 points
-
Pointer to a pointer
mLipok and one other reacted to argumentum for a topic
I asked ChatGPT and it told me I was the best. It made my day. Am very happy today. Thank you ChatGPP2 points -
DwmColorBlurMica
ioa747 and one other reacted to WildByDesign for a topic
2 points -
[REGEXPTITLE: difficulty with wildcards
TimRude and one other reacted to pixelsearch for a topic
It's because the quantifiers (* + ? { }) "specify how many of the preceding character, class, reference or group are expected to match." ( @jchd in help file, topic StringRegExp) So space* will check for 0 or more repeated spaces, while .* will check for 0 or more any character (except newline characters when the option (?s) is not indicated) Edit : @Musashi was fast2 points -
.* is required because : . -> matches any single character except, by default, a newline sequence. * -> 0 or more, greedy * alone is a Quantifier (or repetition specifier) which specifies how many of the preceding characters are expected to match. Info : \d\d\d\d can be written as \d{4} Global $sStr = "SampleApp 1234 - some text here 12345678 - some more miscellaneous text" Global $sPattern = "(?i)SampleApp \d{4} -.*\d{8} -.*" ConsoleWrite(StringRegExp($sStr, $sPattern) & @LF) ; Returns 1 (match) or 0 (no match)2 points
-
Well, this is openning a can of worms! Nowhere in the AutoIt specification of flags is mentionnend whether more than one occurence of a given flag is permitted or acted upon: is "%+++123.0f" the same as "%+123.0f". Seems easy to check in a few cases, but still without clear spec, we can't rely on that being innocuous. We do have a hint that more than one distinct flag is supported (albeit ignored) : If 0 and - appear, the 0 is ignored. the blank is ignored if both the blank and + flags appear. To provide a partial answer we need to test all combinations of flags. From "" to "-+*0#" (where * stands for a 0x20 whitespace for clarirty). Below is some code to do that and reveal that many flags combinations are not supported: ; There are 5 flag specifiers: '-', '+', '0', ' ', '#' in the StringFormat specification. ; If one assumes that a given flag may only appear once in the flags specification ; and given that more than one flag may be specified, the total numbers of flag strings ; is the power set of the set of flag specifiers. There are therefore 2^5 flag strings to ; test. ; This also assumes that the order of flags in a given flag string is irrelevant. ; ; It is easy to build that power set using binary mapping. Local $aFlags = ['-', '+', '0', ' ', '#'] Local $aFlagComb[2^5][2] Local $aComb2 For $i = 0 To 2^5 - 1 $aComb2 = StringSplit(StringFormat("%05s", _IntToString($i, 2)), "", $STR_NOCOUNT) For $j = 0 To 4 $aFlagComb[$i][0] &= ($aComb2[$j] = 1 ? $aFlags[$j] : "") Next Next For $i = 0 To UBound($aFlagComb) - 1 $aFlagComb[$i][1] = StringFormat("%" & $aFlagComb[$i][0] & "10.0f", 123) $aFlagComb[$i][0] = StringReplace($aFlagComb[$i][0], " ", "*") Next _ArrayDisplay($aFlagComb) Func _IntToString($i, $base = 16) Return DllCall("msvcrt.dll", "wstr:cdecl", "_i64tow", "int64", $i, "wstr", "", "int", $base)[0] EndFunc ;==>_IntToString It is also unclear whether the order of individual flags matter inside a given input. To fully answer this new question, one would need to create new entries in $FlagComb where the length of the flag string is > 1, split that string in individual characters and add new entries made from ArrayPermute. If you're cautious, also create new entries to cope with duplicate flags in various position(s) inside the flags strings to see if ever some rule emerges. Making a long answer short: both AI answers are incorrect. (My) conclusion: never trust a pile on unknown hardware fed with social networks toilet noises.2 points
-
_StringToTable
Musashi and one other reacted to pixelsearch for a topic
Related to this thread, this is the 1st time I use ChatGPT, here are the question & answer My question : Hello, I don't understand. One hour ago, I asked you if the AutoIt RegExp ^([+\-]?(?:\d*\.\d+|\d+\.?))$ could match a numeric input .5 and you answered "No it doesnt" . A few minutes ago, I asked you the same question and you answered "Yes it does" . Why did you change your answer ? Answer from GPT-4o mini The confusion likely stems from the interpretation of the regular expression and the specific input being evaluated. The regular expression ^([+\-]?(?:\d*\.\d+|\d+\.?))$ is designed to match numeric inputs, including integers and decimal numbers. Here's a breakdown of the regex: ^ asserts the start of the string. [+\-]? allows for an optional sign (either '+' or '-'). (?:\d*\.\d+|\d+\.?) is a non-capturing group that matches either: \d*\.\d+: zero or more digits followed by a decimal point and one or more digits (e.g., .5, 1.5, 0.5). \d+\.?: one or more digits followed optionally by a decimal point (e.g., 5, 5., 10). Given this breakdown, the input .5 should indeed match the regex, as it fits the pattern of zero digits before the decimal point followed by one or more digits after it. If I initially stated that it does not match, that was incorrect. The correct answer is that .5 does match the regex. I apologize for the inconsistency in my responses. Thank you for your understanding!2 points -
LibreOffice UDF Help and Support
argumentum and one other reacted to JALucena for a topic
Hi everybody since two weeks ago i have been working with this UDF in several proyects and I think its great! In the past i worked with this UDF: https://www.autoitscript.com/forum/topic/151530-ooolibo-calc-udf/ which is fantastic too. I think i have found a bug in the function _LOCalc_DocViewWindowSettings from the library LibreOfficeCalc_Doc.au3. In the line 2161 there is a call to the function __LOCalc_ArrayFill and the fourth and fifth parameters are switched. where it says __LOCalc_ArrayFill($abView, $oCurCont.HasColumnRowHeaders(), $oCurCont.HasVerticalScrollBar(), $oCurCont.HasSheetTabs(), $oCurCont.HasHorizontalScrollBar(), _ it must be __LOCalc_ArrayFill($abView, $oCurCont.HasColumnRowHeaders(), $oCurCont.HasVerticalScrollBar(), $oCurCont.HasHorizontalScrollBar(), $oCurCont.HasSheetTabs(), _ After modified it works fine. Thank you for your job.2 points -
GUI Button Responsiveness Drops After Setting Color or Background Color
ioa747 and one other reacted to pixelsearch for a topic
Hello @TitaniusPlatinum I had the same concern a few weeks ago, in this post . Here is a part of the comment : Melba23's code indicates the way to handle this. May I suggest yöu save his code on your computer. I kept his useful code about a month ago, saving it under a catchy name '"Double-click a label (WM_COMMAND).au3" Good luck2 points -
Win 11 - My own border color ( Help area )
Musashi and one other reacted to argumentum for a topic
These border colors are set by the app every time the window is created. The example for this is already posted. Since this is more of an app than an example, I opened a thread here for support. The script and compilation to .exe is the files area for download. According to Microsoft, the possibility to set the border color is available from Windows 11 Build 22000 onwards.2 points -
DarkMode UDF for AutoIt's Win32GUIs
argumentum and one other reacted to UEZ for a topic
Is there a way to check if visible GUI is in dark mode? Edit: this seems to work: ;Coded by UEZ build 2025-05-14 #include <AutoItConstants.au3> #include <StringConstants.au3> #include <WinAPISysWin.au3> Const $DWMWA_USE_IMMERSIVE_DARK_MODE = @OSBuild < 18362 ? 19 : 20 Func _WinAPI_IsWindowDarkMode($hWnd) Local $value = DllStructCreate("int dm") Local $ret = DllCall("dwmapi.dll", "long", "DwmGetWindowAttribute","hwnd", $hWnd, "uint", $DWMWA_USE_IMMERSIVE_DARK_MODE, "struct*", $value, "uint", DllStructGetSize($value)) If @error Or $ret[0] <> 0 Then Return 0 Return $value.dm <> 0 EndFunc Global $aWinList = WinList(), $i, $iStatus For $i = 1 To $aWinList[0][0] If _WinAPI_IsWindowVisible($aWinList[$i][1]) Then If IsHWnd($aWinList[$i][1]) Then $iStatus = _WinAPI_IsWindowDarkMode($aWinList[$i][1]) ConsoleWrite($aWinList[$i][1] & ": " & $iStatus & " -> " & StringRegExpReplace($aWinList[$i][0], "[\r\n]+", "") & @CRLF) EndIf EndIf Next2 points -
Overwrite a file without destroying the previous contents
pixelsearch and one other reacted to Musashi for a topic
Or maybe this : #include <Constants.au3> Global $bInsert = "0xFFFFFF" Global $hFile = FileOpen("mslogo.jpg", BitOR($FO_APPEND, $FO_BINARY)) FileSetpos($hFile, 20, $FILE_BEGIN ) ; Pos = 20 FileWrite($hfile, $bInsert) FileClose($hFile) ==> Info : A better way to work with binary data is to use a struct ! I would advise you to always create a backup of the file before you change it - safety first2 points -
SciTE AI assistant
argumentum and one other reacted to SOLVE-SMART for a topic
You are such a nice person @ioa747. In my opinion there is no apology necessary at all. There was a misunderstanding and that's it. But thanks for the clarification - no worries and thanks for your effort regarding this LLM <==> AutoIt thingy 😁 . Best regards Sven2 points -
SciTE AI assistant
argumentum and one other reacted to ioa747 for a topic
I apologize, 😔 I still didn't understand what had happened and it wasn't working for you. Then when I saw here that you started escaping control characters, I was surprised. (I still didn't understand what had happened) That's why I passed you just '__JSON_FormatString($sPrompt) ' I thought you just removed the __JSON_FormatString($sPrompt) Even after you showed me here with the scary StringRegExpReplace($sString & '\\\b\f\n\r\t\"', '(?s)(?|\\(?=.*(\\\\))|[\b](?=.*(\\b))|\f(?=.*(\\f))|\r\n(?=.*(\\n))|\n(?=.*(\\n))|\r(?=.*(\\r))|\t(?=.*(\\t))|"(?=.*(\\")))', '\1'), I thought it was your addition because something didn't work for you, or you have some old version of JSON.au3 and that's why I asked you (and which is the right one? ; Version .......: 0.10 ? ) because I checked on github what the current version is, and it was 10, which is the one I had (I didn't go and see if the function was the same, I just looked at the header) I got the full picture today when I read all the relevant posts. I concluded that, I was misusing a UDF function, which is intended for internal use only. After all this I came to the conclusion. That I need to make an internal function for escaping control characters, so that I have better control. and since my JSON parser requirements are basic, for a specific JSON format, I will also make a fake JSON parser, so that I can extract the data I need from JSON, without external additions (at least until needed) This will also help me to better understand the JSON format thanks for understanding I apologize to everyone for the upset I caused you, it was not my intention.2 points -
JSON UDF in pure AutoIt
SOLVE-SMART and one other reacted to AspirinJunkie for a topic
Ok, so let's just say that the function is not “broken” after all, does what it is supposed to do and does it correctly without any known errors? It has always been the responsibility of the application code to use their respective dependencies correctly. Especially as non-public interfaces are used here, which were never intended to be used by the user. The _JSON_Generate() function is intended to format a string in a JSON-compliant manner as a user. Its behavior has not changed over time. A change would have no effect on the described functionality of the UDF, which is why there is no need for action from my point of view.2 points -
SciTE AI assistant
SOLVE-SMART and one other reacted to genius257 for a topic
@argumentum I am not sure i get if it's the platform, the repositories, the individual users or a combination you dislike? When it comes to git, keeping the version in the file seems wrong, in my opinion. Git tags and/or releases on some git platforms seems the best way to keep good track of the available versions of scripts/projects. In regards to the same code being available at a later date, unless they delete or change the visibility of the repository, you could keep a commit hash reference for a perma-link to the code you were able to access last time I personally prefer git (GitHub more specifically). Old files on this forum sometimes go poof, and sometimes no one can provide a replica (it's rare, i know). Both Git and this forum can be a time waster, if dependencies are not kept with the project, and you are forced to go on a treasure hunt to find the necessary files (happened once or twice to me 🫠). Personally i am working towards a package manager, using primarily git to automatically resolve and fetch dependencies of a project. If developers use the semver standard, patches should be pain free and allow upgrading dependencies using a single command I agree forking is not exactly a perfect solution, but is sometimes necessary, for example when dealing with abandoned projects or not agreeing on where a project is heading2 points -
_StringToTable
Danyfirex and one other reacted to SOLVE-SMART for a topic
Hi folks 👋 , I spend a bit freetime and created version v0.3.0 of data-to-table.au3 UDF. 8 different border styles a flexible way of adding more border styles (tiny how-to follows in the next days (I hope)) what has changed ==> CHANGELOG how it looks ==> output-result Once again, kudos to @ioa747 for his idea and main logic behind it. I changed your version drastically, but you approach is still in my coding heart 🤭 . 💡 For now, I am temporary done with this library, until I will have more time for this. If you guys find BUGs or do have suggestions, I really appreciate your feedback - thanks 🤝 . Btw. @WildByDesign, your style request from @argumentums post here, is border style variant 8 "double-outter-border-and-header-with-single-inner-border" 😀 . ╔════════════╤════════════════╤═════════════════╤═════════════════════════════════════════╗ ║ Language │ Popularity (%) │ Job Demand │ Typical Use ║ ╟────────────┼────────────────┼─────────────────┼─────────────────────────────────────────╢ ║ JavaScript │ 62.3 │ Very High │ Web Development, Frontend/Backend ║ ║ C# │ 27.1 │ High │ Game Development, Windows Apps, Web Dev ║ ║ Go │ 13.8 │ Growing │ Cloud Services, System Programming ║ ║ PowerShell │ 13.5 │ Low to Moderate │ Task Automation, DevOps, System Admin ║ ║ AutoIt │ 0.5 │ Low │ Windows GUI Automation, Scripting ║ ╚════════════╧════════════════╧═════════════════╧═════════════════════════════════════════╝ If you like the UDF, consider to star the project on GitHub, thanks. Best regards Sven2 points -
Listview replacing, coloring, doubleclick
argumentum and one other reacted to pixelsearch for a topic
Ok, I'll finally post something in this thread, though we had a solution for 2 days ("we" = me and a helpful tester via PM, for confirmation on a different OS) But the sentence "Back to your issue, I will not give you the answer." refrained us for posting anything, to avoid creating new tensions. Just have a look at this post above, then 1) Change this line... For $i = 1 To 10 ...to For $i = 1 To 500 Now the script throws the error you reported : $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] ? ($mColor[$tCustDraw.IDFrom])[$iItem][$iSubItem] : 0xFFFFFF $tCustDraw.clrTextBk = ($mColor[$tCustDraw.IDFrom])^ ERROR 2) Then move this block of 3 lines... GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUIRegisterMsg($WM_LBUTTONUP, WM_LBUTTONUP) GUISetState() ...and place it just before While True : GUIRegisterMsg($WM_NOTIFY, WM_NOTIFY) GUIRegisterMsg($WM_LBUTTONUP, WM_LBUTTONUP) GUISetState() While True ...now everything should work fine. It seems that after a few hundreds of list items added, then WM_NOTIFY is always triggered (the listview needs to be redrawn). So if you place the block of 3 lines too early, then the script will crash because the array $aColor is not defined (when map is encountered within the WM_NOTIFY function) Moving the 3 lines just before the main loop should fix it. Please tell us if this solution works for you.2 points -
I'm closing this topic as I have found a solution. Basically, in the app I'm flipping between my regular domain, and the global domain, and the flipping action was not properly setting things up in the initial go-from-regular-to-global-domain action. This was causing the AD query to fail. Thanks to everyone who may have already looked at this issue, and I'm now sorry that I brought this up. Bob2 points
-
_StringToTable
Musashi and one other reacted to argumentum for a topic
╔══════════════════════╦══════════╦════════╦══════════╦═══════════╦════════╦═════════╦════════╗ ║ name ║ time[ms] ║ factor ║ Std. Dev ║ Std. Err. ║ min ║ max ║ range ║ ╠══════════════════════╬══════════╬════════╬══════════╬═══════════╬════════╬═════════╬════════╣ ║ StringRegExp only ║ 1.691 ║ 1.00 ║ 0.351 ║ 0.035 ║ 1.304 ║ 3.167 ║ 1.863 ║ ║ jq UDF ║ 32.933 ║ 19.48 ║ 2.929 ║ 0.293 ║ 29.308 ║ 43.169 ║ 13.861 ║ ║ JsonC-UDF ║ 51.086 ║ 30.21 ║ 3.205 ║ 0.321 ║ 45.625 ║ 63.460 ║ 17.835 ║ ║ pure AutoIt JSON-UDF ║ 97.916 ║ 57.90 ║ 5.685 ║ 0.569 ║ 86.362 ║ 113.467 ║ 27.105 ║ ║ JSMN-based JSON-UDF ║ 108.248 ║ 64.01 ║ 5.512 ║ 0.551 ║ 99.029 ║ 130.864 ║ 31.835 ║ ╚══════════════════════╩══════════╩════════╩══════════╩═══════════╩════════╩═════════╩════════╝ ... ... Local Const $TL = "╔", $TR = "╗", $BL = "╚", $BR = "╝" Local Const $H = "═", $V = "║", $C = "╬" Local Const $TH = "╦", $CH = "╩", $LH = "╠", $RH = "╣" ... ...2 points -
_StringToTable
argumentum and one other reacted to ioa747 for a topic
I added functionality to accept and array as input. I renamed $iString to $vString, and now it verifies whether $vString is an array and converts it to a string as needed.2 points -
Melque_Lima, There is a very useful search function at top-right of the page. A quick search found several solutions. M232 points
-
Uploaded a new version of the SciTE4AutoIt3.exe v21.316.1639.1
argumentum reacted to mLipok for a topic
1 point -
@atvaxn I would go some other way. Try this : #include <guiConstants.au3> #include <Misc.au3> #include <WinAPIShellEx.au3> #include <WinAPIRes.au3> #include <WinAPISysWin.au3> Opt("MustDeclareVars", True) Opt("MouseCoordMode", 2) Example() Func Example() Local $hGUI = GUICreate("Gantt Chart", 300, 200, -1, -1, -1, $WS_EX_COMPOSITED) Local $idBar1 = GUICtrlCreateLabel("", 5, 50, 80, 20) GUICtrlSetBkColor(-1, 0xf00000) Local $idBar2 = GUICtrlCreateLabel("", 25, 80, 80, 20) GUICtrlSetBkColor(-1, 0xf0) Local $hDll = DllCallbackRegister(MoveProc, 'lresult', 'hwnd;uint;wparam;lparam;uint_ptr;dword_ptr') _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBar1), DllCallbackGetPtr($hDll), $idBar1) _WinAPI_SetWindowSubclass(GUICtrlGetHandle($idBar2), DllCallbackGetPtr($hDll), $idBar2) GUISetState() While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idBar1), DllCallbackGetPtr($hDll), $idBar1) _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($idBar2), DllCallbackGetPtr($hDll), $idBar2) DllCallbackFree($hDll) EndFunc ;==>Example Func MoveProc($hWnd, $iMsg, $wParam, $lParam, $iID, $iData) If $iMsg <> $WM_LBUTTONDOWN Then Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) Local $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) Local $iPosX = MouseGetPos(0), $iPosXN, $hCursor Select Case $iPosX - $aPosID[0] <= 3 ; left $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEWE) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0] + ($iPosXN - $iPosX), $aPosID[1], $aPosID[2] + $iPosX - $iPosXN) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd Case $aPosID[0] + $aPosID[2] - $iPosX <= 3 ; right $hCursor = _WinAPI_LoadCursor(0, $OCR_SIZEWE) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0], $aPosID[1], $aPosID[2] + $iPosXN - $iPosX) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd Case Else ; center $hCursor = _WinAPI_LoadCursor(0, $OCR_HAND) While _IsPressed("01") _WinAPI_SetCursor($hCursor) If $iPosX <> MouseGetPos(0) Then $iPosXN = MouseGetPos(0) GUICtrlSetPos($iID, $aPosID[0] + $iPosXN - $iPosX) $iPosX = $iPosXN $aPosID = ControlGetPos(_WinAPI_GetParent($hWnd), "", $hWnd) EndIf WEnd EndSelect Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>MoveProc1 point
-
You are right. What about: Local $tBuffer = DllStructCreate("handle buffer") ; https://msdn.microsoft.com/en-us/library/windows/desktop/ms682485(v=vs.85).aspx Local $a_hCall = DllCall("kernel32.dll", "bool", "CreateTimerQueueTimer", _ "struct*", $tBuffer, _ "handle", 0, _ "ptr", DllCallbackGetPtr($hCallback), _ "ptr", Null, _ "dword", 100, _ "dword", 150, _ "ulong", 0) ... Local $a_hCall = DllCall("kernel32.dll", "bool", "DeleteTimerQueueTimer", _ "handle", 0, _ "handle", $tBuffer.buffer, _ "handle", 0) Forget: it still doesn't seem to be stable.1 point
-
No issues with Freebasic: #include "windows.bi" #include "win/winbase.bi" Sub WoTCallback(LPARAM As LPARAM, TimerOrWaitFired As BOOL) ? LPARAM, TimerOrWaitFired End Sub Dim As PHANDLE phNewTimer Dim As HANDLE hTQ = CreateTimerQueue() CreateTimerQueueTimer(@phNewTimer, hTQ, Cast(WAITORTIMERCALLBACK, @WoTCallback), 0, 100, 100, WT_EXECUTEDEFAULT) Dim As Double t = Timer While 1 If Timer - t > 5 Then ? !"Exit loop" DeleteTimerQueueTimer(hTQ, phNewTimer, 0) CloseHandle(phNewTimer) Exit While End If Sleep(10) Wend Sleep Seems to be an issue with Autoit. Edit: Local $a_hCall = DllCall("kernel32.dll", "bool", "CreateTimerQueueTimer", _ "struct*", $tBuffer, _ "handle", $a_h_CreateTimerQueue[0], _ "ptr", DllCallbackGetPtr($hCallback), _ "ptr", Null, _ "dword", 5000, _ "dword", $i_TimerQueue_Repeat_after, _ "ulong", 0) This seems to be stable.1 point
-
I think I have found the source of the issue. As described in the function : WT_EXECUTEINTIMERTHREAD 0x00000020 The callback function is invoked by the timer thread itself. This flag should be used only for short tasks or it could affect other timer operations. The callback function is queued as an APC. It should not perform alertable wait operations. APC : Asynchronous Procedure Call. Which means it is not executed immediately. I thought that using Volatile would help, but it does not.1 point
-
How to capture output from a batch file?
SOLVE-SMART reacted to BigDaddyO for a topic
Take a look at the help file for StdoutRead you would need to put in a loop waiting for the output you want before closing the app.1 point -
Win 11 - My own border color ( Help area )
argumentum reacted to WildByDesign for a topic
I had some fun with your script after learning some more about how it works. Added title bar Dark, Mica, Acrylic/blur, Mica Alt options Added ability to do rounded GUI corners or standard square corners * These are build 22621+. I'm still playing with some more fun options. I understand that your script is related to border color, however, your script really is the perfect "vehicle" to enable all of these fun things system-wide. Func SetBorderColor_apply2this($hwnd, $iBorderColor = $g_iBorderColor) ; 0xffFFFFFF default ; else 0x00ABCDEF ; https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute ; $DWMWA_BORDER_COLOR = 34 ; https://www.purebasic.fr/english/viewtopic.php?t=78732 _WinAPI_DwmSetWindowAttribute__($hWnd, 20, 1) ; dark mode DWMWA_USE_IMMERSIVE_DARK_MODE _WinAPI_DwmSetWindowAttribute__($hWnd, 38, 4) ; build 22523+, DWMWA_SYSTEMBACKDROP_TYPE = 38 ; 0 auto, 1 none (dark), 2 mica, 3 acrylic, 4 mica alt _WinAPI_DwmSetWindowAttribute__($hWnd, 33, 1) ; DWMWA_CORNER_PREFERENCE = 33 ; 0 default, 1 not round, 2 round, 3 round small _WinAPI_DwmSetWindowAttribute__($hwnd, 34, _WinAPI_SwitchColor($iBorderColor)) ; border EndFunc ;==>SetBorderColor_apply2this EDIT: The DWMWA_SYSTEMBACKDROP_TYPE option will mess up the Start menu. You can avoid that easily by adding exclusion for any window with title "Start".1 point -
JSON UDF in pure AutoIt
SOLVE-SMART reacted to AspirinJunkie for a topic
It may be obvious to you, but it still isn't to me. You have now written the function again but still haven't explained which input values cause it to fail. I have fed several test strings to it and all came back as expected. That's why I'm asking again: For which specific data does the function not return the desired result? About the byref/return story: In old versions, the function was designed to process the variable directly (a "procedure"). However, since you cannot include the function call in string definitions, this was later changed to a return the target value (a "function"). This has simplified the code that uses this function. The way in which the function must be used has of course changed: Before you had to make a single call and got the variable changed, now you have to use the return value instead. The ByRef was left in (for performance reasons at the time) to avoid additional copies. We had already covered the fact that these considerations are not fulfilled in reality in the discussion on _JSON_Parse(). This function is therefore also a candidate where the ByRef can be removed if the opportunity arises. But until then, this is simply irrelevant for the functionality of the function and has no influence. ByRef and Return are not incompatible. Edit: Ok, a little more thought: Could it be that it's not about the function being faulty, but that you just want a feature extension so that you can process variables directly and at the same time get them back as return values? Well of course you can discuss that but this function is not part of the user interface (it begins with 2 underscores) but an internal helper function for a specific purpose. So far it has fulfilled this purpose, so I have no compulsion to change it accordingly. If someone absolutely needs a function that processes a variable accordingly in-place, then this is a three-liner for him. But that would just be a feature request. In fact, the function was said to be “broken”. But I can't see that so far.1 point -
_StringToTable
ioa747 reacted to SOLVE-SMART for a topic
I appreciate this, thanks. Good point, I guess I have to create another thread. To be honest, it's not a "project" that I want to extent much or spend much time, because my personal usage of it isn't that much. Reporting BUGs would usually made by GitHub issues. Anyhow, you're right - most of the people here don't use GitHub at all, so I will create a new thread. --------------------------- ==> https://www.autoitscript.com/forum/topic/212886-udf-data-to-tableau3 --------------------------- Now I understand, thanks. I also wouldn't expect this, all fine. Good point, but why getting annoyed - not a big deal 😅 . Best regards Sven1 point -
_StringToTable
ioa747 reacted to WildByDesign for a topic
I've tested your _DblFrame function this morning and it works great and looks really nice.1 point