Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 08/05/2025 in all areas

  1. ; #FUNCTION# ==================================================================================================================== ; Name...........: HourAmPm ; Description....: Converts a time in 24-hour format to AM/PM format. ; Syntax.........: HourAmPm( $sDateTime [, $sAmPm = "AM|PM" [, $iTrimRight = 0]] ) ; Parameters.....: $sDateTime - The time (with date or not) string with "HH:" in it. ; $sAmPm - [optional] The AM/PM representation (default is "AM|PM"). ; $iTrimRight - [optional] The number of characters to trim from the right of the result (default is 0). ; $iNoDate - [optional] Whether to omit the date from the output. Defaults to False. ; Return values .: Success: Returns the formatted date and time in AM/PM format. ; Failure: None. ; Author ........: argumentum ; Modified ......: ; Remarks .......: This function takes a 24-hour time string, converts it to AM or PM format, and returns the result with optional trimming. ; Related .......: ; Link ..........: https://www.autoitscript.com/forum/index.php?showtopic=213061 ; Example .......: MsgBox(64, "Converted Time", HourAmPm("12/31/1999 18:59:59")) ; =============================================================================================================================== Func HourAmPm($sDateTime, $sAmPm = Default, $iTrimRight = Default, $iNoDate = Default) Local $aAmPm = StringSplit((StringInStr($sAmPm, "|") ? $sAmPm : "AM|PM"), "|"), $sFormat = $aAmPm[2] Local $iHourPos = StringInStr($sDateTime, ":"), $sHour = StringMid($sDateTime, $iHourPos - 2, 2) Local $sDate = StringLeft($sDateTime, $iHourPos - 3), $sTime = StringTrimLeft($sDateTime, $iHourPos - 1) If $sHour < 12 Then $sFormat = $aAmPm[1] ; https://www.autoitscript.com/forum/index.php?showtopic=213061 $sHour = Mod($sHour, 12) If Not $sHour Then $sHour = 12 Return StringTrimRight((Int($iNoDate) ? "" : $sDate) & StringRight('0' & $sHour, 2) & $sTime, Int($iTrimRight)) & " " & $sFormat EndFunc ;==>HourAmPm ...am always looking for these ( because am disorganized ) and when I find them they are more than needed so, I decided to simplify it and flexibly-cate** it. All that's needed is the hour, the rest of the date-time string should be anything as long as there is a "HH:" in it. ; Examples: ConsoleWrite('- ' & HourAmPm("18:59") & @CRLF) ; - 06:59 PM ConsoleWrite('- ' & HourAmPm("18:59:59.999") & @CRLF) ; - 06:59:59.999 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999") & @CRLF) ; - 1999/12/31 06:59:59.999 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999", Default, 7) & @CRLF) ; - 1999/12/31 06:59 PM ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59", Default, 3) & @CRLF) ; - 1999/12/31 06:59 PM ConsoleWrite('- ' & HourAmPm("12/31/1999 18:59", "a|p") & @CRLF) ; - 12/31/1999 06:59 p ConsoleWrite('- ' & HourAmPm("1999/12/31 18:59:59.999", Default, 7, True) & @CRLF) ; - 06:59 PM Don't remember seeing this approach anywhere so I decided to share it **flexibly-cate [verb] To make it flexible
    4 points
  2. ioa747

    Auto(it)Runs

    Auto(it)Runs This script utilizes the sysinternals autorunsc command-line tool to scan and analyze autorun entries on a Windows system. https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns The script's primary function is to extract information from the autorunsc.exe scan results, to Autoit, which can be used for various purposes and understanding system startup behavior. Using the $STDOUT stream and not the -c switch (Print output as CSV), so that you don't have to export the data to disk every time I explored it experimentally, and these are the results. ; https://www.autoitscript.com/forum/topic/213070-autoitruns/ ;---------------------------------------------------------------------------------------- ; Title...........: Auto(it)Runs.au3 ; Description.....: This script utilizes the sysinternals `autorunsc` command-line tool ; to scan and analyze autorun entries on a Windows system. ; The script's primary function is to extract information from the autorun scan results, ; which can be used for various purposes and understanding system startup behavior. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.9 ; Note............: Testet in Win10 22H2 Date:10/08/2025 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #RequireAdmin #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> #include <StringConstants.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> Example() ;--------------------------------------------------------------------------------------- Func Example() Local $sCMD = CreateCmdGUI() ConsoleWrite("$sCMD=" & $sCMD & @CRLF) Local $aEntries = AutorunSnapshot($sCMD) If @error Then ConsoleWrite("! @error:" & @error & " " & $aEntries & @CRLF) Local $iPos = StringInStr($sCMD, '-o "') ; check if -o Switch in $sCMD then execute the output file If $iPos > 1 Then ShellExecute(StringLeft(StringTrimLeft($sCMD, $iPos + 3), StringInStr(StringTrimLeft($sCMD, $iPos + 3), '"') - 1)) Else DisplayGUI($aEntries, "Autorun Entries") EndIf EndFunc ;==>Example ;--------------------------------------------------------------------------------------- Func CreateCmdGUI() ; Optional GUI to build the autorunsc cmdline ; Switches for the "-a" group (Group A) Local $aGroupA[18][3] = [ _ [0, "*", "All"], [0, "b", "Boot execute"], [0, "c", "Codecs"], _ [0, "d", "Appinit DLLs"], [0, "e", "Explorer addons"], [0, "g", "Sidebar gadgets"], _ [0, "h", "Image hijacks"], [0, "i", "Internet Explorer addons"], [0, "k", "Known DLLs"], _ [0, "l", "Logon startups (default)"], [0, "m", "WMI entries"], [0, "n", "Winsock protocol"], _ [0, "o", "Office addins"], [0, "p", "Printer monitor DLLs"], [0, "r", "LSA security providers"], _ [0, "s", "Services & non-disabled drivers"], [0, "t", "Scheduled tasks"], [0, "w", "Winlogon entries"] _ ] ; Switches for other parameters (Group B) Local $aGroupB[12][3] = [ _ [0, "-ct", "Print as tab-delimited"], [0, "-c", "Print as CSV"], [0, "-x", "Print output as XML"], _ [0, "-o", "Write output to the file."], [0, "-h", "Show file hashes."], [0, "-m", "Hide Microsoft entries"], _ [0, "-t", "Show timestamps in normalized UTC."], [0, "-s", "Verify digital signatures"], _ [0, "-u", "Show unsigned/unknown files"], [0, "-vrs", "VirusTotal check & upload"], _ [0, "-nobanner", "Do not show startup banner"], [0, "*", "Scan all user profiles"] _ ] ; Create the Autorunsc GUI GUICreate("Autorunsc GUI", 600, 560) GUISetFont(9, 400, 0, "Tahoma") ; Create the input box for the command GUICtrlCreateLabel("Generated Command:", 10, 10, 200, 20) Local $idInputbox = GUICtrlCreateInput("", 10, 30, 580, 25, $ES_AUTOHSCROLL) GUICtrlSetState($idInputbox, $GUI_DISABLE) ; Create the input box for the output file Local $idLblOutFile = GUICtrlCreateLabel("Output file:", 310, 420, 200, 20) GUICtrlSetState(-1, $GUI_HIDE) Local $idOutFile = GUICtrlCreateInput("output.txt", 310, 440, 260, 20) GUICtrlSetState(-1, $GUI_HIDE) Local $idExecuteButton = GUICtrlCreateButton("Execute", 420, 500, 140, 25) ; Create Group 1 for "-a" switches on the left GUICtrlCreateGroup("Autostart Entry Selection (-a)", 10, 70, 280, 480) Local $iX = 20, $iY = 90 For $i = 0 To UBound($aGroupA) - 1 $aGroupA[$i][0] = GUICtrlCreateCheckbox($aGroupA[$i][1] & " (" & $aGroupA[$i][2] & ")", $iX, $iY, 260, 20) $iY += 25 Next ; Set default selections in (Group A) GUICtrlSetState($aGroupA[1][0], $GUI_CHECKED) ; -a b GUICtrlSetState($aGroupA[9][0], $GUI_CHECKED) ; -a l GUICtrlCreateGroup("", -99, -99, 1, 1) ; Close the group ; Create Group 2 for other switches on the right GUICtrlCreateGroup("Other Options", 300, 70, 290, 330) $iX = 310 $iY = 90 For $i = 0 To UBound($aGroupB) - 1 $aGroupB[$i][0] = GUICtrlCreateCheckbox($aGroupB[$i][1] & " (" & $aGroupB[$i][2] & ")", $iX, $iY, 260, 20) $iY += 25 Next ; Set default selections in (Group B) GUICtrlSetState($aGroupB[11][0], $GUI_CHECKED) ; * user profiles GUICtrlCreateGroup("", -99, -99, 1, 1) ; Close the group GUISetState(@SW_SHOW) Local $nMsg, $bNeedUpdate = True While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $aGroupA[0][0] ; Handle the "All" checkbox logic If GUICtrlRead($aGroupA[0][0]) = $GUI_CHECKED Then For $i = 1 To UBound($aGroupA) - 1 GUICtrlSetState($aGroupA[$i][0], $GUI_DISABLE) GUICtrlSetState($aGroupA[$i][0], $GUI_UNCHECKED) Next Else For $i = 1 To UBound($aGroupA) - 1 GUICtrlSetState($aGroupA[$i][0], $GUI_ENABLE) Next EndIf $bNeedUpdate = True Case $aGroupA[1][0] To $aGroupA[17][0] ; Handle other "-a" checkboxes If GUICtrlRead($nMsg) = $GUI_CHECKED Then GUICtrlSetState($aGroupA[0][0], $GUI_DISABLE) Else Local $bAnyChecked = False For $i = 1 To UBound($aGroupA) - 1 If GUICtrlRead($aGroupA[$i][0]) = $GUI_CHECKED Then $bAnyChecked = True ExitLoop EndIf Next If Not $bAnyChecked Then GUICtrlSetState($aGroupA[0][0], $GUI_ENABLE) EndIf EndIf $bNeedUpdate = True Case $idOutFile $bNeedUpdate = True Case $idExecuteButton Return GUICtrlRead($idInputbox) Case $aGroupB[0][0] To $aGroupB[11][0] $bNeedUpdate = True EndSwitch If $bNeedUpdate Then Local $sCommand = "" Local $sAGroupSwitches = "" ; Build the string for "-a" switches For $i = 0 To UBound($aGroupA) - 1 If GUICtrlRead($aGroupA[$i][0]) = $GUI_CHECKED Then $sAGroupSwitches &= $aGroupA[$i][1] EndIf Next ; Add the "-a" switch only once if any option is selected If StringLen($sAGroupSwitches) > 0 Then $sCommand &= " -a " & $sAGroupSwitches ; Add switches from Group B For $i = 0 To UBound($aGroupB) - 1 If GUICtrlRead($aGroupB[$i][0]) = $GUI_CHECKED Then $sCommand &= " " & $aGroupB[$i][1] EndIf Next ; if Output file is checked If GUICtrlRead($aGroupB[3][0]) = $GUI_CHECKED Then GUICtrlSetState($idLblOutFile, $GUI_SHOW) GUICtrlSetState($idOutFile, $GUI_SHOW) Local $sOutFile = @ScriptDir & "\" & GUICtrlRead($idOutFile) $sCommand = StringReplace($sCommand, "-o", '-o "' & $sOutFile & '"') ; Set default selections in (Group B) GUICtrlSetState($aGroupB[0][0], $GUI_ENABLE) ; -ct GUICtrlSetState($aGroupB[1][0], $GUI_ENABLE) ; -c GUICtrlSetState($aGroupB[2][0], $GUI_ENABLE) ; -x GUICtrlSetState($aGroupB[4][0], $GUI_ENABLE) ; -h GUICtrlSetState($aGroupB[6][0], $GUI_ENABLE) ; -t GUICtrlSetState($aGroupB[7][0], $GUI_ENABLE) ; -s GUICtrlSetState($aGroupB[8][0], $GUI_ENABLE) ; -u GUICtrlSetState($aGroupB[9][0], $GUI_ENABLE) ; -vrs GUICtrlSetState($aGroupB[10][0], $GUI_ENABLE) ; -nobanner Else GUICtrlSetState($idLblOutFile, $GUI_HIDE) GUICtrlSetState($idOutFile, $GUI_HIDE) ; Set default selections in (Group B) GUICtrlSetState($aGroupB[0][0], $GUI_CHECKED) ; -ct GUICtrlSetState($aGroupB[0][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[1][0], $GUI_UNCHECKED) ; -c GUICtrlSetState($aGroupB[1][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[2][0], $GUI_UNCHECKED) ; -x GUICtrlSetState($aGroupB[2][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[4][0], $GUI_UNCHECKED) ; -h GUICtrlSetState($aGroupB[4][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[6][0], $GUI_CHECKED) ; -t GUICtrlSetState($aGroupB[6][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[7][0], $GUI_UNCHECKED) ; -s GUICtrlSetState($aGroupB[7][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[8][0], $GUI_UNCHECKED) ; -u GUICtrlSetState($aGroupB[8][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[9][0], $GUI_UNCHECKED) ; -vrs GUICtrlSetState($aGroupB[9][0], $GUI_DISABLE) GUICtrlSetState($aGroupB[10][0], $GUI_CHECKED) ; -nobanner GUICtrlSetState($aGroupB[10][0], $GUI_DISABLE) EndIf GUICtrlSetData($idInputbox, $sCommand) $bNeedUpdate = False EndIf WEnd Exit ;Return SetError(1, 0, "") EndFunc ;==>CreateCmdGUI ;--------------------------------------------------------------------------------------- Func AutorunSnapshot($sCmdSwitches = '-a bl -t -ct -nobanner *') ; Extract Entries to array ; https://learn.microsoft.com/en-us/sysinternals/downloads/autoruns ; Make sure autorunsc.exe is located in a subfolder named "Autoruns" in @ScriptDir Local Const $sAutorunscPath = @ScriptDir & "\Autoruns\autorunsc64.exe" ; Verify that autorunsc.exe exists. If Not FileExists($sAutorunscPath) Then Return SetError(1, 0, "! Error: The autorunsc.exe file was not found") ; Usage: autorunsc [-a <*|bdeghiklmoprsw>] [-c|-ct] [-h] [-m] [-s] [-u] [-vt] [-o <output file>] [[-z <systemroot> <userprofile>] | [user]]] ; -a Autostart entry selection: ; * All. ; b Boot execute. ; c Codecs. ; d Appinit DLLs. ; e Explorer addons. ; g Sidebar gadgets (Vista and higher) ; h Image hijacks. ; i Internet Explorer addons. ; k Known DLLs. ; l Logon startups (this is the default). ; m WMI entries. ; n Winsock protocol and network providers. ; o Office addins. ; p Printer monitor DLLs. ; r LSA security providers. ; s Autostart services and non-disabled drivers. ; t Scheduled tasks. ; w Winlogon entries. ; -c Print output as CSV. ; -ct Print output as tab-delimited values. ; -h Show file hashes. ; -m Hide Microsoft entries (signed entries if used with -s). ; -o Write output to the specified file. ; -s Verify digital signatures. ; -t Show timestamps in normalized UTC (YYYYMMDD-hhmmss). ; -u If VirusTotal check is enabled, show files that are unknown ; by VirusTotal or have non-zero detection, otherwise show only ; unsigned files. ; -x Print output as XML. ; -v[rs] Query VirusTotal (www.virustotal.com) for malware based on file hash. ; Add 'r' to open reports for files with non-zero detection. Files ; reported as not previously scanned will be uploaded to VirusTotal ; if the 's' option is specified. Note scan results may not be ; available for five or more minutes. ; -vt Before using VirusTotal features, you must accept ; VirusTotal terms of service. See: https://www.virustotal.com/en/about/terms-of-service/ ; If you haven't accepted the terms and you omit this ; option, you will be interactively prompted. ; -z Specifies the offline Windows system to scan. ; user Specifies the name of the user account for which ; autorun items will be shown. Specify '*' to scan ; all user profiles. ; -nobanner Do not display the startup banner and copyright message. ; Construct the command to run autorunsc.exe ; Local $sCommand = '"' & $sAutorunscPath & '" -a bl -m -t -ct -nobanner *' <<- Default -<< Local $sCommand = '"' & $sAutorunscPath & '" ' & $sCmdSwitches ; $sCmdSwitches = '-a bl -t -ct -nobanner *' ; Run autorunsc.exe Local $iPID = Run($sCommand, "", @SW_HIDE, $STDOUT_CHILD) ; Wait until the process has closed ProcessWaitClose($iPID) ; Read the Stdout stream of the PID Local $sOutput = StdoutRead($iPID) ; Possible ANSI to UTF16 conversion $sOutput = BinaryToString(StringToBinary($sOutput, $SB_ANSI), $SB_UTF16LE) ; <<- important -<< ;ConsoleWrite("$sOutput=" & $sOutput & @CRLF) ; Use StringSplit to split the output of StdoutRead to an array. All carriage returns (@CR) are stripped and @LF is used as the delimiter. Local $aDataArray = StringSplit(StringTrimRight(StringStripCR($sOutput), 1), @LF) If @error Then Return SetError(2, 0, "! Error: It appears there was an error trying to get the STDOUT.") ;_ArrayDisplay($aDataArray) Local $aPart, $aData[UBound($aDataArray)][12], $idx = 0 ; Skip 1st line with header For $i = 2 To UBound($aDataArray) - 1 $aPart = StringSplit($aDataArray[$i], @TAB) If $aPart[0] = 11 Then $idx += 1 $aData[$idx][0] = $idx $aData[$idx][1] = $aPart[1] $aData[$idx][2] = $aPart[2] $aData[$idx][3] = $aPart[3] $aData[$idx][4] = $aPart[4] $aData[$idx][5] = $aPart[5] $aData[$idx][6] = $aPart[6] $aData[$idx][7] = $aPart[7] $aData[$idx][8] = $aPart[8] $aData[$idx][9] = $aPart[9] $aData[$idx][10] = $aPart[10] $aData[$idx][11] = $aPart[11] EndIf Next ;_ArrayDisplay($aData) ReDim $aData[$idx + 1][12] $aData[0][0] = $idx $aData[0][1] = "Time" $aData[0][2] = "EntryLocation" $aData[0][3] = "Entry" $aData[0][4] = "Enabled" $aData[0][5] = "Category" $aData[0][6] = "Profile" $aData[0][7] = "Description" $aData[0][8] = "Company" $aData[0][9] = "ImagePath" $aData[0][10] = "Version" $aData[0][11] = "LaunchString" Return $aData EndFunc ;==>AutorunSnapshot ;--------------------------------------------------------------------------------------- Func DisplayGUI($aItems, $sTitle = "") ; Optional GUI to Display the extracted Entries ; Create GUI GUICreate($sTitle, 1600, 600) Local $idListview = GUICtrlCreateListView("", 2, 2, 1600, 600, -1, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) GUISetState(@SW_SHOW) ; ["idx", "Time", "EntryLocation", "Entry", "Enabled", "Category", "Profile", "Description", "Company", "ImagePath", "Version", "LaunchString"] ; Add columns _GUICtrlListView_AddColumn($idListview, "idx", 30) _GUICtrlListView_AddColumn($idListview, "Time", 100) _GUICtrlListView_AddColumn($idListview, "EntryLocation", 450) _GUICtrlListView_AddColumn($idListview, "Entry", 150) _GUICtrlListView_AddColumn($idListview, "Enabled", 60) _GUICtrlListView_AddColumn($idListview, "Category", 60) _GUICtrlListView_AddColumn($idListview, "Profile", 60) _GUICtrlListView_AddColumn($idListview, "Description", 100) _GUICtrlListView_AddColumn($idListview, "Company", 100) _GUICtrlListView_AddColumn($idListview, "ImagePath", 300) _GUICtrlListView_AddColumn($idListview, "Version", 40) _GUICtrlListView_AddColumn($idListview, "LaunchString", 300) _GUICtrlListView_SetItemCount($idListview, $aItems[0][0]) ; remove $aItems header _ArrayDelete($aItems, 0) _GUICtrlListView_AddArray($idListview, $aItems) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>DisplayGUI ;--------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    3 points
  3. Thank you so much for everyone's kind help! Apologies in delay in replying, I don't know what I was doing wrong, but it was like beating my head against the wall somehow (my mom passed away 3 months ago, so suspect I was also just having trouble with details, who knows <sigh>). But I came back to this again. When I leave my apartment, I like to shut down all things running apps in the systray except what's there "automatically", as it were. Then when I come home, start up those extra things I like to have running when I'm around. Ultimately, pixelsearch kindly wrote up the code to include that TRUE statement which escaped me because of the presentation before as just describing what to do (and I see now I must still have been affected by mom's passing as I just couldn't make heads or tails of that). Here is the what worked just now, but I removed the suggested "_ArrayDisplay($array)" line as that created some havoc, too, and I find it's not really necessary, just an extra confusing step, it seems. #include <file.au3> #include <Array.au3> Local $array = _FileListToArray(@ScriptDir & "\Startup\", "0*.*", 1, TRUE) ;_ArrayDisplay($array) For $i = 1 To $array[0] ShellExecute($array[$i]) Next Thank you!
    3 points
  4. Absolutely. Please keep in mind that I am a complete AutoIt rookie. The examples show JSON code already in the example scripts as Global variables and parse/manipulate from there. The thing that would help a rookie like me the most would be to have an example script and an example .json file. The script would load the .json file from disk, parse json, modify some data and save those changes back to .json file on disk. That would have helped my rookie situation a lot. However, I also understand that some of that is outside of the responsibility for the UDF. But from an example perspective still would be beneficial. By the way, thank you all for your help. Cheers!
    3 points
  5. If you then want to write to the theme with _JSON_addChangeDelete() (which could make sense due to the nested structure), then you basically only need to determine the first free array index. Since you have an AutoIt data structure after _JSON_Parse(), you basically only need to make a Ubound to the themes array: #include "JSON.au3" ; your input JSON string Global $sJSONRAW = '{"workbench.startupEditor":"none","breadcrumbs.enabled":false,"window.controlsStyle":"custom","workbench.activityBar.location":"hidden","window.customTitleBarVisibility":"auto","window.titleBarStyle":"custom","workbench.colorCustomizations":{"editor.background":"#00000060","terminal.background":"#00000060"},"theme":"Existing Theme 1","themes":[{"name":"Existing Theme 1","tab":{"background":"#00000080","unfocusedBackground":"#00000000"},"tabRow":{"background":"#00000000","unfocusedBackground":"#00000000"},"window":{"applicationTheme":"light","useMica":true}},{"name":"Existing Theme 2","tab":{"background":"#00000080","unfocusedBackground":"#00000000"},"tabRow":{"background":"#00000000","unfocusedBackground":"#00000000"},"window":{"applicationTheme":"light","useMica":true}},{"name":"Existing Theme 3","tab":{"background":"#00000080","unfocusedBackground":"#00000000"},"tabRow":{"background":"#00000000","unfocusedBackground":"#00000000"},"window":{"applicationTheme":"light","useMica":true}},{"name":"Existing Theme 4","tab":{"background":"#00000080","unfocusedBackground":"#00000000"},"tabRow":{"background":"#00000000","unfocusedBackground":"#00000000"},"window":{"applicationTheme":"light","useMica":true}}]}' ; parse JSON string into nested AutoIt data structure: Global $vJSON = _JSON_Parse($sJSONRAW) If @error Then Exit MsgBox(0,"Erro", "Error " & @error & " during parsing the JSON string") ; print to console to check the structure of the input JSON string ConsoleWrite("------- Input --------- " & @CRLF & _JSON_Generate($vJSON) & @CRLF & @CRLF) ; determine the number of elements already in the array "themes" Global $iNewIdx = UBound($vJSON["themes"]) ; add the new theme at the first free index: _JSON_addChangeDelete($vJSON, "theme", "Default Theme Test") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].name", "Default Theme Test") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].tab.background", "#00000020") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].tab.unfocusedBackground", "#00000000") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].tabRow.background", "#00000000") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].tabRow.unfocusedBackground", "#00000000") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].window.applicationTheme", "dark") _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "].window.useMica", true) ; create JSON string out of the AutoIt datastructure and print it to the console ConsoleWrite("------- Output --------- " & @CRLF & _JSON_Generate($vJSON) & @CRLF & @CRLF) Exactly - after _JSON_Parse() the whole thing no longer has anything to do with JSON but you have completely normal AutoIt data structures. However, this data is heavily nested. In AutoIt you can easily read information from nested data structures. But changing them is extremely cumbersome. To simplify exactly this, there is the _JSON_addChangeDelete() which (contrary to its name) has nothing to do with JSON but takes care of nested AutoIt data structures. The "cleaner" way mentioned is therefore already the way that _JSON_addChangeDelete() takes, as it changes the data at AutoIt level - just with a simpler interface than building the nested array element manually. Btw:, here's a little trick: With structures as complex as your theme description, you don't have to add everything manually. If you already know the structure beforehand, then simply describe it directly in JSON, have the theme element created completely from it and add it as a whole. In other words, you can replace the entire _JSON_addChangeDelete() in the example with a single one (similar to the jq example above): _JSON_addChangeDelete($vJSON, "themes[" & $iNewIdx & "]", _JSON_Parse('{"name":"Default Theme Test","tab":{"background":"#00000020","unfocusedBackground":"#00000000"},"tabRow":{"background":"#00000000","unfocusedBackground":"#00000000"},"window":{"applicationTheme":"dark","useMica":true}}'))
    3 points
  6. I’m thrilled to introduce my IStream UDF, a sophisticated library designed to handle the COM IStream interface in AutoIt. This UDF enables management of data streams, whether from files, memory, or other sources, leveraging Windows IStream APIs. It provides a reliable solution for reading, writing, and administering streams in your AutoIt scripts. Whether you need to process large files, manipulate in-memory data, or handle transactional streams, this UDF is crafted to be versatile, well-documented, and user-friendly.Key Features Full Implementation of the IStream Interface: Supports all methods of the IStream interface (Read, Write, Seek, SetSize, CopyTo, Commit, Revert, LockRegion, UnlockRegion, Stat, Clone). Support for File and Memory Streams: Create streams from files using _SHCreateStreamOnFileEx or from in-memory data with _StreamCreateFromData, _SHCreateMemStream, and _StreamCreateFromDataOnHGlobal. Advanced Error Handling: Includes a detailed HRESULT error table ($tagIStreamErrorTable) and a _IStream_GetErrorInfo function for clear, understandable error messages. Utility Functions: Functions like _StreamGetSize, _StreamGetName, _StreamGetType, and _StreamStatDisplay simplify access to stream metadata. Comprehensive Documentation: Each function comes with standard UDF-format documentation, including syntax, parameters, return values, remarks, MSDN links, and practical examples. Compatibility: Works with AutoIt 3.3+ and relies on standard libraries (AutoItObject, WinAPI, Memory, Date). Use Cases Reading and writing large files without loading their entire content into memory. Handling in-memory binary data for applications such as network stream processing or serialized data manipulation. Supporting transactional streams for secure operations (e.g., via StgCreateDocfile). Integration with other COM interfaces requiring IStream. you need: AutoItObject.au3 Example: copy data between streams #include "IStream.au3" ; Example demonstrating the use of _StreamCopyToEx to copy data between streams Func Example_StreamCopyToEx() ; Create a source stream with the content "Strong" using _StreamCreateFromDataOnHGlobal ConsoleWrite("Creating source stream with 'Strong'..." & @CRLF) Local $iSrcSize,$aError Local $oSrcStream = _StreamCreateFromDataOnHGlobal("Strong", $iSrcSize, True) If @error Or Not IsObj($oSrcStream) Then ; Handle errors by displaying the HRESULT code and details from $tagIStreamErrorTable ConsoleWrite("Error: Failed to create source stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf Return EndIf ConsoleWrite("Source stream created, size: " & $iSrcSize & " bytes" & @CRLF) ; Create a destination stream with the content "AutoIt is " using _StreamCreateFromDataOnHGlobal ConsoleWrite("Creating destination stream with 'AutoIt is '..." & @CRLF) Local $iDestSize Local $oDestStream = _StreamCreateFromDataOnHGlobal("AutoIt is ", $iDestSize, True) If @error Or Not IsObj($oDestStream) Then ; Handle errors for destination stream creation ConsoleWrite("Error: Failed to create destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release the source stream and COM resources before exiting _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Destination stream created, size: " & $iDestSize & " bytes" & @CRLF) ; Copy the content from the source stream to the destination stream using _StreamCopyToEx ConsoleWrite("Copying 'Strong' to destination stream..." & @CRLF) Local $iBytesRead, $iBytesWritten If Not _StreamCopyToEx($oSrcStream, $oDestStream, $iSrcSize, $iBytesRead, $iBytesWritten) Then ; Handle errors during the copy operation ConsoleWrite("Error: _StreamCopyToEx failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release both streams and COM resources before exiting _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Copied " & $iBytesRead & " bytes read, " & $iBytesWritten & " bytes written." & @CRLF) ; Read and display the content of the destination stream ConsoleWrite("Reading destination stream content..." & @CRLF) Local $iNewDestSize = _StreamGetSize($oDestStream) If @error Then ; Handle errors when retrieving the destination stream size ConsoleWrite("Error: Failed to get destination stream size. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Release both streams and COM resources before exiting _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ConsoleWrite("Destination stream size after copy: " & $iNewDestSize & " bytes" & @CRLF) ; Position the stream pointer at the beginning for reading Local $pDestMem, $iDestRead _StreamSeek($oDestStream, 0, $STREAM_SEEK_SET) If @error Then ; Handle errors when seeking in the destination stream ConsoleWrite("Error: Failed to seek destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf _StreamRelease($oDestStream) _StreamRelease($oSrcStream) Return EndIf ; Read the content of the destination stream _StreamRead($oDestStream, $iNewDestSize, $pDestMem, $iDestRead) If @error Then ; Handle errors when reading the destination stream ConsoleWrite("Error: Failed to read destination stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) $aError = _IStream_GetErrorInfo(@extended) If IsArray($aError) Then ConsoleWrite("Name: " & $aError[0] & @CRLF) ConsoleWrite("Description: " & $aError[1] & @CRLF) ConsoleWrite("Affected methods: " & $aError[2] & @CRLF) EndIf ; Free the memory buffer if allocated, then release streams and COM resources If $pDestMem Then _MemGlobalFree($pDestMem) _StreamRelease($oDestStream) _StreamRelease($oSrcStream) _WinAPI_CoUninitialize() Return EndIf ; Convert the read data to a string and display it Local $bufSize Local $bDestData = _WinAPI_GetBufferData($pDestMem, $bufSize) ConsoleWrite("Destination stream content: " & BinaryToString($bDestData, 4) & @CRLF) ; Free the memory buffer If $pDestMem Then _MemGlobalFree($pDestMem) ; Release both streams to prevent memory leaks _StreamRelease($oDestStream) _StreamRelease($oSrcStream) ConsoleWrite("COM uninitialized, resources freed." & @CRLF) EndFunc ;==>Example_StreamCopyToEx ; Run the example Example_StreamCopyToEx() example demonstrating multiple IStream interface methods #include "IStream.au3" ; Example demonstrating multiple IStream interface methods Func Example_IStream() ; Initialize the COM object model (required for COM API calls) _WinAPI_CoInitialize() ConsoleWrite("=== Creating Stream with SHCreateMemStream ===" & @CRLF) ; Create a memory stream with initial content "Hello, IStream UDF!" Local $sData = "Hello, IStream UDF!" Local $iSize = 0 Local $oStream = _StreamCreateFromData($sData, $iSize) If @error Then ; Handle stream creation error and display details ConsoleWrite("Error: Failed to create stream. @error = " & @error & @CRLF) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Stream created successfully. Size: " & $iSize & " bytes" & @CRLF) ; Test IUnknown::QueryInterface to verify the IStream interface ConsoleWrite("Testing QueryInterface..." & @CRLF) Local $IID_IStream = "{0000000C-0000-0000-C000-000000000046}" Local $pQueriedStream = _StreamQueryInterface($oStream, $IID_IStream) If @error Then ; Handle QueryInterface error and release resources ConsoleWrite("Error: QueryInterface failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("QueryInterface succeeded." & @CRLF) ; Release the queried interface to prevent memory leaks DllCall("ole32.dll", "ulong", "Release", "ptr", $pQueriedStream) ; Test IStream::Write by appending additional data ConsoleWrite("Testing Write..." & @CRLF) Local $sNewData = " Additional data." ; 16 characters Local $iNewSize = 0 Local $pMemory = _StreamCreateMemoryBuffer($sNewData, $iNewSize) If @error Then ; Handle memory buffer creation error ConsoleWrite("Error: Failed to create memory buffer. @error = " & @error & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $iWrittenSize = 0 ; Set the stream size to accommodate new data If Not _StreamSetSize($oStream, $iSize + $iNewSize) Then ConsoleWrite("Error: SetSize failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Move the stream pointer to the end for appending If Not _StreamSeek($oStream, $iSize, $STREAM_SEEK_SET) Then ConsoleWrite("Error: Seek failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Write the new data to the stream If Not _StreamWrite($oStream, $pMemory, $iNewSize, $iWrittenSize) Then ConsoleWrite("Error: Write failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemory) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Wrote " & $iWrittenSize & " bytes." & @CRLF) ; Free the memory buffer _WinAPI_FreeMemory($pMemory) ; Test IStream::Seek to move the pointer to the beginning ConsoleWrite("Testing Seek..." & @CRLF) Local $iNewPosition = _StreamSeek($oStream, 0, $STREAM_SEEK_SET) If @error Then ConsoleWrite("Error: Seek failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Stream pointer moved to: " & $iNewPosition & @CRLF) ; Test IStream::Read to retrieve the entire stream content ConsoleWrite("Testing Read..." & @CRLF) Local $pMemoryRead = 0, $iReadSize = 0 If Not _StreamRead($oStream, $iSize + $iNewSize, $pMemoryRead, $iReadSize) Then ConsoleWrite("Error: Read failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pMemoryRead) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $bData = _WinAPI_GetBufferData($pMemoryRead, $iReadSize) ConsoleWrite("Read " & $iReadSize & " bytes: " & BinaryToString($bData) & @CRLF) _WinAPI_FreeMemory($pMemoryRead) ; Verify that the read data matches the expected content If $iReadSize <> $iSize + $iNewSize Or BinaryToString($bData) <> $sData & $sNewData Then ConsoleWrite("Error: Read data does not match expected: " & $sData & $sNewData & @CRLF) EndIf ; Test IStream::CopyTo by copying the stream to a new destination stream ConsoleWrite("Testing CopyTo..." & @CRLF) ; Create a destination stream Local $pDestStream = _WinAPI_CreateStreamOnHGlobal(0, True) If Not $pDestStream Then ConsoleWrite("Error: Failed to create destination stream." & @CRLF) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Move the source stream pointer to the beginning $iNewPosition = _StreamSeek($oStream, 0, $STREAM_SEEK_SET) If @error Then ConsoleWrite("Error: Seek failed on source stream. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Copy the content to the destination stream Local $iBytesRead = 0, $iBytesWritten = 0 If Not _StreamCopyTo($oStream, $pDestStream, $iSize + $iNewSize, $iBytesRead, $iBytesWritten) Then ConsoleWrite("Error: CopyTo failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Copied " & $iBytesRead & " bytes read, " & $iBytesWritten & " bytes written." & @CRLF) ; Create an IStream object from the destination stream pointer Local $oDestStream = _AutoItObject_WrapperCreate($pDestStream, $tagIStream) If @error Then ConsoleWrite("Error: Failed to create destination stream object. @error = " & @error & @CRLF) DllCall("ole32.dll", "ulong", "Release", "ptr", $pDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ; Read and verify the destination stream content _StreamSeek($oDestStream, 0, $STREAM_SEEK_SET) Local $pDestMemory, $iDestReadSize If Not _StreamRead($oDestStream, $iSize + $iNewSize, $pDestMemory, $iDestReadSize) Then ConsoleWrite("Error: Reading destination stream failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _WinAPI_FreeMemory($pDestMemory) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf Local $bDestData = _WinAPI_GetBufferData($pDestMemory, $iDestReadSize) ConsoleWrite("Destination stream content: " & BinaryToString($bDestData, $SB_UTF8) & @CRLF) _WinAPI_FreeMemory($pDestMemory) ; Verify that the copied data matches the expected content ; Test IStream::Commit ConsoleWrite("Testing Commit..." & @CRLF) If Not _StreamCommit($oDestStream, $STGC_DEFAULT) Then ConsoleWrite("Error: Commit failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Commit succeeded." & @CRLF) EndIf ; Test IStream::Revert ConsoleWrite("Testing Revert..." & @CRLF) If Not _StreamRevert($oDestStream) Then ; Note that Revert may not be supported by memory streams ConsoleWrite("Note: Revert may not be supported. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Revert succeeded (unexpected for memory stream)." & @CRLF) EndIf ; Test IStream::LockRegion and UnlockRegion ConsoleWrite("Testing LockRegion..." & @CRLF) If Not _StreamLockRegion($oStream, 0, 10, 0) Then ; Note that LockRegion may not be supported by memory streams ConsoleWrite("Note: LockRegion may not be supported. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) __IStreamErrorInfo(@extended) Else ConsoleWrite("LockRegion succeeded." & @CRLF) ConsoleWrite("Testing UnlockRegion..." & @CRLF) If Not _StreamUnlockRegion($oStream, 0, 10, 0) Then ConsoleWrite("Error: UnlockRegion failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("UnlockRegion succeeded." & @CRLF) EndIf EndIf ; Test IStream::Stat to retrieve stream metadata ConsoleWrite("Testing GetStat..." & @CRLF) Local $pStatFlag = 0 If Not _StreamGetStat($oStream, $pStatFlag) Then ConsoleWrite("Error: GetStat failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Displaying stream metadata:" & @CRLF) _StreamStatDisplay($pStatFlag) _WinAPI_CoTaskMemFree($pStatFlag) ; Test IStream::GetType and GetName ConsoleWrite("Testing GetType and GetName..." & @CRLF) Local $sType = _StreamGetType($oStream) If @error Then ConsoleWrite("Error: GetType failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Stream type: " & $sType & @CRLF) EndIf Local $sName = _StreamGetName($oStream) If @error Then ConsoleWrite("Error: GetName failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) Else ConsoleWrite("Stream name: " & $sName & @CRLF) EndIf ; Test IStream::Clone ConsoleWrite("Testing Clone..." & @CRLF) Local $pCloned Local $oCloneStream = _StreamClone($oStream, $pCloned) If @error Then ConsoleWrite("Error: Clone failed. @error = " & @error & ", @extended = 0x" & Hex(@extended, 8) & @CRLF) _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() Return EndIf ConsoleWrite("Clone stream created successfully." & @CRLF) _StreamRelease($oCloneStream) DllCall("ole32.dll", "ulong", "Release", "ptr", $pCloned) ; Clean up all resources _StreamRelease($oDestStream) _StreamRelease($oStream) _WinAPI_CoUninitialize() ConsoleWrite("All streams released and COM uninitialized." & @CRLF) EndFunc ;==>Example_IStream ; Run the example Example_IStream() The help file is included with the UDF IStream.zip New update Description: The IStream2 UDF (Interface Stream User Defined Function) is an AutoIt library designed to create, manipulate, and interact with IStream COM objects, implementing all methods of the IStream interface defined by Microsoft. This interface enables operations such as reading, writing, seeking, and copying on data streams, whether file-based or in-memory. Version 2 of this UDF has been optimized for native AutoIt usage, removing the dependency on AutoItObject.au3, making it lighter, self-contained, and more accessible.The UDF provides robust error handling through HRESULT codes, well-defined constants for COM flags (STGM, STGC, etc.), and comprehensive documentation for each function. It is ideal for developers looking to manipulate data streams in various contexts, such as file processing, memory management, or integration with structured storage systems. The previous version has been retained for compatibility reasons. This version 2 is designed to be fully compatible with any development using the IStorage interface, while avoiding data conflicts. IStream2.au3
    2 points
  7. Try this version : ; From Nine #include <WinAPIDiag.au3> #include <GDIPlus.au3> #include <GUIConstants.au3> ; Blend - Fade - Text Opt("MustDeclareVars", True) Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 400) GUISetBkColor(0xFFFF00) Local $idLabel = GUICtrlCreateLabel("", 75, 20, 250, 40) Local $hLabel = GUICtrlGetHandle($idLabel) GUISetState() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hLabel) Local $hBrush = _GDIPlus_LineBrushCreate(0, 20, 250, 20, 0xFF606060, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(0, 0, 250, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) ;_WinAPI_DisplayStruct($aInfo[0], $tagGDIPRECTF) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESTORE _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) Case $idLabel ConsoleWrite("Label was clicked" & @CRLF) EndSwitch WEnd _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example
    2 points
  8. I wrote a dll and the wrapper to convert non-animated WebP images to a GDI/GDI+ format / encode any GDI+ supported image to WebP format for use in Autoit. What is WebP? You can find more information about WebP and WebP tools / source codes here: https://developers.google.com/speed/webp Maybe useful for one or the other... 🙂 WebP.au3: #cs Copyright (c) 2025 UEZ The following terms apply to the use of this code (AutoIt scripts and both DLLs), unless otherwise agreed upon in writing with the author: 1. **No commercial use** Any commercial usage - including but not limited to selling, licensing, integrating into commercial software, or using in revenue-generating products - is prohibited. 2. **Modification allowed, for non-commercial use only** You may modify or adapt the code as long as it remains non-commercial. Even in modified versions, the original author must be clearly credited as UEZ. 3. **Attribution required** In any non-commercial distribution or use, clear credit must be given to the original author: UEZ. For exceptions or commercial licensing, please contact: uez at hotmail de #ce ; More information about WebP: https://developers.google.com/speed/webp ; Copyright Google Inc. All Rights Reserved. ;Version 0.5.0 build 2025-08-10 beta #include-once #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <Memory.au3> #include <MsgBoxConstants.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #include <WinAPIConstants.au3> #include <WinAPISysWin.au3> ;~ #include <WinAPIDiag.au3> ;WEBP_HINT_ENUMARTION Enum $WEBP_HINT_DEFAULT = 0, _ ; default preset. $WEBP_HINT_PICTURE, _ ; digital picture, like portrait, inner shot $WEBP_HINT_PHOTO, _ ; outdoor photograph, with natural lighting $WEBP_HINT_GRAPH, _ ; Discrete tone image (graph, map-tile etc). $WEBP_HINT_LAST Global Const $tagWebPConfig = _ "long lossless;" & _ "float quality;" & _ "long method;" & _ "long image_hint;" & _ "long target_size;" & _ "float target_PSNR;" & _ "long segments;" & _ "long sns_strength;" & _ "long filter_strength;" & _ "long filter_sharpness;" & _ "long filter_type;" & _ "long autofilter;" & _ "long alpha_compression;" & _ "long alpha_filtering;" & _ "long alpha_quality;" & _ "long pass;" & _ "long show_compressed;" & _ "long preprocessing;" & _ "long partitions;" & _ "long partition_limit;" & _ "long emulate_jpeg_size;" & _ "long thread_level;" & _ "long low_memory;" & _ "long near_lossless;" & _ "long exact;" & _ "long use_delta_palette;" & _ "long use_sharp_yuv;" & _ "long qmin;" & _ "long qmax" Global Const $tagWebPBitstreamFeatures = "struct;long width; long height; long has_alpha; long has_animation; long format; ulong pad[5];endstruct" Global $g_hDLL ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_Ver ; Description ...: Displays the DLL version information in a messagebox window ; Syntax ........: WebP_Ver([$sPath2DLL = ""]) ; Parameters ....: $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: None ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_Ver($sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found DllCall($sDLL, "none", "WebP_DLL_Version") Return True EndFunc ;==>WebP_Ver ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_Ver2 ; Description ...: Returns the DLL version information ; Syntax ........: WebP_Ver([$sPath2DLL = ""]) ; Parameters ....: $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: DLL version ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_Ver2($sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Return DllCall($sDLL, "str", "Web_DLL_Version2")[0] EndFunc ;==>WebP_Ver2 ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapGetInfo ; Description ...: Gets some rudimentary information about the WebP image ; Syntax ........: WebP_BitmapGetInfo($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - file to load ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: Struct ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapGetInfo($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) ;file not found Local $iFileSize = FileGetSize($sFilename), $nBytes Local $tBuffer = DllStructCreate("struct;byte bin[" & $iFileSize & "];endstruct") Local Const $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tBuffer, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) If Int(BinaryMid($tBuffer.bin, 1, 4)) <> 1179011410 Or Int(BinaryMid($tBuffer.bin, 9, 6)) <> 88331643929943 Then Return SetError(3, 0, 0) ;header must contain RIFF and WEBPVP Local $tWebPBitstreamFeatures = DllStructCreate($tagWebPBitstreamFeatures) Local $iReturn = DllCall($sDLL, "long", "WebP_BitmapGetInfo", "struct*", $tBuffer, "uint", $iFileSize, "struct*", $tWebPBitstreamFeatures) If $iReturn = 0 Then Return SetError(4, 0, 0) Return $tWebPBitstreamFeatures EndFunc ;==>WebP_BitmapGetInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapCreateGDIp ; Description ...: Converts (decodes) a WebP image from disk to a GDI / GDI+ bitmap handle ; Syntax ........: WebP_BitmapCreateGDIp($sFilename[, $bGDIImage = False[, $bDither = False[, $iDitherStrength = 32[, ; $bCountColors = False[, $sPath2DLL = ""]]]]]) ; Parameters ....: $sFilename - file to load ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). If True then output is GDI bitmap handle. ; $bDither - [optional] a boolean value. Default is False. If true pseudo dithering (noise) will applied to image. ; $iDitherStrength - [optional] an integer value. Default is 32. Valid values are from 0 to 64. ; $bCountColors - [optional] a boolean value. Default is False. If True then the colors will be counted and saved in extended. Use @extended to get color count. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: GDI / GDIPlus bitmap handle and color count if $bCountColors = True in extended. ; Author ........: UEZ ; Modified ......: ; Remarks .......: For animated WebP images see below! Dithering makes only sense for images which are heavily compressed. ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapCreateGDIp($sFilename, $bGDIImage = False, $bDither = False, $iDitherStrength = 32, $bCountColors = False, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) ;file not found $iDitherStrength = $iDitherStrength > 64 ? 64 : $iDitherStrength < 0 ? 0 : $iDitherStrength Local $iFileSize = FileGetSize($sFilename), $nBytes If $iFileSize < 1 Then Return SetError(3, 0, 0) Local $tBuffer = DllStructCreate("byte bin[" & $iFileSize & "]") Local Const $hFile = _WinAPI_CreateFile($sFilename, 2, 2) _WinAPI_ReadFile($hFile, $tBuffer, $iFileSize, $nBytes) _WinAPI_CloseHandle($hFile) If Int(BinaryMid($tBuffer.bin, 1, 4)) <> 1179011410 Or Int(BinaryMid($tBuffer.bin, 9, 6)) <> 88331643929943 Then Return SetError(4, 0, 0) ;header must contain RIFF and WEBPVP Local $tColors = DllStructCreate("struct;ulong cc;endstruct") Local Const $hBitmap = DllCall($sDLL, "ptr", "WebP_BitmapCreateGDIp", "struct*", $tBuffer, "uint", $iFileSize, "boolean", $bDither, "ubyte", $iDitherStrength, "boolean", $bGDIImage, "boolean", $bCountColors, "struct*", $tColors)[0] If $hBitmap = 0 Then Return SetError(5, 0, 0) Return SetExtended($tColors.cc, $hBitmap) EndFunc ;==>WebP_BitmapCreateGDIp ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_BitmapCreateGDIpFromMem ; Description ...: Converts (decodes) a WebP image from memory to a GDI / GDI+ bitmap handle ; Syntax ........: WebP_BitmapCreateGDIpFromMem($tBuffer[, $iBufferSize = 0[, $bGDIImage = False[, $bDither = False[, ; $iDitherStrength = 32[, $bCountColors = False[, $sPath2DLL = ""]]]]]]) ; Parameters ....: $tBuffer - a dll struct with WebP binary data as content or pointer to the memory data. ; $iBufferSize - the size of the binary data (file size). ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). If True then output is GDI bitmap handle. ; $bDither - [optional] a boolean value. Default is False. If true pseudo dithering (noise) will applied to image. ; $iDitherStrength - [optional] an integer value. Default is 32. Valid values are from 0 to 64. ; $bCountColors - [optional] a boolean value. Default is False. If True then the colors will be counted and saved in extended. Use @extended to get color count. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir ; Return values .: GDI / GDIPlus bitmap handle and color count if $bCountColors = True in extended. ; Author ........: UEZ ; Modified ......: ; Remarks .......: Currently only WebP images are supported - no animated WebP images yet! ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_BitmapCreateGDIpFromMem($tBuffer, $iBufferSize = 0, $bGDIImage = False, $bDither = False, $iDitherStrength = 32, $bCountColors = False, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $iBufferSize = 0 Then Return SetError(2, 0, 0) Local $binMem If IsPtr($tBuffer) Then Local $tMem = DllStructCreate("byte bin[" & $iBufferSize & "]", $tBuffer) $binMem = $tMem.bin Else $binMem = DllStructGetData($tBuffer, 1) EndIf If Int(BinaryMid($binMem, 1, 4)) <> 1179011410 Or Int(BinaryMid($binMem, 9, 6)) <> 88331643929943 Then Return SetError(3, 0, 0) ;header must contain RIFF and WEBPVP Local $tColors = DllStructCreate("ulong cc") Local Const $hBitmap = DllCall($sDLL, "ptr", "WebP_BitmapCreateGDIp", "struct*", $tBuffer, "uint", $iBufferSize, "boolean", $bDither, "ubyte", $iDitherStrength, "boolean", $bGDIImage, "boolean", $bCountColors, "struct*", $tColors)[0] If $hBitmap = 0 Then Return SetError(4, 0, 0) Return SetExtended($tColors.cc, $hBitmap) EndFunc ;==>WebP_BitmapCreateGDIpFromMem ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPLossySimpleFromBitmap ; Description ...: Converts a GDI+ bitmap to WebP lossy image and save it to HD ; Syntax ........: WebP_CreateWebPLossySimpleFromBitmap($sFilename, $hBitmap[, $iQuality = 75[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename - file to load ; $hBitmap - GDIPlus bitmap handle ; $iQuality - [optional] an integer value. Default is 75. Valid range is 0 - 100. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -4 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPLossySimpleFromBitmap($sFilename, $hBitmap, $iQuality = 75, $sPath2DLL = "") If $sFilename = "" Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPLossySimpleFromBitmap", "wstr", $sFilename, "ptr", $hBitmap, "float", $iQuality)[0] If $iReturn = 0 Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>WebP_CreateWebPLossySimpleFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPLosslessSimpleFromBitmap ; Description ...: Converts a GDI+ bitmap to WebP lossless image and save it to HD ; Syntax ........: WebP_CreateWebPLosslessSimpleFromBitmap($sFilename, $hBitmap[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - file to load ; $hBitmap - GDIPlus bitmap handle ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 0 for failure, 1 for success. ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPLosslessSimpleFromBitmap($sFilename, $hBitmap, $sPath2DLL = "") If $sFilename = "" Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPLosslessSimpleFromBitmap", "wstr", $sFilename, "ptr", $hBitmap)[0] If $iReturn = 0 Then Return SetError(3, 0, 0) Return 1 EndFunc ;==>WebP_CreateWebPLosslessSimpleFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPAdvancedFromBitmap ; Description ...: Converts a bitmap to WebP lossy / lossless image and save it to HD ; Syntax ........: WebP_CreateWebPAdvancedFromBitmap($sFilename, $hBitmap[, $lossless = 0[, $quality = 75.0[, $method = 4[, ; $sns_strength = 50[, $filter_sharpness = 0[, $filter_strength = 60[, $pass = 6[, $near_lossless = 100[, ; $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, $target_size = 0[, ; $WebPImageHint = $WEBP_HINT_DEFAULT[, $NoSave = False[, $sPath2DLL = ""]]]]]]]]]]]]]]]) ; Parameters ....: $sFilename - a string value. ; $hBitmap - a handle value. ; $lossless - [optional] an unknown value. Default is 0. ; $quality - [optional] an unknown value. Default is 75.0. ; $method - [optional] a map. Default is 4. ; $sns_strength - [optional] a string value. Default is 50. ; $filter_sharpness - [optional] a floating point value. Default is 0. ; $filter_strength - [optional] a floating point value. Default is 60. ; $pass - [optional] a pointer value. Default is 6. ; $near_lossless - [optional] a general number value. Default is 100. ; $alpha_compression - [optional] an array of unknowns. Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $NoSave - [optional] an unknown value. Default is False. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: negative value up to -8 for failure, 1 for success or the struct with information (pointers, size) if $NoSave = True ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPAdvancedFromBitmap($sFilename, $hBitmap, $lossless = 0, $quality = 75.0, $method = 4, $sns_strength = 50, _ $filter_sharpness = 0, $filter_strength = 60, $pass = 6, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $NoSave = False, $sPath2DLL = "") If $sFilename = "" And $NoSave = False Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $tMem = DllStructCreate("struct;ptr pPic; ptr pWriter; ptr pMemData; uint memsize;endstruct") Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) .exact = BitAND($near_lossless = 0, $lossless = 1) ? 1 : 0 EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPAdvancedFromBitmap", _ "wstr", $sFilename, _ ;Webp filename "ptr", $hBitmap, _ ;handle to GDI+ bitmap "struct*", $tWebPConfig, _ ;WebP config settings "bool", $NoSave, _ "struct*", $tMem)[0] If $iReturn < 0 Then Return SetError(3, 0, $iReturn) If $NoSave And $tMem.memsize = 0 Then SetError(4, 0, 0) Return $NoSave ? $tMem : $iReturn EndFunc ;==>WebP_CreateWebPAdvancedFromBitmap ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ReencodeWebPImage ; Description ...: Re-encodes a WebP image ; Syntax ........: WebP_ReencodeWebPImage($sFilename, $sOutfile, $tConfig[, $iNewWidth = 0[, $iNewHeight = 0[, $pImageData = 0[, ; $pImageDataSize = 0[, $sPath2DLL = ""]]]]]) ; Parameters ....: $sFilename - a string value. ; $sOutfile - a string value. ; $tConfig - a dll struct value. Must be a struct using $tagWebPConfig! ; $iNewWidth - [optional] an integer value. Default is 0. ; $iNewHeight - [optional] an integer value. Default is 0. ; $pImageData - [optional] a pointer value. Default is 0. A pointer to a memory block with loaded WebP image. ; $pImageDataSize - [optional] a pointer value. Default is 0. Size of the memory block. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -11 ; Author ........: UEZ ; Modified ......: ; Remarks .......: If $pImageData is set, then $sFilename will be ignored in the WebP_ReencodeWebPImage() funtion ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ReencodeWebPImage($sFilename, $sOutfile, $tConfig, $iNewWidth = 0, $iNewHeight = 0, $pImageData = 0, $pImageDataSize = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) If Not IsDllStruct($tConfig) Then Return SetError(3, 0, 0) Local Const $iResult = DllCall($sDLL, "long", "WebP_ReencodeWebPImage", "wstr", $sFilename, "wstr", $sOutfile, "struct*", $tConfig, "ptr", $pImageData, "int", $pImageDataSize, "ushort", $iNewWidth, "ushort", $iNewHeight)[0] If $iResult < 1 Then Return SetError(4, 0, $iResult) Return $iResult EndFunc ;==>WebP_ReencodeWebPImage ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_FreeUp ; Description ...: Release the ressources from $tMem struct ; Syntax ........: WebP_FreeUp(Byref $tMem[, $sPath2DLL = ""]) ; Parameters ....: $tMem - [in/out] a dll struct value. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: https://developers.google.com/speed/webp ; Example .......: No ; =============================================================================================================================== Func WebP_FreeUp(ByRef $tMem, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_FreeUp", "struct*", $tMem)[0] Return $iReturn EndFunc ;==>WebP_FreeUp ; #FUNCTION# ==================================================================================================================== ; Name ..........: BitmapCountColors ; Description ...: Counts the colors used by the bitmap ; Syntax ........: BitmapCountColors($hBitmap) ; Parameters ....: $hBitmap - a handle to a GDI+ bitmap. ; $bGDIImage - [optional] a boolean value. Default is False (GDIPlus bitmap handle). ; Return values .: Number of colors used by the image. ; Author ........: UEZ ; Modified ......: ; Remarks .......: The result may differ from other programs for JPG images depending on the decoder. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func BitmapCountColors($hBitmap = 0, $bGDIImage = False, $sPath2DLL = "") If IsPtr($hBitmap) = 0 Or $hBitmap = 0 Then SetError(1, 0, 0) Local Const $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "ulong", "BitmapCountColors", "ptr", $hBitmap)[0] If Not $iReturn Or @error Then Return SetError(3, 0, 0) Return $iReturn EndFunc ;==>BitmapCountColors ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ExtractAnimFramesToDisk ; Description ...: Extracts the frames of a WebP animated file ; Syntax ........: WebP_ExtractAnimFramesToDisk($sFile, $sDestPath = ""[, $sOutputFormat = "webp"[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename - path to webp anim file. ; $sDestPath - destination folder. If empty then script path will be used. ; $sOutputFormat - [optional] a string value. Default is "webp". Any GDI+ supported or WebP image format. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: number of extracted frames on success, otherwise error -> -1 to -3 ; Author ........: UEZ ; Modified ......: ; Remarks .......: If output image format is WebP then frames will be saved lossless. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ExtractAnimFramesToDisk($sFilename, $sDestPath = "", $sOutputFormat = "webp", $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local Const $iResult = DllCall($sDLL, "long", "WebP_ExtractAnimFramesToDisk", "wstr", $sFilename, "wstr", $sDestPath, "str", StringStripWS($sOutputFormat, $STR_STRIPALL))[0] If $iResult < 1 Then Return SetError(2, 0, $iResult) Return $iResult EndFunc ;==>WebP_ExtractAnimFramesToDisk ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetAmountOfAnimFrames ; Description ...: Get the amount of frames from an animated webp file ; Syntax ........: WebP_GetAmountOfAnimFrames($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 0 for failure, otherwise the amount of frames ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetAmountOfAnimFrames($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local Const $iResult = DllCall($sDLL, "uint", "WebP_GetAmountOfAnimFrames", "wstr", $sFilename)[0] If Not $iResult Or @error Then Return SetError(2, 0, 0) Return $iResult EndFunc ;==>WebP_GetAmountOfAnimFrames ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ExtractAnimFramesToMem ; Description ...: Extracts all frames from a webp animated file to the memory ; Syntax ........: WebP_ExtractAnimFramesToMem($sFilename, Byref $iUB[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $iUB - [in/out] an integer value. Needed to save the amount of data in struct array -> frames * 2 ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 0 for failure, otherwise struct array with pointer to the GDI+ image and frame delay ; Author ........: UEZ ; Modified ......: ; Remarks .......: You must dispose all frames when done. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ExtractAnimFramesToMem($sFilename, ByRef $iUB, $bDither = False, $iDitherStrength = 32, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iFrames = WebP_GetAmountOfAnimFrames($sFilename, $sPath2DLL) If Not $iFrames Or @error Then Return SetError(2, 0, 0) Local $tImgPtr = DllStructCreate((@AutoItX64 ? "int64 array[" : "int array[") & $iFrames * 2 + 2 & "]") Local Const $iResult = DllCall($sDLL, "long", "WebP_ExtractAnimFramesToMem", "wstr", $sFilename, "ptr*", DllStructGetPtr($tImgPtr), "boolean", $bDither, "ubyte", $iDitherStrength)[0] If $iResult < 1 Or @error Then Return SetError(4, $iResult, 0) $iUB = $iFrames * 2 Return $tImgPtr EndFunc ;==>WebP_ExtractAnimFramesToMem ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPCreateAnim ; Description ...: Creates an WebP animation file ; Syntax ........: WebP_CreateWebPCreateAnim($aFilenames, $sOutfile[, $quality = 75.0[, $lossless = 0[, $method = 4[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 6[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPImageHint = $WEBP_HINT_DEFAULT[, $iDefaultDelay = 75[, ; $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]) ; Parameters ....: $aFilenames - an 2D array of pathes to the image files and delay per frame. ; $sOutfile - filename of WebP animation output file. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 0. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 4. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 1. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 0 Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $iDefaultDelay - [optional] an integer value. Default is 75. Delay in milli seconds. ; $pCallback - [optional] a pointer value. Default is 0. Pointer to a callback address for progress hook. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -12 ; Author ........: UEZ ; Modified ......: ; Remarks .......: All frames must have same image dimension. First image defines the dimension of the animation. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPCreateAnim($aFilenames, $sOutfile, $quality = 75.0, $lossless = 1, $method = 4, $filter_strength = 60, $sns_strength = 50, _ $pass = 1, $filter_sharpness = 0, $near_lossless = 0, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $iDefaultDelay = 75, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutfile = "" Then Return SetError(2, 0, 0) If Not IsArray($aFilenames) Or UBound($aFilenames) < 2 Then Return SetError(3, 0, 0) Local $iNumberOfFrames = UBound($aFilenames), $i Local $tArrayFrames = DllStructCreate("ptr ptr[" & $iNumberOfFrames & "]"), $tArrayFramesDelay = DllStructCreate("uint delay[" & $iNumberOfFrames & "]") Local $tArrayAnim[$iNumberOfFrames], $tArrayFrameDelay[$iNumberOfFrames], $aDim, $iW, $iH For $i = 0 To $iNumberOfFrames - 1 If Not FileExists($aFilenames[$i][0]) Then Return SetError(4, 0, 0) $tArrayAnim[$i] = DllStructCreate("wchar path[" & StringLen($aFilenames[$i][0]) + 1 & "]") $tArrayAnim[$i].path = $aFilenames[$i][0] $tArrayFrames.ptr(($i + 1)) = DllStructGetPtr($tArrayAnim[$i]) $tArrayFramesDelay.delay(($i + 1)) = (UBound($aFilenames, 2) ? ($aFilenames[$i][1] > 0 ? $aFilenames[$i][1] : $iDefaultDelay) : $iDefaultDelay) Next Local $tAnim = DllStructCreate("ptr pFrames;ptr pDelays") $tAnim.pFrames = DllStructGetPtr($tArrayFrames) $tAnim.pDelays = DllStructGetPtr($tArrayFramesDelay) If StringRight($sOutfile, 5) <> ".webp" Then $sOutfile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPCreateAnim", _ "struct*", $tAnim, _ ;array of filenames with GDi+ supported images and delay per frame "uint", $iNumberOfFrames, _ ;amount of frames "wstr", $sOutfile, _ ;output filename "long", $loop_count, _ ;loop count -> 0 = endless "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(7, 0, $iReturn) ReDim $tArrayAnim[0] ReDim $tArrayFrameDelay[0] Return 1 EndFunc ;==>WebP_CreateWebPCreateAnim ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_CreateWebPCreateAnimFromScreenCapture ; Description ...: Capture the screen to WebP animation file ; Syntax ........: WebP_CreateWebPCreateAnimFromScreenCapture($x, $y, $w, $h, $sec, $sOutfile[, $fps = 30[, $CapCursor = 1[, ; $quality = 75.0[, $lossless = 0[, $method = 0[, $filter_strength = 60[, $sns_strength = 50[, $pass = 1[, ; $level = 6[, $filter_sharpness = 0[, $near_lossless = 100[, $alpha_compression = 0[, ; $alpha_filtering = 0[, $alpha_quality = 100[, $target_size = 0[, $loop_count = 0[, ; $WebPPreset = $WEBP_HINT_DEFAULT[, $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]]]) ; Parameters ....: $x - x position on the screen where to start the capturing. ; $y - y position on the screen where to start the capturing. ; $w - width of the screen to capture. ; $h - height of the screen to capture. ; $sec - seconds to capture ; $sOutfile - filename of WebP animation output file. ; $fps - [optional] a floating point value. Default is 30 fps. ; $CapCursor - [optional] an unknown value. Default is 1. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 0. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 0. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 1. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 0. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 0. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPImageHint - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $pCallback - [optional] a pointer value. Default is 0. Callback pointer for progress status ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -9 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_CreateWebPCreateAnimFromScreenCapture($x, $y, $w, $h, $sec, $sOutfile, $fps = 30, $CapCursor = 1, $quality = 75.0, $lossless = 0, $method = 0, $filter_strength = 60, $sns_strength = 50, _ $pass = 1, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 0, $alpha_filtering = 0, $alpha_quality = 100, $target_size = 0, $loop_count = 0, _ $WebPImageHint = $WEBP_HINT_DEFAULT, $pCallback = 0, $sPath2DLL = "") If $w < 1 Or $h < 1 Or $fps < 1 Or $sec < 1 Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_CreateWebPCreateAnimFromScreenCapture", _ "long", $x, _ ;x position of the screen "long", $y, _ ;y position of the screen "ulong", $w, _ ;width of the screen to capture "ulong", $h, _ ;height of the screen to capture "long", $sec, _ ;duration in seconds "ushort", $fps, _ ;fps for capturing "wstr", $sOutfile, _ ;output file name "ubyte", $CapCursor, _ ;capture cursor "long", $loop_count, _ ;loop count -> 0 = endless. "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ;==>WebP_CreateWebPCreateAnimFromScreenCapture ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ConvertGIF2WebP ; Description ...: Converts a GIF animation to WebP animation ; Syntax ........: WebP_ConvertGIF2WebP($sGIFAnimFile, $sOutWebPFile[, $quality = 75.0[, $lossless = 1[, $method = 6[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 10[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPPreset = $WEBP_HINT_DEFAULT[, $pCallback = 0[, ; $sPath2DLL = ""]]]]]]]]]]]]]]]]) ; Parameters ....: $sGIFAnimFile - a string value. ; $sOutWebPFile - a string value. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 1. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 6. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 10. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPPreset - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -11 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ConvertGIF2WebP($sGIFAnimFile, $sOutWebPFile, $quality = 75.0, $lossless = 1, $method = 6, $filter_strength = 60, $sns_strength = 50, _ $pass = 10, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutWebPFile = "" Then Return SetError(2, 0, 0) If StringRight($sOutWebPFile, 5) <> ".webp" Then $sOutWebPFile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith Local $iReturn = DllCall($sDLL, "long", "WebP_ConvertGIF2WebP", _ "wstr", $sGIFAnimFile, _ ;GIF animated input file "wstr", $sOutWebPFile, _ ;WebP animation output file "long", $loop_count, _ ;loop count -> 0 = endless "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ;==>WebP_ConvertGIF2WebP ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ConvertAPNG2WebP ; Description ...: Converts a PNG animation to WebP animation ; Syntax ........: WebP_ConvertAPNG2WebP($sAPNGAnimFile, $sOutWebPFile[, $quality = 75.0[, $lossless = 1[, $method = 5[, ; $filter_strength = 60[, $sns_strength = 50[, $pass = 10[, $filter_sharpness = 0[, ; $near_lossless = 100[, $alpha_compression = 1[, $alpha_filtering = 1[, $alpha_quality = 100[, ; $target_size = 0[, $loop_count = 0[, $WebPPreset = $WEBP_HINT_DEFAULT[, $iDefaultDelay = 50[, ; $pCallback = 0[, $sPath2DLL = ""]]]]]]]]]]]]]]]]]]) ; Parameters ....: $sAPNGAnimFile - a string value. ; $sOutWebPFile - a string value. ; $quality - [optional] an unknown value. Default is 75.0. Valid range is 0 - 100. ; $lossless - [optional] an unknown value. Default is 1. 0 for lossy encoding / 1 for lossless. ; $method - [optional] a map. Default is 6. Valid range is 0 - 6 (0=fast, 6=slower-better). ; $filter_strength - [optional] a floating point value. Default is 60. Range: [0 = off .. 100 = strongest] ; $sns_strength - [optional] a string value. Default is 50. Spatial Noise Shaping. 0=off, 100=maximum ; $pass - [optional] a pointer value. Default is 10. Number of entropy-analysis passes (in [1..10]). ; $filter_sharpness - [optional] a floating point value. Default is 0. Range: [0 = off .. 7 = least sharp] ; $near_lossless - [optional] a general number value. Default is 100. Near lossless encoding [0 = max loss .. 100 = off (default)]. ; $alpha_compression - [optional] an array of unknowns. Default is 1. Algorithm for encoding the alpha plane (0 = none,1 = compressed with WebP lossless). Default is 1. ; $alpha_filtering - [optional] an array of unknowns. Default is 1. Predictive filtering method for alpha plane.0: none, 1: fast, 2: best. Default if 1. ; $alpha_quality - [optional] an array of unknowns. Default is 100. Between 0 (smallest size) and 100 (lossless). Default is 100. ; $target_size - [optional] a dll struct value. Default is 0. If non-zero, set the desired target size in bytes. ; $loop_count - [optional] an unknown value. Default is 0. 0 = endless. ; $WebPPreset - [optional] an unknown value. Default is $WEBP_HINT_DEFAULT. ; $iDefaultDelay - [optional] an integer value. Default is 50. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -13 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ConvertAPNG2WebP($sAPNGAnimFile, $sOutWebPFile, $quality = 75.0, $lossless = 1, $method = 6, $filter_strength = 60, $sns_strength = 50, _ $pass = 10, $filter_sharpness = 0, $near_lossless = 100, $alpha_compression = 1, $alpha_filtering = 1, $alpha_quality = 100, _ $target_size = 0, $loop_count = 0, $WebPImageHint = $WEBP_HINT_DEFAULT, $iDefaultDelay = 50, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If $sOutWebPFile = "" Then Return SetError(2, 0, 0) If StringRight($sOutWebPFile, 5) <> ".webp" Then $sOutWebPFile &= ".webp" $loop_count = $loop_count < 0 ? 0 : $loop_count Local $tWebPConfig = DllStructCreate($tagWebPConfig) FilltWebPConfigWithDefaults($tWebPConfig) With $tWebPConfig .lossless = $lossless .quality = ($quality < 0) ? 0 : (($quality > 100) ? 100 : $quality) .method = ($method < 0) ? 0 : (($method > 6) ? 6 : $method) .image_hint = ($WebPImageHint < 0) ? 0 : (($WebPImageHint > 4) ? 4 : $WebPImageHint) .target_size = $target_size ;in bytes .sns_strength = ($sns_strength < 0) ? 0 : (($sns_strength > 100) ? 100 : $sns_strength) .filter_strength = ($filter_strength < 0) ? 0 : (($filter_strength > 100) ? 100 : $filter_strength) .filter_sharpness = ($filter_sharpness < 0) ? 0 : (($filter_sharpness > 7) ? 7 : $filter_sharpness) .alpha_compression = $alpha_compression .alpha_filtering = ($alpha_filtering < 0) ? 0 : (($alpha_filtering > 2) ? 2 : $alpha_filtering) .alpha_quality = ($alpha_quality < 0) ? 0 : (($alpha_quality > 100) ? 100 : $alpha_quality) .pass = ($pass < 0) ? 0 : (($pass > 10) ? 10 : $pass) .thread_level = 1 .near_lossless = ($near_lossless < 0) ? 0 : (($near_lossless > 100) ? 100 : $near_lossless) EndWith $iDefaultDelay = ($iDefaultDelay < 0) ? 0 : $iDefaultDelay Local $iReturn = DllCall($sDLL, "long", "WebP_ConvertAPNG2WebP", _ "wstr", $sAPNGAnimFile, _ ;GIF animated input file "wstr", $sOutWebPFile, _ ;WebP animation output file "long", $loop_count, _ ;loop count -> 0 = endless "long", $iDefaultDelay, _ ;delay of each frame "struct*", $tWebPConfig, _ ;WebP config settings "ptr", $pCallback)[0] ;callback pointer for progress status If $iReturn < 1 Then Return SetError(3, 0, $iReturn) Return 1 EndFunc ;==>WebP_ConvertAPNG2WebP ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ReencodeAnimWebPImage ; Description ...: Re-encodes a WebP animated image ; Syntax ........: WebP_ReencodeAnimWebPImage($sFilename, $sOutfile, $tConfig[, $iNewWidth = 0[, $iNewHeight = 0[, ; $sPath2DLL = ""]]]) ; Parameters ....: $sFilename - a string value. ; $sOutfile - a string value. ; $tConfig - a dll struct value. ; $iNewWidth - [optional] an integer value. Default is 0. ; $iNewHeight - [optional] an integer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". ; Return values .: 1 on success, otherwise error -> -1 to -10 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ReencodeAnimWebPImage($sFilename, $sOutfile, $tConfig, $iNewWidth = 0, $iNewHeight = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) If Not IsDllStruct($tConfig) Then Return SetError(3, 0, 0) Local Const $iResult = DllCall($sDLL, "long", "WebP_ReencodeAnimWebPImage", "wstr", $sFilename, "wstr", $sOutfile, "struct*", $tConfig, "ushort", $iNewWidth, "ushort", $iNewHeight)[0] If $iResult < 1 Then Return SetError(4, 0, $iResult) Return $iResult EndFunc ;==>WebP_ReencodeAnimWebPImage ; #FUNCTION# ==============================================================================================================DllCallbackGetPtr($iCB)====== ; Name ..........: WebP_GetAnimFileInfo ; Description ...: Get information about a WebP anim file ; Syntax ........: WebP_GetAnimFileInfo($sFilename, Byref $tAnimInfo[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - path to webp anim file. ; $tAnimInfo - [in/out] a dll struct value. Must be "ulong Width;ulong Height;ulong FrameCount;ulong Duration;double FPS" ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -6 ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetAnimFileInfo($sFilename, ByRef $tAnimInfo, $sPath2DLL = "") If Not FileExists($sFilename) Then Return SetError(1, 0, 0) Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(2, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_GetAnimFileInfo", "wstr", $sFilename, "struct*", $tAnimInfo)[0] If @error Or $iReturn < 1 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ;==>WebP_GetAnimFileInfo ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetImagesDiffFromFile ; Description ...: Displays the difference of two WebP images. ; Syntax ........: WebP_GetImagesDiffFromFile($sFilename1, $sFilename2[, $iMetricType = 1[, $sPath2DLL = ""]]) ; Parameters ....: $sFilename1 - a string value. First WebP image filename. ; $sFilename2 - a string value. Second WebP image filename. ; $iMetricType - [optional] an integer value. Default is 1. Valid values 0 - 2. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: array with distortion values, otherwise error ; Author ........: UEZ ; Modified ......: ; Remarks .......: Possible metric type: ; 0: PSNR - Peak signal-to-noise ratio - measures numerical deviation (higher = better). ; Value range Interpretation ; > 50 dB Excellent quality - barely visible ; 40-50 dB Very good quality ; 30-40 dB Good to medium quality ; < 30 dB Clearly visible losses ; 1: SSIM - Structural Similarity Index - takes visual perception into account (0 - 100, closer to 100 = better). ; Value range Interpretation ; 95 - 100 Almost identical / perfect quality ; 90 - 95 Very good quality ; 85 - 90 Good quality ; < 85 Visible structural differences ; 2: LSIM - Local Similarity - more detailed, for local differences (more experimental). Same as SSIM. ; ; Both images must have same dimension! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetImagesDiffFromFile($sFilename1, $sFilename2, $iMetricType = 1, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename1) Then Return SetError(2, 0, 0) If Not FileExists($sFilename2) Then Return SetError(3, 0, 0) $iMetricType = ($iMetricType > 2) ? 2 : ($iMetricType < 0 ? 0 : $iMetricType) Local $tDistortion = DllStructCreate("float d[5]") Local $iReturn = DllCall($sDLL, "long", "WebP_GetImagesDiffFromFile", "wstr", $sFilename1, "wstr", $sFilename2, "long", $iMetricType, "ptr*", DllStructGetPtr($tDistortion))[0] If $iReturn < 1 Then SetError(4, 0, $iReturn) Local $aDistortion[5] = [$tDistortion.d((1)), $tDistortion.d((2)), $tDistortion.d((3)), $tDistortion.d((4)), $tDistortion.d((5))] Return $aDistortion EndFunc ;==>WebP_GetImagesDiffFromFile ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_ScaleImage ; Description ...: Resizes a WebP image. ; Syntax ........: WebP_ScaleImage($sSourceFile, $iW, $iH, $sDestFile[, $sPath2DLL = ""]) ; Parameters ....: $sSourceFile - source WebP file to load. ; $iW - an integer value. ; $iH - an integer value. ; $sDestFile - destination WebP file to save. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 to -9 ; Author ........: UEZ ; Modified ......: ; Remarks .......: Resized image will be saved lossless. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_ScaleImage($sSourceFile, $iW, $iH, $sDestFile, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found Local $iReturn = DllCall($sDLL, "long", "WebP_ScaleImage", "wstr", $sSourceFile, "long", $iW, "long", $iH, "wstr", $sDestFile)[0] If $iReturn < 1 Then SetError(2, 0, $iReturn) Return 1 EndFunc ;==>WebP_ScaleImage ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_GetImageQuality ; Description ...: Estimates the quality of a WebP image. ; Syntax ........: WebP_GetImageQuality($sFilename[, $sPath2DLL = ""]) ; Parameters ....: $sFilename - source WebP file to load. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: the quality of the WebP image. 0 - 100 for lossy - 101 for lossless. 0 or negative value on error. ; Author ........: UEZ ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_GetImageQuality($sFilename, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) Local $iReturn = DllCall($sDLL, "long", "WebP_GetImageQuality", "wstr", $sFilename)[0] If $iReturn < 0 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ;==>WebP_GetImageQuality ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_PlayAnimFile ; Description ...: Plays an animated WebP file and display it in the GUI ; Syntax ........: WebP_PlayAnimFile($sFilename, $hGUI[, $w = 0[, $h = 0[, $pCallback = 0[, $sPath2DLL = ""]]]]) ; Parameters ....: $sFilename - path to webp anim file. ; $hGUI - the handle to the GUI to copy the frames to it. ; $w - [optional] an unknown value. Default is 0. If 0 the width from the animation file will be used. ; $h - [optional] a handle value. Default is 0. If 0 the height from the animation file will be used. ; $pCallback - [optional] a pointer value. Default is 0. ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: a pointer to the thread on success, otherwise error -> 0 ; Author ........: UEZ ; Modified ......: ; Remarks .......: Don't use $pCallback yet because it is not working properly! Don't forget DllClose($g_hDLL) when done! DllOpen must be used otherwise crash. ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_PlayAnimFile($sFilename, $hGUI, $w = 0, $h = 0, $pCallback = 0, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not FileExists($sFilename) Then Return SetError(2, 0, 0) $g_hDLL = DllOpen($sDLL) Local $pReturn = DllCall($g_hDLL, "ptr", "WebP_PlayAnimFile", "wstr", $sFilename, "hwnd", HWnd($hGUI), "ulong", $w, "ulong", $h, "ptr", $pCallback)[0] If $pReturn = 0 Then SetError(3, 0, 0) Return $pReturn EndFunc ;==>WebP_PlayAnimFile ; #FUNCTION# ==================================================================================================================== ; Name ..........: WebP_StopAnimFile ; Description ...: Stops the animation which was started by WebP_PlayAnimFile() function. ; Syntax ........: WebP_StopAnimFile($pThread[, $sPath2DLL = ""]) ; Parameters ....: $pThread - a thread parameter pointer ; $sPath2DLL - [optional] a string value. Default is "". Path to WebP dll if not in script dir. ; Return values .: 1 on success, otherwise error -> -1 ; Author ........: UEZ ; Modified ......: ; Remarks .......: You must call WebP_PlayAnimFile() before you call WebP_StopAnimFile()! Don't forget DllClose($g_hDLL) when done! ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func WebP_StopAnimFile($pThread, $sPath2DLL = "") Local $sDLL = Path2DLL($sPath2DLL) If Not FileExists($sDLL) Then Return SetError(1, 0, 0) ;DLL not found If Not $g_hDLL Then Return SetError(2, 0, 0) Local $iReturn = DllCall($g_hDLL, "long", "WebP_StopAnimFile", "ptr", $pThread)[0] If $iReturn < 1 Then SetError(3, 0, $iReturn) Return $iReturn EndFunc ;==>WebP_StopAnimFile ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_MarkScreenRegion ; Description ...: Selected area on desktop will be captured and save to clipbord or GDI bitmap handle will be returned. ; Syntax ........: _WinAPI_MarkScreenRegion([$iFillMode = 0]) ; Parameters ....: $iFillMode - [optional] an integer value. Default is 0. ; 0: marked area filled with solid color ; 1: marked area filled with hatch pattern ($HS_DIAGCROSS) ; 2: marked area without any fill pattern / color - only red border ; Return values .: 0 / 1 / -1 / array with coordinates [x, y, w, h] ; Author ........: UEZ ; Version .......: 0.90 build 2025-06-27 ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: no ; =============================================================================================================================== Func _WinAPI_MarkScreenRegion($iFillMode = 0) If @OSBuild > 6299 Then ;https://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx DllCall("Shcore.dll", "long", "PROCESS_DPI_AWARENESS", 1) ;PROCESS_SYSTEM_DPI_AWARE = 1 (https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx) Else DllCall("User32.dll", "bool", "SetProcessDPIAware") EndIf Local $iOld = AutoItSetOption("MouseCoordMode", 1) Local Const $hDesktop = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]") Local Const $aFullScreen = WinGetPos($hDesktop) ;should work also on multi screens Local Const $iW = $aFullScreen[2], $iH = $aFullScreen[3] Local Const $hGUI_MarkScreen = GUICreate("", $iW, $iH, $aFullScreen[0], $aFullScreen[1], $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState(@SW_SHOW, $hGUI_MarkScreen) Local Const $hDC = _WinAPI_GetDC($hGUI_MarkScreen) Local Const $hGfxDC = _WinAPI_CreateCompatibleDC($hDC) Local Const $hBitmapGDI = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local $hObjOld = _WinAPI_SelectObject($hGfxDC, $hBitmapGDI) Local $tSize = DllStructCreate($tagSIZE) $tSize.x = $iW $tSize.y = $iH Local $tSource = DllStructCreate($tagPOINT) Local $tBlend = DllStructCreate($tagBLENDFUNCTION) $tBlend.Alpha = 0xFF $tBlend.Format = 1 Local $tDest = DllStructCreate($tagPOINT), $pPoint = DllStructGetPtr($tDest) $tDest.x = $aFullScreen[0] $tDest.y = $aFullScreen[1] Local Const $hPen = _WinAPI_CreatePen($PS_SOLID, 1, 0x0000FF) Local Const $hPen_Orig = _WinAPI_SelectObject($hGfxDC, $hPen) Local $hBrush, $iAlpha2, $iFlag $iFillMode = $iFillMode > 2 ? 2 : $iFillMode < 0 ? 0 : $iFillMode Switch $iFillMode Case 0 $hBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0x808080) $iAlpha2 = 0xA0 $iFlag = $ULW_ALPHA Case 1 $hBrush = _WinAPI_CreateBrushIndirect($BS_HATCHED, 0x808000, $HS_DIAGCROSS) $iAlpha2 = 0x30 $iFlag = $ULW_ALPHA Case 2 $hBrush = _WinAPI_CreateBrushIndirect($BS_HOLLOW, 0x000000) $iAlpha2 = 0xFF ;not needed $iFlag = $ULW_COLORKEY EndSwitch Local $hBrush_Orig = _WinAPI_SelectObject($hGfxDC, $hBrush) Local $aMPos[5], $aMPos_old[4], $tRECT = _WinAPI_CreateRect(0, 0, 0, 0) Do GUISetCursor(16, 1, $hGUI_MarkScreen) $aMPos = GUIGetCursorInfo($hGUI_MarkScreen) $aMPos_old[0] = $aMPos[0] $aMPos_old[1] = $aMPos[1] $aMPos_old[2] = MouseGetPos(0) $aMPos_old[3] = MouseGetPos(1) Switch $aMPos[2] Case 0 ;display crosshair _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) _WinAPI_DrawLine($hGfxDC, $tDest.x, $aMPos[1], $iW, $aMPos[1]) _WinAPI_DrawLine($hGfxDC, $aMPos[0], $tDest.y, $aMPos[0], $iH) _WinAPI_UpdateLayeredWindow($hGUI_MarkScreen, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $ULW_COLORKEY) Case 1 ; $tBlend.Alpha = $iAlpha2 While $aMPos[2] ;mark region GUISetCursor(14, 1, $hGUI_MarkScreen) ;WinGetHandle(AutoItWinGetTitle())) $aMPos = GUIGetCursorInfo($hGUI_MarkScreen) _WinAPI_BitBlt($hGfxDC, 0, 0, $iW, $iH, $hGfxDC, 0, 0, $CAPTUREBLT) ;clear bitmap ;draw rectangle $tRECT.Left = $aMPos_old[0] $tRECT.Top = $aMPos_old[1] $tRECT.Right = $aMPos[0] $tRECT.Bottom = $aMPos[1] _WinAPI_Rectangle($hGfxDC, $tRECT) If $iFillMode <> 2 Then _WinAPI_InvertRect($hGfxDC, $tRECT) _WinAPI_UpdateLayeredWindow($hGUI_MarkScreen, $hDC, $tDest, $tSize, $hGfxDC, $tSource, 0, $tBlend, $iFlag) Sleep(10) WEnd _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_MarkScreen, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) _WinAPI_SelectObject($hGfxDC, $hBrush_Orig) _WinAPI_DeleteObject($hBrush) GUIDelete($hGUI_MarkScreen) AutoItSetOption("MouseCoordMode", $iOld) Local $aCoords[4] = [($aMPos[0] > $aMPos_old[2] ? $aMPos_old[2] : $aMPos[0]), ($aMPos[1] > $aMPos_old[3] ? $aMPos_old[3] : $aMPos[1]), Abs($tRECT.Right - $tRECT.Left) + 1, Abs($tRECT.Bottom - $tRECT.Top) + 1] Return $aCoords EndSwitch Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_SelectObject($hGfxDC, $hObjOld) _WinAPI_ReleaseDC($hGUI_MarkScreen, $hDC) _WinAPI_DeleteDC($hGfxDC) _WinAPI_DeleteObject($hBitmapGDI) _WinAPI_SelectObject($hGfxDC, $hPen_Orig) _WinAPI_DeleteObject($hPen) GUIDelete($hGUI_MarkScreen) AutoItSetOption("MouseCoordMode", $iOld) Return -1 EndSwitch Until False EndFunc ;==>_WinAPI_MarkScreenRegion ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: Path2DLL ; Description ...: Return the path to the _WebP_x??.dll ; Author ........: UEZ ; Modified.......: ; Remarks .......: This function is used internally by WebP.au3 ; =============================================================================================================================== Func Path2DLL($sPath2DLL = "") Return $sPath2DLL ? $sPath2DLL : @ScriptDir & (@AutoItX64 ? "\_WebP_x64.dll" : "\_WebP_x86.dll") EndFunc ;==>Path2DLL ; #INTERNAL_USE_ONLY#============================================================================================================ ; Name...........: FilltWebPConfigWithDefaults ; Description ...: Set the default $tWebPConfig struct parameters ; Author ........: UEZ ; Modified.......: ; Remarks .......: This function is used internally by WebP.au3 ; =============================================================================================================================== Func FilltWebPConfigWithDefaults(ByRef $tWebPConfig) With $tWebPConfig .lossless = 0 .quality = 75 .method = 4 .image_hint = 0 .target_size = 0 .target_PSNR = 0 .segments = 4 .sns_strength = 50 .filter_strength = 60 .filter_sharpness = 0 .filter_type = 1 .autofilter = 0 .alpha_compression = 1 .alpha_filtering = 1 .alpha_quality = 100 .pass = 1 .show_compressed = 0 .preprocessing = 0 .partitions = 0 .partition_limit = 0 .emulate_jpeg_size = 0 .thread_level = 0 .low_memory = 0 .near_lossless = 100 .exact = 0 .use_delta_palette = 0 .use_sharp_yuv = 0 .qmin = 0 .qmax = 100 EndWith EndFunc ;==>FilltWebPConfigWithDefaults WebP Advanced Encoder GUI: ;Coded by UEZ build 2025-08-06 #AutoIt3Wrapper_UseX64=n #AutoIt3Wrapper_Res_HiDpi=n #AutoIt3Wrapper_Version=p #AutoIt3Wrapper_Compile_Both=y #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/so /pe ;/rm #AutoIt3Wrapper_Run_After=del /f /q "%scriptdir%\%scriptfile%_stripped.au3" #pragma compile(Icon, WebP_logo_2010_by_Simo99.ico) #pragma compile(FileVersion, 0.9.9.1) #pragma compile(ProductVersion, 3.3.16.1) #pragma compile(CompanyName, "UEZ Software Development") #pragma compile(ProductName, "WebP Advanced Encoder GUI") AutoItSetOption("MustDeclareVars", 1) #include <Array.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <GuiStatusBar.au3> #include <Memory.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> #include "WebP.au3" Break(0) If @OSBuild < 10240 Then MsgBox($MB_ICONWARNING, "Warning", "Your Windows version is not support!", 30) If WebP_Ver2() < "0.4.3" Then Exit MsgBox($MB_ICONERROR, "ERROR", "DLL Version v0.4.3+ required!", 30) Global Const $ver = "v0.99.1", $build = "build 2025-08-06" #Region TichySID Global Const $tagIMAGE_DOS_HEADER = 'WORD e_magic;WORD e_cblp;WORD e_cp;WORD e_crlc;WORD e_cparhdr;WORD e_minalloc;WORD e_maxalloc;WORD e_ss;WORD e_sp;WORD e_csum;WORD e_ip;WORD e_cs;WORD e_lfarlc;WORD e_ovno;WORD e_res[4];WORD e_oemid;WORD e_oeminfo;WORD e_res2[10];LONG e_lfanew;' Global Const $tagIMAGE_FILE_HEADER = 'WORD Machine;WORD NumberOfSections;DWORD TimeDateStamp;DWORD PointerToSymbolTable;DWORD NumberOfSymbols;WORD SizeOfOptionalHeader;WORD Characteristics;' Global $tagIMAGE_OPTIONAL_HEADER = 'WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;DWORD BaseOfData;PTR ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;PTR SizeOfStackReserve;PTR SizeOfStackCommit;PTR SizeOfHeapReserve;PTR SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;' If @AutoItX64 Then $tagIMAGE_OPTIONAL_HEADER = 'WORD Magic;BYTE MajorLinkerVersion;BYTE MinorLinkerVersion;DWORD SizeOfCode;DWORD SizeOfInitializedData;DWORD SizeOfUninitializedData;DWORD AddressOfEntryPoint;DWORD BaseOfCode;PTR ImageBase;DWORD SectionAlignment;DWORD FileAlignment;WORD MajorOperatingSystemVersion;WORD MinorOperatingSystemVersion;WORD MajorImageVersion;WORD MinorImageVersion;WORD MajorSubsystemVersion;WORD MinorSubsystemVersion;DWORD Win32VersionValue;DWORD SizeOfImage;DWORD SizeOfHeaders;DWORD CheckSum;WORD Subsystem;WORD DllCharacteristics;PTR SizeOfStackReserve;PTR SizeOfStackCommit;PTR SizeOfHeapReserve;PTR SizeOfHeapCommit;DWORD LoaderFlags;DWORD NumberOfRvaAndSizes;' Global Const $tagIMAGE_NT_HEADER = 'DWORD Signature;' & $tagIMAGE_FILE_HEADER & $tagIMAGE_OPTIONAL_HEADER Global Const $tagIMAGE_SECTION_HEADER = 'CHAR Name[8];DWORD VirtualSize;DWORD VirtualAddress;DWORD SizeOfRawData;DWORD PointerToRawData;DWORD PointerToRelocations;DWORD PointerToLinenumbers;WORD NumberOfRelocations;WORD NumberOfLinenumbers;DWORD Characteristics;' Global Const $tagIMAGE_DATA_DIRECTORY = 'DWORD VirtualAddress;DWORD Size;' Global Const $tagIMAGE_BASE_RELOCATION = 'DWORD VirtualAddress;DWORD SizeOfBlock;' Global Const $tagIMAGE_IMPORT_DESCRIPTOR = 'DWORD OriginalFirstThunk;DWORD TimeDateStamp;DWORD ForwarderChain;DWORD Name;DWORD FirstThunk;' Global Const $tagIMAGE_IMPORT_BY_NAME = 'WORD Hint;char Name[1];' Global Const $tagIMAGE_EXPORT_DIRECTORY = 'DWORD Characteristics;DWORD TimeDateStamp;WORD MajorVersion;WORD MinorVersion;DWORD Name;DWORD Base;DWORD NumberOfFunctions;DWORD NumberOfNames;DWORD AddressOfFunctions;DWORD AddressOfNames;DWORD AddressOfNameOrdinals;' Global $_KERNEL32DLL = DllOpen('kernel32.dll') Global $_MFHookPtr, $_MFHookBak, $_MFHookApi = 'LocalCompact' Global Const $tagModule = 'PTR ExportList;PTR CodeBase;PTR ImportList;PTR DllEntry;DWORD Initialized;' Global Const $SID_MEMORY = 1 Global Const $SID_NON_DEFAULT = 2 Global $hTitchysidDll, $iSubsongCount = 0 #EndRegion ; enum _PROCESS_DPI_AWARENESS -> https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx Global Enum $DPI_AWARENESS_INVALID = -1, $PROCESS_DPI_UNAWARE = 0, $PROCESS_SYSTEM_DPI_AWARE, $PROCESS_PER_MONITOR_DPI_AWARE ;https://docs.microsoft.com/en-us/windows/desktop/hidpi/dpi-awareness-context Global Enum $Context_UnawareGdiScaled = -5, $Context_PerMonitorAwareV2, $Context_PerMonitorAware, $Context_SystemAware, $Context_Unaware ; enum _MONITOR_DPI_TYPE Global Enum $MDT_EFFECTIVE_DPI = 0, $MDT_ANGULAR_DPI, $MDT_RAW_DPI Global Const $MDT_DEFAULT = $MDT_EFFECTIVE_DPI Global Const $SM_CXPADDEDBORDER = 92 _GDIPlus_Startup() ;~ Global $aDPI = _WinAPI_GetDpiForMonitor() ;_GDIPlus_GraphicsGetDPIRatio() Global $aDPI = [1, 1] Global $hGUI_About, $iFPS = 0, $iShowFPS = 0, $bExit, $bGUIBgColor = 0xFF808080 #Region GUI Global Const $SC_DRAGMOVE = 0xF012, $iW = 322, $iH = 694 Global Const $hGUI = GUICreate("WAE GUI " & $ver & " Beta by UEZ", $iW, $iH, @DesktopWidth - $iW - 8, -1, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_APPWINDOW, $WS_EX_TOPMOST, $WS_EX_NOACTIVATE)) GUISetFont(10 * $aDPI[0], 400, 0, "Arial Narrow") Global Const $Title = GUICtrlCreateLabel("WebP Advanced Encoder GUI", 5, 8, 310, 41) GUICtrlSetFont(-1, 21 * $aDPI[0], 400, 0, "Arial Narrow") Global Const $icLoad = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -127, 8, 60, 32, 32, BitOR($GUI_SS_DEFAULT_ICON, $WS_BORDER)) GUICtrlSetTip(-1, "Load a GDI+ supported image") Global Const $icSave = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -259, 56, 60, 32, 32, BitOR($GUI_SS_DEFAULT_ICON, $WS_BORDER)) GUICtrlSetTip(-1, "Save compressed image in WebP format.") Global Const $icReset = GUICtrlCreateIcon(@SystemDir & "\shell32.dll", -239, 104, 60, 32, 32, BitOR($GUI_SS_DEFAULT_ICON, $WS_BORDER)) GUICtrlSetTip(-1, "Reset image position if image was moved (only for images larger than preview window).") GUICtrlCreateLabel("", 0, 106, $iW - 2, 2, $SS_ETCHEDHORZ) Global Const $lbPresets = GUICtrlCreateLabel("Presets", 10, 125, 39, 20) Global Const $cbPreset = GUICtrlCreateCombo("Default", 120, 120, $iW - 177, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL)), $hcbPreset = GUICtrlGetHandle($cbPreset) GUICtrlSetData(-1, "Picture|Photo|Graph|Last") Global Const $chkbLossless = GUICtrlCreateCheckbox("&Lossless", 120, 152, 97, 17) GUICtrlSetTip(-1, "Enable lossless compression. Default: lossy.") Global Const $lbEncoding = GUICtrlCreateLabel("Encoding", 10, 152, 48, 20) Global Const $lbQuality = GUICtrlCreateLabel("Quality", 10, 176, 36, 20) Global Const $slQuality = GUICtrlCreateSlider(116, 176, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslQuality = GUICtrlGetHandle($slQuality) GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData(-1, 75) GUICtrlSetTip(-1, "Between 0 and 100. 0 gives the smallest size and 100 the largest.") Global Const $ipQuality = GUICtrlCreateInput("", $iW - 48, 172, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slQuality)) Global Const $lbMethod = GUICtrlCreateLabel("Method", 10, 210, 39, 20) Global Const $slMethod = GUICtrlCreateSlider(116, 210, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslMethod = GUICtrlGetHandle($slMethod) GUICtrlSetLimit(-1, 6, 0) GUICtrlSetData(-1, 4) GUICtrlSetTip(-1, "Quality/speed trade-off (0=fast, 6=slower-better.") Global Const $ipMethod = GUICtrlCreateInput("", $iW - 48, 206, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slMethod)) Global Const $lbSNS_Strength = GUICtrlCreateLabel("SNS-Strength", 10, 242, 66, 20) Global Const $slSNS_Strength = GUICtrlCreateSlider(116, 244, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslSNS_Strength = GUICtrlGetHandle($slSNS_Strength) GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData(-1, 50) GUICtrlSetTip(-1, "Spatial Noise Shaping. 0=off, 100=maximum.") Global Const $ipSSN_Strength = GUICtrlCreateInput("", $iW - 48, 240, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slSNS_Strength)) Global Const $lbFilterSharpness = GUICtrlCreateLabel("Filter Sharpness", 10, $iW - 48, 81, 20) Global Const $slFilter_Sharpness = GUICtrlCreateSlider(116, 278, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslFilter_Sharpness = GUICtrlGetHandle($slFilter_Sharpness) GUICtrlSetLimit(-1, 7, 0) GUICtrlSetTip(-1, "Range: [0 = off .. 7 = least sharp].") Global Const $ipFilter_Sharpness = GUICtrlCreateInput("", $iW - 48, 274, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slFilter_Sharpness)) Global Const $lbFilter_Strength = GUICtrlCreateLabel("Filter Strenght", 010, 304, 69, 20) Global Const $slFilter_Strength = GUICtrlCreateSlider(116, 312, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslFilter_Strength = GUICtrlGetHandle($slFilter_Strength) GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData(-1, 60) GUICtrlSetTip(-1, "Range: [0 = off .. 100 = strongest]") Global Const $ipFilter_Strength = GUICtrlCreateInput("", $iW - 48, 308, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slFilter_Strength)) Global Const $lbPass = GUICtrlCreateLabel("Pass", 10, 344, 27, 20) Global Const $slPass = GUICtrlCreateSlider(116, 346, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslPass = GUICtrlGetHandle($slPass) GUICtrlSetLimit(-1, 10, 1) GUICtrlSetData(-1, 1) GUICtrlSetTip(-1, "Number of entropy-analysis passes (in [1..10]).") Global Const $ipPass = GUICtrlCreateInput("", $iW - 48, 342, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slPass)) Global Const $lbNear_Lossless = GUICtrlCreateLabel("Near Lossless", 10, 378, 80, 20) Global Const $slNear_Lossless = GUICtrlCreateSlider(116, 380, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslNear_Lossless = GUICtrlGetHandle($slNear_Lossless) GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData(-1, 100) GUICtrlSetTip(-1, "Specify the level of near-lossless image preprocessing. The range is 0 (maximum preprocessing) to 100 (no preprocessing, the default).") Global Const $ipNear_Lossless = GUICtrlCreateInput("", $iW - 48, 374, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slNear_Lossless)) Global Const $lbLevel = GUICtrlCreateLabel("Level", 10, 411, 30, 20) Global Const $slLevel = GUICtrlCreateSlider(116, 414, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslLevel = GUICtrlGetHandle($slLevel) GUICtrlSetLimit(-1, 9, 0) GUICtrlSetData(-1, 6) GUICtrlSetTip(-1, "Switch on lossless compression mode with the specified level between 0 and 9, with level 0 being the fastest, 9 being the slowest.") GUICtrlSetState(-1, $GUI_DISABLE) Global Const $ipLevel = GUICtrlCreateInput("", $iW - 48, 410, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slLevel)) Global Const $lbAlpha_Compression = GUICtrlCreateLabel("Alpha Compression", 10, 444, 96, 20) Global Const $chkbAlpha_Compression = GUICtrlCreateCheckbox("&Enable", 120, 444, 97, 17) GUICtrlSetState(-1, $GUI_CHECKED) Global Const $lbAlpha_Filtering = GUICtrlCreateLabel("Alpha Filtering", 10, 478, 71, 20) Global Const $slAlpha_Filtering = GUICtrlCreateSlider(114, 482, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslAlpha_Filtering = GUICtrlGetHandle($slAlpha_Filtering) GUICtrlSetLimit(-1, 2, 0) GUICtrlSetData(-1, 1) GUICtrlSetTip(-1, "Predictive filtering method for alpha plane. 0: none, 1: fast, 2: best. Default if 1.") Global Const $ipAlpha_Filtering = GUICtrlCreateInput("", $iW - 48, 478, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slAlpha_Filtering)) Global Const $lbAlpha_Quality = GUICtrlCreateLabel("Alpha Quality", 8, 516, 66, 20) Global Const $slAlpha_Quality = GUICtrlCreateSlider(114, 516, $iW - 164, 21, BitOR($GUI_SS_DEFAULT_SLIDER, $TBS_ENABLESELRANGE)), $hslAlpha_Quality = GUICtrlGetHandle($slAlpha_Quality) GUICtrlSetLimit(-1, 100, 0) GUICtrlSetData(-1, 100) GUICtrlSetTip(-1, "Between 0 (smallest size) and 100 (lossless).") Global Const $ipAlpha_Quality = GUICtrlCreateInput("", $iW - 48, 512, 28, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_CENTER, $ES_READONLY)) GUICtrlSetData(-1, GUICtrlRead($slAlpha_Quality)) Global Const $lbTarget_Size = GUICtrlCreateLabel("Target Size", 10, 552, 58, 20) Global Const $ipTarget_Size = GUICtrlCreateInput("0", 120, 550, $iW - 177, 24, $ES_NUMBER) GUICtrlSetTip(-1, "If non-zero, set the desired target size in bytes (lossy mode only!).") Global Const $chkbCountColors = GUICtrlCreateCheckbox("&Count Colors", 10, 590, 87, 17) Global Const $lbColorOriginal = GUICtrlCreateLabel("Source:", 101, 590, 38, 20) Global Const $ipColorOriginal = GUICtrlCreateInput("0", 142, 588, 60, 24, BitOR($ES_NUMBER, $ES_READONLY)) Global Const $lbColorWebP = GUICtrlCreateLabel("WebP:", 215, 590, 32, 20) Global Const $ipColorWebP = GUICtrlCreateInput("0", 250, 588, 60, 24, BitOR($ES_NUMBER, $ES_READONLY)) Global Const $btnShow = GUICtrlCreateButton("Show Original Image", 10, 630, 123, 25) GUICtrlSetTip(-1, "Press lmb and hold it to display original image.") Global Const $btnApply = GUICtrlCreateButton("&Apply Settings", 188, 630, 123, 25) Global Const $StatusBar = _GUICtrlStatusBar_Create($hGUI), $iSBColor = 0xE9CFEC _WinAPI_SetWindowTheme($StatusBar, "", "") _GUICtrlStatusBar_SetText($StatusBar, " Welcome to 'WebP Advanced Encoder GUI' ٩(●̮̮̃•̃)۶") _GUICtrlStatusBar_SetBkColor($StatusBar, $iSBColor) Global Const $hGUI_Image = GUICreate("", 0, 0, -1, -1, $WS_EX_TOOLWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_APPWINDOW)) GUISetBkColor(BitAND(0xFFFFFF, $bGUIBgColor), $hGUI_Image) Global Const $iPic_WebP = GUICtrlCreatePic("", 0, 0, 0, 0), $hPic_WebP = GUICtrlGetHandle($iPic_WebP) ;~ Global Const $iW_Zoom = @DesktopWidth * 0.25, $iH_Zoom = @DesktopHeight * 0.25 ;~ Global Const $hGUI_Image_Zoom = GUICreate("", $iW_Zoom, $iH_Zoom, 0, 0, $WS_POPUP) Global Const $dw = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME), $dh = _WinAPI_GetSystemMetrics($SM_CYDLGFRAME) + _WinAPI_GetSystemMetrics($SM_CYSIZE) + 1 Global Enum $idAbout = 5000, $idResetPicPos, $idResetValues Global Const $hMenu_Sys = _GUICtrlMenu_GetSystemMenu($hGUI) _GUICtrlMenu_AppendMenu($hMenu_Sys, $MF_SEPARATOR, 0, 0) _GUICtrlMenu_AppendMenu($hMenu_Sys, $MF_STRING, $idAbout, "About") Global Const $hImage_Icon = _GDIPlus_BitmapCreateFromMemory(_WebP_Icon()) Global Const $hIcon = _GDIPlus_HICONCreateFromBitmap($hImage_Icon) _WinAPI_SetClassLongEx($hGUI, -34, $hIcon) _GDIPlus_ImageDispose($hImage_Icon) GUISetState(@SW_HIDE, $hGUI_Image) GUISetState(@SW_SHOW, $hGUI) ;~ GUISetState(@SW_SHOW, $hGUI_Image_Zoom) _WinAPI_SetProcessDpiAwarenessContext($Context_PerMonitorAwareV2, $hGUI, 2) Global Const $iDummy_About = GUICtrlCreateDummy(), $iDummy_Return = GUICtrlCreateDummy() Global $sFileLoad, $hImage, $hImage_GDI, $hHBitmap, $aDim, $aPixelFormat, $pMemData, $pMemData_Size, $tMem, $mp, $sFileSave, $hFile, $nBytes, $nBytes, $iResetPosX, $iResetPosY, _ $hImage_tmp GUIRegisterMsg($WM_DROPFILES, "WM_DROPFILES") GUIRegisterMsg($WM_LBUTTONDOWN, "WM_LBUTTONDOWN") GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") #EndRegion GUI Global $aGUIGetMsg, $aMPos1, $aMPos2, $iMPx, $iMPy, $iMPx_p = 0, $iMPy_p = 0, $bBigger = False, $iResult, $old_cursor, $bNew = False While 1 $mp = GUIGetCursorInfo($hGUI) If $hImage And $mp[2] And $mp[4] = $btnShow Then _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_WebP, $STM_SETIMAGE, $IMAGE_BITMAP, $hImage_GDI)) While $mp[2] $mp = GUIGetCursorInfo($hGUI) Sleep(10) WEnd _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_WebP, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) EndIf $mp = GUIGetCursorInfo($hGUI_Image) $aMPos1 = MouseGetPos() If $mp[4] = $iPic_WebP And $mp[2] And $bBigger And WinActive($hGUI_Image) Then While $mp[2] $mp = GUIGetCursorInfo($hGUI_Image) Sleep(10) $aMPos2 = MouseGetPos() $iMPx = $iMPx_p + $aMPos2[0] - $aMPos1[0] $iMPy = $iMPy_p + $aMPos2[1] - $aMPos1[1] ControlMove($hGUI_Image, "", $iPic_WebP, $iMPx, $iMPy) WEnd $iMPx_p = $iMPx $iMPy_p = $iMPy EndIf $aGUIGetMsg = GUIGetMsg(1) Switch $aGUIGetMsg[1] Case $hGUI Switch $aGUIGetMsg[0] Case $GUI_EVENT_CLOSE GUIRegisterMsg($WM_DROPFILES, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") GUIRegisterMsg($WM_COMMAND, "") GUIRegisterMsg($WM_CONTEXTMENU, "") GUIRegisterMsg($WM_SYSCOMMAND, "") GUIRegisterMsg($WM_HSCROLL, "") ;~ If IsDllStruct($tMem) Then WebP_FreeUp($tMem) _WinAPI_DestroyIcon($hIcon) If $hImage_tmp Then _GDIPlus_ImageDispose($hImage_tmp) If $hImage Then _GDIPlus_ImageDispose($hImage) If $hHBitmap Then _WinAPI_DeleteObject($hHBitmap) If $hImage_GDI Then _WinAPI_DeleteObject($hImage_GDI) If $hGUI_Image Then GUIDelete($hGUI_Image) _GDIPlus_Shutdown() GUIDelete($hGUI_Image) GUIDelete($hGUI) DllClose($_KERNEL32DLL) Exit Case $btnApply, $iDummy_Return If $hImage Then CompressAndDisplay($hImage) EndIf Case $icLoad $sFileLoad = FileOpenDialog("Select an image to compress", "", "Images (*.jpg;*.bmp;*.png;*.gif;*.tif;*webp)") If @error Then ContinueLoop LoadImage($sFileLoad) Case $icSave If $hImage Then $sFileSave = FileSaveDialog("Save WebP Image", "", "WebP Image (*.webp)", BitOR($FD_PATHMUSTEXIST, $FD_PROMPTOVERWRITE), StringRegExpReplace($sFileLoad, ".+\\(.+)\..*", "$1") & ".webp", $hGUI) If @error Then ContinueLoop $hFile = _WinAPI_CreateFile($sFileSave, 1) $iResult = _WinAPI_WriteFile($hFile, $tMem.pMemData, $tMem.memsize, $nBytes) _WinAPI_CloseHandle($hFile) If Not $iResult Then MsgBox($MB_ICONERROR, "ERROR", "Unable to save WebP image to disk!", 30, $hGUI) Else MsgBox($MB_ICONINFORMATION, "Information", "WebP image successfully save to disk", 10, $hGUI) EndIf EndIf Case $icReset ResetImage() Case $slAlpha_Filtering GUICtrlSetData($ipAlpha_Filtering, GUICtrlRead($slAlpha_Filtering)) Case $slAlpha_Quality GUICtrlSetData($ipAlpha_Quality, GUICtrlRead($slAlpha_Quality)) Case $slFilter_Sharpness GUICtrlSetData($ipFilter_Sharpness, GUICtrlRead($slFilter_Sharpness)) Case $slFilter_Strength GUICtrlSetData($ipFilter_Strength, GUICtrlRead($slFilter_Strength)) Case $slLevel GUICtrlSetData($ipLevel, GUICtrlRead($slLevel)) Case $slMethod GUICtrlSetData($ipMethod, GUICtrlRead($slMethod)) Case $slNear_Lossless GUICtrlSetData($ipNear_Lossless, GUICtrlRead($slNear_Lossless)) Case $slPass GUICtrlSetData($ipPass, GUICtrlRead($slPass)) Case $slQuality GUICtrlSetData($ipQuality, GUICtrlRead($slQuality)) Case $slSNS_Strength GUICtrlSetData($ipSSN_Strength, GUICtrlRead($slSNS_Strength)) Case $iDummy_About AutoItSetOption("GUIOnEventMode", 1) GDIPlus_About(11 * $aDPI[0], -12, 24.5) AutoItSetOption("GUIOnEventMode", 0) Case $btnShow If BitAND(WinGetState($hGUI_Image), $WIN_STATE_VISIBLE) = $WIN_STATE_VISIBLE Then WinActivate($hGUI_Image) EndSwitch Case $hGUI_Image Switch $aGUIGetMsg[0] Case $GUI_EVENT_CLOSE EndSwitch EndSwitch WEnd Func ResetImage() If $bBigger Then $iMPx_p = $iResetPosX $iMPy_p = $iResetPosY ControlMove($hGUI_Image, "", $iPic_WebP, $iMPx_p, $iMPy_p) EndIf EndFunc Func LoadImage($sFileLoad) If $hImage_tmp Then _GDIPlus_ImageDispose($hImage_tmp) If $hImage Then _GDIPlus_ImageDispose($hImage) If $hImage_GDI Then _WinAPI_DeleteObject($hImage_GDI) If StringRight($sFileLoad, 5) = ".webp" Then If WebP_GetAmountOfAnimFrames($sFileLoad) > 0 Then Return MsgBox($MB_ICONERROR, "ERROR", "WebP animated image cannot be loaded!", 30, $hGUI) $hImage_tmp = WebP_BitmapCreateGDIp($sFileLoad) If @error Or $hImage_tmp = 0 Then Return MsgBox($MB_ICONERROR, "ERROR", "Unable to decode WebP image!", 30, $hGUI) EndIf Else $hImage_tmp = _GDIPlus_ImageLoadFromFile($sFileLoad) If @error Or $hImage_tmp = 0 Then Return MsgBox($MB_ICONERROR, "ERROR", "Unknown image format!", 30, $hGUI) EndIf EndIf $aPixelFormat = _GDIPlus_ImageGetPixelFormat($hImage_tmp) ;Local Const $aImageRawFormat = _GDIPlus_ImageGetRawFormat($hImage_tmp) If BitAND(GUICtrlRead($chkbCountColors), $GUI_CHECKED) Then GUICtrlSetData($ipColorOriginal, BitmapCountColors($hImage_tmp)) Else GUICtrlSetData($ipColorOriginal, 0) EndIf ;~ If $hImage_tmp Then ConsoleWrite("Original color count: " & BitmapCountColors($hImage_tmp) & @CRLF) $aDim = _GDIPlus_ImageGetDimension($hImage_tmp) $hImage = _GDIPlus_BitmapCreateFromScan0($aDim[0], $aDim[1]) Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hImage) If $aPixelFormat[0] = 2498570 Then _GDIPlus_GraphicsClear($hGfx, $bGUIBgColor) _GDIPlus_GraphicsDrawImageRect($hGfx, $hImage_tmp, 0, 0, $aDim[0], $aDim[1]) _GDIPlus_GraphicsDispose($hGfx) $hImage_GDI = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $bNew = True _WinAPI_LockWindowUpdate($hGUI) CompressAndDisplay($hImage, $aPixelFormat[1]) _WinAPI_LockWindowUpdate(0) EndFunc ;==>LoadImage Func CompressAndDisplay($hImage, $sFormat = "") Local $aDim = _GDIPlus_ImageGetDimension($hImage) If $hHBitmap Then _WinAPI_DeleteObject($hHBitmap) $pMemData = 0 $pMemData_Size = 0 Local $iPreset = GUICtrlRead($cbPreset) Switch $iPreset Case "Default" $iPreset = 0 Case "Picture" $iPreset = 1 Case "Photo" $iPreset = 2 Case "Graph" $iPreset = 3 Case "Last" $iPreset = 4 EndSwitch If IsDllStruct($tMem) Then WebP_FreeUp($tMem) $old_cursor = MouseGetCursor() GUISetCursor(15, 1, $hGUI) _GUICtrlStatusBar_SetBkColor($StatusBar, 192) Local $end, $fTimer = TimerInit() $tMem = WebP_CreateWebPAdvancedFromBitmap("", $hImage, _ BitAND(GUICtrlRead($chkbLossless), $GUI_CHECKED), _ GUICtrlRead($slQuality), _ GUICtrlRead($slMethod), _ GUICtrlRead($slSNS_Strength), _ GUICtrlRead($slFilter_Sharpness), _ GUICtrlRead($slFilter_Strength), _ GUICtrlRead($slPass), _ GUICtrlRead($slNear_Lossless), _ BitAND(GUICtrlRead($chkbAlpha_Compression), $GUI_CHECKED), _ GUICtrlRead($slAlpha_Filtering), _ GUICtrlRead($slAlpha_Quality), _ GUICtrlRead($ipTarget_Size), _ $iPreset, _ True) ;hold the compressed image in memory only, no save to HD! $end = TimerDiff($fTimer) ToolTip("") _GUICtrlStatusBar_SetBkColor($StatusBar, $iSBColor) GUISetCursor($old_cursor, 1, $hGUI) Local $iColorsWebp = 0 If IsDllStruct($tMem) Then _GUICtrlStatusBar_SetText($StatusBar, "WebP size: " & Round($tMem.memsize / 1024, 2) & " kb / encoded in " & Round($end, 2) & " ms.") $hHBitmap = WebP_BitmapCreateGDIpFromMem($tMem.pMemData, $tMem.memsize, 1, 0, 32, BitAND(GUICtrlRead($chkbCountColors), $GUI_CHECKED)) If @error Then Return MsgBox($MB_ICONERROR, "ERROR", "Unable to compress image", 30, $hGUI) $iColorsWebp = @extended GUICtrlSetData($ipColorWebP, $iColorsWebp) If BitAND(GUICtrlRead($chkbCountColors), $GUI_CHECKED) And GUICtrlRead($ipColorOriginal) = "0" Then GUICtrlSetData($ipColorOriginal, BitmapCountColors($hImage_tmp)) ;~ ConsoleWrite("WebP image color count: " & @extended & @CRLF) Local $aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd;INSTANCE:1]", ""), $tbw = 0, $tbh = 0 If $aTaskbar[2] > $aTaskbar[3] Then $tbh = $aTaskbar[3] ELse $tbw = $aTaskbar[2] EndIf Local Const $minw = 384, $minh = $minw * 10 / 16 Local $maxw = Min($aDim[0] + $dw, @DesktopWidth * 0.95), $maxh = Min($aDim[1] + $dh, @DesktopHeight * 0.95), $iNewW = 0, $iNewH = 0 If $aDim[0] + $dw > @DesktopWidth * 0.95 Or $aDim[1] + $dh > @DesktopHeight * 0.95 Then $bBigger = True Else $bBigger = False EndIf If $bNew Then $iNewW = Max($minw, $maxw) $iNewH = Max($minh, $maxh) WinMove($hGUI_Image, "", (@DesktopWidth - $iNewW - (@DesktopWidth - $iW > $iNewW ? $iW : 0)) / 2 - $tbw, (@DesktopHeight - $iNewH - $tbh) / 2, $iNewW, $iNewH) WinSetTitle($hGUI_Image, "", StringRegExpReplace($sFileLoad, ".+\\(.*)", "$1") & " / " & $aDim[0] & "x" & $aDim[1] & " px / " & $sFormat & " / " & Round(FileGetSize($sFileLoad) / 1024, 2) & " kb") $iNewH -= $dh ;_WinAPI_GetSystemMetrics($SM_CXBORDER) + _WinAPI_GetSystemMetrics($SM_CYSIZE) + _WinAPI_GetSystemMetrics($SM_CXPADDEDBORDER) * 2 $iMPx_p = ($iNewW - $aDim[0]) / 2 $iMPy_p = ($iNewH - $aDim[1] - 4) / 2 $iResetPosX = $iMPx_p $iResetPosY = $iMPy_p GUICtrlSetPos($iPic_WebP, $iMPx_p, $iMPy_p, $iNewW - 1, $iNewH - 1) $bNew = False EndIf _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_WebP, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap)) Local Const $iWC_State = WinGetState($hGUI_Image) If $iWC_State <> 7 Or $iWC_State <> 5 Then WinSetState($hGUI_Image, "", @SW_SHOW) WinActivate($hGUI_Image) EndIf WinActivate($hGUI) Else MsgBox($MB_ICONERROR, "ERROR", "DLL encode error " & $tMem, 30) EndIf EndFunc ;==>CompressAndDisplay Func Progress($progress, $ptr) ToolTip($progress & "%", MouseGetPos(0) - 40, MouseGetPos(1)) Return 1 EndFunc Func WM_HSCROLL($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam Switch $lParam Case $hslAlpha_Filtering GUICtrlSetData($ipAlpha_Filtering, GUICtrlRead($slAlpha_Filtering)) Case $hslAlpha_Quality GUICtrlSetData($ipAlpha_Quality, GUICtrlRead($slAlpha_Quality)) Case $hslFilter_Sharpness GUICtrlSetData($ipFilter_Sharpness, GUICtrlRead($slFilter_Sharpness)) Case $hslFilter_Strength GUICtrlSetData($ipFilter_Strength, GUICtrlRead($slFilter_Strength)) Case $hslLevel GUICtrlSetData($ipLevel, GUICtrlRead($slLevel)) Case $hslMethod GUICtrlSetData($ipMethod, GUICtrlRead($slMethod)) Case $hslNear_Lossless GUICtrlSetData($ipNear_Lossless, GUICtrlRead($slNear_Lossless)) Case $hslPass GUICtrlSetData($ipPass, GUICtrlRead($slPass)) Case $hslQuality GUICtrlSetData($ipQuality, GUICtrlRead($slQuality)) Case $hslSNS_Strength GUICtrlSetData($ipSSN_Strength, GUICtrlRead($slSNS_Strength)) EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL Func WM_DROPFILES($hWnd, $iMsg, $wParam, $lParam) Local $i = 1 Local $aFileList = _WinAPI_DragQueryFileEx($wParam) Do If StringInStr(FileGetAttrib($aFileList[$i]), "D") Then _ArrayDelete($aFileList, $i) Else $i += 1 EndIf Until $i = UBound($aFileList) $aFileList[0] = UBound($aFileList) - 1 $sFileLoad = $aFileList[1] _WinAPI_DragFinish($wParam) LoadImage($sFileLoad) Return 0 EndFunc ;==>WM_DROPFILES# Func WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hWnd, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_SYSCOMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Switch BitAND($iwParam, 0x0000FFFF) Case $idAbout GUICtrlSendToDummy($iDummy_About) EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_SYSCOMMAND Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Switch $iwParam Case 1 GUICtrlSendToDummy($iDummy_Return) Return 0 Case $idResetPicPos ResetImage() Return 0 Case $idResetValues GUICtrlSetData($slAlpha_Filtering, 1) GUICtrlSetData($ipAlpha_Filtering, 1) GUICtrlSetData($slAlpha_Quality, 100) GUICtrlSetData($ipAlpha_Quality, 100) GUICtrlSetData($slFilter_Sharpness, 0) GUICtrlSetData($ipFilter_Sharpness, 0) GUICtrlSetData($slFilter_Strength, 60) GUICtrlSetData($ipFilter_Strength, 60) GUICtrlSetData($slLevel, 6) GUICtrlSetData($ipLevel, 6) GUICtrlSetData($slMethod, 4) GUICtrlSetData($ipMethod, 4) GUICtrlSetData($slNear_Lossless, 60) GUICtrlSetData($ipNear_Lossless, 60) GUICtrlSetData($slPass, 6) GUICtrlSetData($ipPass, 6) GUICtrlSetData($slQuality, 75) GUICtrlSetData($ipQuality, 75) GUICtrlSetData($slSNS_Strength, 50) GUICtrlSetData($ipSSN_Strength, 50) GUICtrlSetData($ipTarget_Size, 0) GUICtrlSetState($chkbAlpha_Compression, $GUI_CHECKED) GUICtrlSetState($chkbLossless, $GUI_UNCHECKED) _SendMessage($hcbPreset, $CB_SETCURSEL, 0) Return 0 EndSwitch Return "GUI_RUNDEFMSG" EndFunc ;==>WM_COMMAND Func WM_CONTEXTMENU($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Switch $hWnd Case $hGUI Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Reset values to default", $idResetValues) If $bBigger Then _GUICtrlMenu_InsertMenuItem($hMenu, 1, 0) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "Reset image position", $idResetPicPos) EndIf _GUICtrlMenu_TrackPopupMenu($hMenu, $wParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_CONTEXTMENU Func Max($a, $b) If $a > $b Then Return $a Return $b EndFunc Func Min($a, $b) If $a < $b Then Return $a Return $b EndFunc Func GDIPlus_About($iFontsize = 10, $dx = 0, $dy = 0, $iSpeed = 333, $sFont = "MV Boli") If @AutoItX64 = 0 Then Local $binSIDSound = _Chip_Sound() _SIDStartup() _SIDOpen($binSIDSound) EndIf Local Const $iWh = $iW / 2, $iHh = $iH / 2, $sTitle = "GDI+ About Window" Local Const $fPi = ACos(-1), $fRad = $fPi / 180, $fDeg = 180 / $fPi #Region text Local $sText = _ " WebP Advanced Encoder GUI ²" & _ " " & $ver & " beta " & _ " " & $build & " " & _ " " & _ " Coded by UEZ ;-) " & _ " " & _ "Credits to: " & _ " " & _ "* Google for the WebP API " & _ " and static libraries " & _ "* wakillon for TichySID " & _ " and Stat-Mat for the DLL " & _ "* Soren Lund for SID Tune " & _ "* Ward for Mem call code " & _ " " & _ "-------------------------- " & _ " " & _ "Greetings fly out to: " & _ " " & _ " All Autoit users " & _ " around the globe " & _ " " & _ " " & _ " Press ESC to exit. " & _ " " & _ " " & _ "-------------------------- " & _ " " & _ "NO ..--+++--.. WAR " & _ " .-' | `-. " & _ " +' | `+ " & _ " ' | ` " & _ " ' | ` " & _ ": | : " & _ ": +'|`+ : " & _ ". +' | `+ ; " & _ " + +' | `+ + " & _ " `. +' | `+ .' " & _ " `._ | _.' " & _ "Peace `--.._|_..--' :-) " #EndRegion $bExit = False $hGUI_About = GUICreate($sTitle, $iW, $iH, 0, 0, $WS_POPUP, $WS_EX_NOPARENTNOTIFY, $hGUI) _WinAPI_SetParent($hGUI_About, $hGUI) WinSetTrans($hGUI_About, "", 0xD8) GUISetState(@SW_SHOWNA, $hGUI_About) ;create canvas elements Local Const $hDC = _WinAPI_GetDC($hGUI_About) Local Const $hHBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iW, $iH) Local Const $hDC_backbuffer = _WinAPI_CreateCompatibleDC($hDC) Local Const $DC_obj = _WinAPI_SelectObject($hDC_backbuffer, $hHBitmap) Local Const $hCanvas = _GDIPlus_GraphicsCreateFromHDC($hDC_backbuffer) _GDIPlus_GraphicsSetSmoothingMode($hCanvas, $GDIP_SMOOTHINGMODE_HIGHQUALITY) _GDIPlus_GraphicsSetPixelOffsetMode($hCanvas, $GDIP_PIXELOFFSETMODE_HIGHQUALITY) Local Const $hBrush_Clr = _GDIPlus_HatchBrushCreate(18, 0xF0B0B0E0, 0xF0F0F0FF), _ $hBrush_FPS = _GDIPlus_BrushCreateSolid(0xF0808080), _ $hFormat_FPS = _GDIPlus_StringFormatCreate(), _ $hFamily_FPS = _GDIPlus_FontFamilyCreate("Arial"), _ $hFont_FPS = _GDIPlus_FontCreate($hFamily_FPS, 8), _ $tLayout_FPS = _GDIPlus_RectFCreate(0, 0, 100, 24) $iFPS = 0 GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit_About") Local $iLen = StringLen($sText), $iColums = StringInStr($sText, "²"), $i, $u, $s, $r, $iChar_Space, $x, $y, $t = 0, $f, $b = 0, $a = 512, $iCharCol = 0x101030 $sText = StringReplace($sText, "²", " ") Local $aChars = StringSplit($sText, "", 2) Local $hFormat_char = _GDIPlus_StringFormatCreate(), $hFamily_char = _GDIPlus_FontFamilyCreate($sFont), $hFont_char = _GDIPlus_FontCreate($hFamily_char, $iFontsize, 1), _ $tLayout_char = _GDIPlus_RectFCreate(), $hBrush_char = _GDIPlus_BrushCreateSolid(0xFF000000 + $iCharCol) Local Const $iMilliSeconds = 5 AdlibRegister("CalcFPS", 1000) Do DllCall($__g_hGDIPDll, "int", "GdipFillRectangle", "handle", $hCanvas, "handle", $hBrush_Clr, "float", 0, "float", 0, "float", $iW, "float", $iH) ;erase canvas background For $i = 0 To UBound($aChars) - 1 If $aChars[$i] <> " " Then $f = $t - $i / $iSpeed $s = $f > 2 ? 2 : $f $s = $s > 0 ? $s : 0 $r = (2 - $s) * $iColums * $iColums $iChar_Space = $s / 5.1 * $iColums $tLayout_char.x = $dx + $r / 2 * Sin($t + $i) + Mod($i, $iColums) * $iChar_Space $tLayout_char.y = $dy + $r / 3 * Cos($t + $i) + Int($i / $iColums) * $iChar_Space * 1.3333 DllCall($__g_hGDIPDll, "int", "GdipDrawString", "handle", $hCanvas, "wstr", $aChars[$i], "int", -1, "handle", $hFont_char, "struct*", $tLayout_char, "handle", $tLayout_char, "handle", $hBrush_char) EndIf Next $t += 0.025 DllCall($__g_hGDIPDll, "int", "GdipDrawString", "handle", $hCanvas, "wstr", "FPS: " & $iShowFPS, "int", -1, "handle", $hFont_FPS, "struct*", $tLayout_FPS, "handle", $hFormat_FPS, "handle", $hBrush_FPS) DllCall("gdi32.dll", "bool", "BitBlt", "handle", $hDC, "int", 0, "int", 0, "int", $iW, "int", $iH, "handle", $hDC_backbuffer, "int", 0, "int", 0, "dword", $SRCCOPY) $iFPS += 1 If $bExit Then ExitLoop If $r = 0 Then $b = 1 If $b Then $a -= 5 If $a < 256 Then DllCall($__g_hGDIPDll, "int", "GdipSetSolidFillColor", "handle", $hBrush_char, "dword", BitShift(Max(0, $a), -24) + $iCharCol) If $a <= -50 Then $b = 0 $a = 384 DllCall($__g_hGDIPDll, "int", "GdipSetSolidFillColor", "handle", $hBrush_char, "dword", 0xFF000000 + $iCharCol) $t = 0 EndIf EndIf DllCall($_KERNEL32DLL, "dword", "SleepEx", "dword", $iMilliSeconds, "bool", True) Until False AdlibUnRegister("CalcFPS") ;release resources _GDIPlus_FontDispose($hFont_char) _GDIPlus_FontFamilyDispose($hFamily_char) _GDIPlus_StringFormatDispose($hFormat_char) _GDIPlus_BrushDispose($hBrush_char) _GDIPlus_FontDispose($hFont_FPS) _GDIPlus_FontFamilyDispose($hFamily_FPS) _GDIPlus_StringFormatDispose($hFormat_FPS) _GDIPlus_BrushDispose($hBrush_Clr) _GDIPlus_BrushDispose($hBrush_FPS) _GDIPlus_GraphicsDispose($hCanvas) _WinAPI_SelectObject($hDC_backbuffer, $DC_obj) _WinAPI_DeleteDC($hDC_backbuffer) _WinAPI_DeleteObject($hHBitmap) _WinAPI_ReleaseDC($hGUI_About, $hDC) GUIDelete($hGUI_About) If @AutoItX64 = 0 Then _SIDStop() _SIDClose() _SIDShutdown() $binSIDSound = 0 EndIf EndFunc ;==>GDIPlus_About Func _Exit_About() $bExit = True EndFunc ;==>_Exit_About Func CalcFPS() ;display FPS $iShowFPS = $iFPS $iFPS = 0 EndFunc ;==>CalcFPS Func _GDIPlus_GraphicsGetDPIRatio($iDPIDef = 96) Local $hGfx = _GDIPlus_GraphicsCreateFromHWND(0) If @error Then Return SetError(1, @extended, 0) Local $aResult = DllCall($__g_hGDIPDll, "int", "GdipGetDpiX", "handle", $hGfx, "float*", 0) If @error Then Return SetError(2, @extended, 0) Local $iDPI = $aResult[2] _GDIPlus_GraphicsDispose($hGfx) Local $aResults[2] = [$iDPIDef / $iDPI, $iDPI / $iDPIDef] Return $aResults EndFunc ;==>_GDIPlus_GraphicsGetDPIRatio Func _WinAPI_GetDpiForMonitor($dpiType = $MDT_DEFAULT, $iDPIDef = 96) Local $aMonitors = _WinAPI_EnumDisplayMonitors() Local $x, $y Local $aRet = DllCall("Shcore.dll", "long", "GetDpiForMonitor", "long", $aMonitors[1][0], "int", $dpiType, "uint*", $x, "uint*", $y) If @error Or Not IsArray($aRet) Then Return SetError(1, 0, 0) Local $aDPI[2] = [$iDPIDef / $aRet[3], $aRet[3] / $iDPIDef] Return $aDPI EndFunc ;==>_WinAPI_GetDpiForMonitor Func _WinAPI_SetDPIAwareness($hGUI = 0) Switch @OSBuild Case 6000 To 9199 If Not DllCall("user32.dll", "bool", "SetProcessDPIAware") Then Return SetError(1, 0, 0) Return 1 Case 9200 To 13999 _WinAPI_SetProcessDpiAwareness($PROCESS_PER_MONITOR_DPI_AWARE) If @error Then Return SetError(1, 0, 0) Return 1 Case @OSBuild > 13999 #cs Context_Unaware = ((DPI_AWARENESS_CONTEXT)(-1)), Context_SystemAware = ((DPI_AWARENESS_CONTEXT)(-2)), Context_PerMonitorAware = ((DPI_AWARENESS_CONTEXT)(-3)), Context_PerMonitorAwareV2 = ((DPI_AWARENESS_CONTEXT)(-4)), Context_UnawareGdiScaled = ((DPI_AWARENESS_CONTEXT)(-5)) #ce _WinAPI_SetProcessDpiAwarenessContext($Context_PerMonitorAwareV2, $hGUI) If @error Then Return SetError(3, @error, 0) Return 1 EndSwitch Return -1 EndFunc ;==>_WinAPI_SetDPIAwareness Func _WinAPI_SetProcessDpiAwareness($DPIAware) ;https://docs.microsoft.com/en-us/windows/desktop/api/shellscalingapi/nf-shellscalingapi-setprocessdpiawareness DllCall("Shcore.dll", "long", "SetProcessDpiAwareness", "int", $DPIAware) If @error Then Return SetError(1, 0, 0) Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwareness ;https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setprocessdpiawarenesscontext Func _WinAPI_SetProcessDpiAwarenessContext($DPIAwareContext = $Context_PerMonitorAware, $hGUI = 0, $iMode = 1) ;https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-setprocessdpiawarenesscontext $DPIAwareContext = ($DPIAwareContext < -5) ? -5 : ($DPIAwareContext > -1) ? -1 : $DPIAwareContext $iMode = ($iMode < 1) ? 1 : ($iMode > 3) ? 3 : $iMode Switch $iMode Case 1 Local $hDC = _WinAPI_GetDC($hGUI) Local $aResult1 = DllCall("user32.dll", "ptr", "GetDpiFromDpiAwarenessContext", "ptr", $hDC) If @error Or Not IsArray($aResult1) Then Return SetError(11, 0, 0) _WinAPI_ReleaseDC(0, $hDC) Local $aResult = DllCall("user32.dll", "Bool", "SetProcessDpiAwarenessContext", "int", $aResult1[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(12, 0, 0) Case 2 ;~ If Not $hGUI Then $hGUI = WinGetHandle(AutoItWinGetTitle()) Local $aResult2 = DllCall("user32.dll", "int", "GetWindowDpiAwarenessContext", "ptr", $hGUI) If @error Or Not IsArray($aResult2) Then Return SetError(21, 0, 0) Local $aResult = DllCall("user32.dll", "Bool", "SetProcessDpiAwarenessContext", "int", $aResult2[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(22, 0, 0) Case 3 Local $aResult31 = DllCall("user32.dll", "ptr", "GetThreadDpiAwarenessContext") If @error Or Not IsArray($aResult31) Then Return SetError(31, 0, 0) Local $aResult32 = DllCall("user32.dll", "ptr", "GetAwarenessFromDpiAwarenessContext", "ptr", $aResult31[0]) If @error Or Not IsArray($aResult32) Then Return SetError(32, 0, 0) Local $aResult = DllCall("user32.dll", "Bool", "SetThreadDpiAwarenessContext", "int", $aResult32[0] + $DPIAwareContext) If @error Or Not IsArray($aResult) Then Return SetError(33, 0, 0) EndSwitch Return 1 EndFunc ;==>_WinAPI_SetProcessDpiAwarenessContext ;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2020-06-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1+2P+i2A1tftr/v+CYA2zYvuBYA+zYvuwYA+z+4lhG7FgD7P7tBv7/4JgErNi+4FgHrNi+7BgErP7iWEesWASs/u0Hvv/gmAWs2L7gWAis2L7sGAWs/uJYSKxYBaz+7Qi+/+OZwD/kWAMtmb7/2H+hgD+AP+EYQD+AP6FAP6HAP4AhgCEAP6FAIYAhwCGAP+PYCf8LPwi/Cf8Lvwi/Cn8Lvwl/Cn8Kvwl/Cf8Kvws/Cf/iGAn/Cz8Ivwn/C78Ivwp/C78Jfwp/Cr8Jfwn/Cr8LPwn/4JgErNi+4FgFLNi+7BgFLP7iWEgsWAUs/u0IPv/kmAnt2L7Y/5gI7di+2P+YCK3Yvtj/mAet2L7Y/6TYBu3avty/rlg/v+bYDG+YvuSYCe3Yvtj/mAjt2L7Y/5gIrdi+2P+YB63Yvtj/pNgG7dy+2f+/5lgJ/ws/CL8J/wu/CL8Kfwu/CX8Kfwq/CX8J/wq/Cy9J//8YA+4aPt1/mv7vGP7b/7/l2MAZ/6VYAq6bvtr/rtn/rxj/pprAP+SYCe3Yvtj/mAjt2L7Y/6WYC63Yvtj/mAqt2L7Y/6TYCe3avty/rlg/v+bYCe+YvuSYCe3Yvtj/mAjt2L7Y/6WYC63Yvtj/mAqt2L7Y/6TYCe3cvtn/v+XYQCYYCL8J/wu/CL8KfwulwD8+5gq/CX8J/wq/Cz8J/+eYBjAYvvBY/vC+8Nn+8Rj+8X7xvtgSshi+8dgSsj+Sshi+8dgSsj+nxvJavvKYD9m+/+eYBjAYvvBY/vC+8Nn+8Rj+8X7y2H7zPtgSshi+8dgSsj+Sshi+8dgSsj+nz/KYvuXYwCHYQCQYwAAhWEA/w==' Local $bString = _WinAPI_Base64Decode($Chip_Sound) If @error Then Return SetError(1, 0, 0) $bString = Binary($bString) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\Commodore_64.sid", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc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9PT0EKil5eVlbIVYh8bGRpwpJAX04tTUVOIRv9ra2vLy8oGBAefOOXJfRnNDk0DL6ejokA5z941kB8bGxv7722msAxF4B6D0K05KGJl3MJ01mXGS+F6BAzmbZQv3eQXkG4Xdi4RQ7jehbOCAgyP3P94Red6jcQCLAAAAAElFTkSuQmCC' Local $bString = _WinAPI_Base64Decode($WebP_Icon) If @error Then Return SetError(1, 0, 0) $bString = Binary($bString) If $bSaveBinary Then Local Const $hFile = FileOpen($sSavePath & "\WebP_logo_2010_64x64_Simo99.png", 18) If @error Then Return SetError(2, 0, $bString) FileWrite($hFile, $bString) FileClose($hFile) EndIf Return $bString EndFunc ;==>_WebP_Icon Func _WinAPI_Base64Decode($sB64String) Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "") Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]") $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0) If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "") Return DllStructGetData($bBuffer, 1) EndFunc ;==>_WinAPI_Base64Decode #Region TichySID Func _SIDClose() Local $aRet = MemoryDllCall($hTitchysidDll, 'int', 'SIDClose') If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_SIDClose Func _SIDOpen($Sid, $iSubsong = 1) Local $bSid If Not IsBinary($Sid) Then If Not FileExists($Sid) Then Return SetError(2, 0, 0) Local $hFileOpen = FileOpen($Sid, 0) If $hFileOpen = -1 Then Return SetError(-1, 0, 0) $bSid = FileRead($hFileOpen) FileClose($hFileOpen) Else $bSid = $Sid EndIf Local $tSid = DllStructCreate('byte[' & BinaryLen($bSid) & ']') DllStructSetData($tSid, 1, $bSid) Local $sType = BinaryToString(BinaryMid($bSid, 1, 4), 1) ConsoleWrite('-->-- Sid File Type : ' & $sType & @CRLF) Local $iVersion = Execute(BinaryMid($bSid, 5, 2)) ConsoleWrite('-->-- Sid File Version : ' & $iVersion & @CRLF) $iSubsongCount = Int(StringTrimLeft(BinaryMid($bSid, 15, 2), 2)) ConsoleWrite('-->-- SubsongCount : ' & $iSubsongCount & @CRLF) $iSubsong = $iSubsong - 1 If $iSubsong < 0 Then $iSubsong = 0 If $iSubsong > $iSubsongCount Then $iSubsong = 0 ConsoleWrite('-->-- Subsong : ' & $iSubsong & @CRLF) Local $aRet = MemoryDllCall($hTitchysidDll, 'int', 'SIDOpen', 'ptr', DllStructGetPtr($tSid), 'int', DllStructGetSize($tSid), 'int', $SID_MEMORY, 'int', $SID_NON_DEFAULT, 'int', $iSubsong) If @error Then Return SetError(@error, 0, 0) $tSid = 0 $bSid = 0 Return $aRet[0] EndFunc ;==>_SIDOpen Func _SIDShutdown() MemoryDllClose($hTitchysidDll) $hTitchysidDll = 0 EndFunc ;==>_SIDShutdown Func _SIDStartup() $hTitchysidDll = MemoryDllOpen(TitchySIDdll()) If $hTitchysidDll = -1 Then Return SetError(1, 0, 0) Return SetError(0, 0, $hTitchysidDll) EndFunc ;==>_SIDStartup Func _SIDStop() Local $aRet = MemoryDllCall($hTitchysidDll, 'int', 'SIDStop') If @error Then Return SetError(@error, 0, 0) Return $aRet[0] EndFunc ;==>_SIDStop Func TitchySIDdll() ;only x86 :-( Local $sFileBin = 'cbsATVqQAAMAAACCBAAw//8AALgAOC0BAEAEOBkAsAAMDh8Aug4AtAnNIbgAAUzNIVRoaXMAIHByb2dyYW0AIGNhbm5vdCAAYmUgcnVuIGkAbiBET1MgbW+AZGUuDQ0KJASGADvpjpN/iODAQQUDg6jywHwAB/EQl/PAZQAHUmljBmgBFwVzUEUAAEyAAQQA9O0oVQUTAOAADiELAQUMpAASAAzMAgegEAADfjAECQELABoB5wEABQcA/iCAfgQGgxwA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APAP8PAA8ADwAPAA8ADwAPAA8A/w8ADwAPAA8ADwAPAA8ADwD/DwAPAA8ADwAPAA8ADwAPAP8PAA8ADwAPAA8ADwAPAA8A/w8ADwAPAA8ADwAPAA8ABAA=' $sFileBin = Binary(_WinAPI_Base64Decode($sFileBin)) $sFileBin = Binary(_LzntDecompress($sFileBin)) Return SetError(0, 0, $sFileBin) EndFunc ;==>TitchySIDdll Func _LzntDecompress($bBinary) $bBinary = Binary($bBinary) Local $tInput = DllStructCreate('byte[' & BinaryLen($bBinary) & ']') DllStructSetData($tInput, 1, $bBinary) Local $tBuffer = DllStructCreate('byte[' & 16 * DllStructGetSize($tInput) & ']') Local $a_Call = DllCall('ntdll.dll', 'int', 'RtlDecompressBuffer', 'ushort', 2, 'ptr', DllStructGetPtr($tBuffer), 'dword', DllStructGetSize($tBuffer), 'ptr', DllStructGetPtr($tInput), 'dword', DllStructGetSize($tInput), 'dword*', 0) If @error Or $a_Call[0] Then Return SetError(1, 0, '') Local $tOutput = DllStructCreate('byte[' & $a_Call[6] & ']', DllStructGetPtr($tBuffer)) Return SetError(0, 0, DllStructGetData($tOutput, 1)) EndFunc ;==>_LzntDecompress Func API_FreeLibrary($Module) Local $Ret = DllCall($_KERNEL32DLL, 'bool', 'FreeLibrary', 'handle', $Module) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_FreeLibrary Func API_GetProcAddress($Module, $Procname) If IsNumber($Procname) Then Local $Ret = DllCall($_KERNEL32DLL, 'ptr', 'GetProcAddress', 'handle', $Module, 'int', $Procname) Else Local $Ret = DllCall($_KERNEL32DLL, 'ptr', 'GetProcAddress', 'handle', $Module, 'str', $Procname) EndIf If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_GetProcAddress Func API_IsBadReadPtr($Ptr, $Len) Local $Ret = DllCall($_KERNEL32DLL, 'int', 'IsBadReadPtr', 'ptr', $Ptr, 'UINT_PTR', $Len) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_IsBadReadPtr Func API_LoadLibrary($Filename) Local $Ret = DllCall($_KERNEL32DLL, 'handle', 'LoadLibraryW', 'wstr', $Filename) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_LoadLibrary Func API_lstrlenA($Address) Local $Ret = DllCall($_KERNEL32DLL, 'int', 'lstrlenA', 'ptr', $Address) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_lstrlenA Func API_lstrlenW($Address) Local $Ret = DllCall($_KERNEL32DLL, 'int', 'lstrlenW', 'ptr', $Address) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_lstrlenW Func API_VirtualProtect($Address, $Size, $Protection) Local $Ret = DllCall($_KERNEL32DLL, 'bool', 'VirtualProtect', 'ptr', $Address, 'dword_ptr', $Size, 'dword', $Protection, 'dword*', 0) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_VirtualProtect Func API_ZeroMemory($Address, $Size) Local $Ret = DllCall($_KERNEL32DLL, 'none', 'RtlZeroMemory', 'ptr', $Address, 'dword_ptr', $Size) If @error Then Return SetError(@error, @extended, 0) Return $Ret[0] EndFunc ;==>API_ZeroMemory Func MemLib_BuildImportTable($CodeBase, $PEHeader) Local Const $IMAGE_DIRECTORY_ENTRY_IMPORT = 1 Local Const $SizeOfPtr = DllStructGetSize(DllStructCreate('ptr', 1)) Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) Local $SizeOfDataDirectory = DllStructGetSize(DllStructCreate($tagIMAGE_DATA_DIRECTORY)) Local $ImportDirectoryPtr = $PEHeader + DllStructGetSize($IMAGE_NT_HEADER) + $IMAGE_DIRECTORY_ENTRY_IMPORT * $SizeOfDataDirectory Local $ImportDirectory = DllStructCreate($tagIMAGE_DATA_DIRECTORY, $ImportDirectoryPtr) Local $ImportSize = DllStructGetData($ImportDirectory, 'Size') Local $ImportVirtualAddress = DllStructGetData($ImportDirectory, 'VirtualAddress') Local $SizeOfImportDir = DllStructGetSize(DllStructCreate($tagIMAGE_IMPORT_DESCRIPTOR)) Local $ImportList = '' If $ImportSize > 0 Then Local $ImportDescPtr = $CodeBase + $ImportVirtualAddress While 1 If API_IsBadReadPtr($ImportDescPtr, $SizeOfImportDir) Then ExitLoop Local $ImportDesc = DllStructCreate($tagIMAGE_IMPORT_DESCRIPTOR, $ImportDescPtr) Local $NameOffset = DllStructGetData($ImportDesc, 'Name') If $NameOffset = 0 Then ExitLoop Local $Name = Peek('str', $CodeBase + $NameOffset) Local $OriginalFirstThunk = DllStructGetData($ImportDesc, 'OriginalFirstThunk') Local $FirstThunk = DllStructGetData($ImportDesc, 'FirstThunk') Local $Handle = API_LoadLibrary($Name) If $Handle Then $ImportList &= $Handle & ',' Local $FuncRef = $CodeBase + $FirstThunk Local $ThunkRef = $CodeBase + $OriginalFirstThunk If $OriginalFirstThunk = 0 Then $ThunkRef = $FuncRef While 1 Local $Ref = Peek('ptr', $ThunkRef) If $Ref = 0 Then ExitLoop If BitAND(Peek('byte', $ThunkRef + $SizeOfPtr - 1), 0x80) Then Local $Ptr = API_GetProcAddress($Handle, BitAND($Ref, 0xffff)) Else Local $IMAGE_IMPORT_BY_NAME = DllStructCreate($tagIMAGE_IMPORT_BY_NAME, $CodeBase + $Ref) Local $NamePtr = DllStructGetPtr($IMAGE_IMPORT_BY_NAME, 2) Local $FuncName = Peek('str', $NamePtr) Local $Ptr = API_GetProcAddress($Handle, $FuncName) EndIf If $Ptr = 0 Then Return SetError(1, 0, False) Poke('ptr', $FuncRef, $Ptr) $ThunkRef += $SizeOfPtr $FuncRef += $SizeOfPtr WEnd Else Return SetError(1, 0, False) EndIf $ImportDescPtr += $SizeOfImportDir WEnd EndIf Return $ImportList EndFunc ;==>MemLib_BuildImportTable Func MemLib_CopySections($CodeBase, $PEHeader, $DllDataPtr) Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) Local $SizeOfFileHeader = DllStructGetPtr($IMAGE_NT_HEADER, 'Magic') - $PEHeader Local $SizeOfOptionalHeader = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfOptionalHeader') Local $NumberOfSections = DllStructGetData($IMAGE_NT_HEADER, 'NumberOfSections') Local $SectionAlignment = DllStructGetData($IMAGE_NT_HEADER, 'SectionAlignment') Local $SectionPtr = $PEHeader + $SizeOfFileHeader + $SizeOfOptionalHeader For $i = 1 To $NumberOfSections Local $Section = DllStructCreate($tagIMAGE_SECTION_HEADER, $SectionPtr) Local $VirtualAddress = DllStructGetData($Section, 'VirtualAddress') Local $SizeOfRawData = DllStructGetData($Section, 'SizeOfRawData') Local $PointerToRawData = DllStructGetData($Section, 'PointerToRawData') If $SizeOfRawData = 0 Then Local $Dest = _MemVirtualAlloc($CodeBase + $VirtualAddress, $SectionAlignment, $MEM_COMMIT, $PAGE_READWRITE) API_ZeroMemory($Dest, $SectionAlignment) Else Local $Dest = _MemVirtualAlloc($CodeBase + $VirtualAddress, $SizeOfRawData, $MEM_COMMIT, $PAGE_READWRITE) _MemMoveMemory($DllDataPtr + $PointerToRawData, $Dest, $SizeOfRawData) EndIf DllStructSetData($Section, 'VirtualSize', $Dest - $CodeBase) $SectionPtr += DllStructGetSize($Section) Next EndFunc ;==>MemLib_CopySections Func MemLib_FinalizeSections($CodeBase, $PEHeader) Local Const $IMAGE_SCN_MEM_EXECUTE = 0x20000000 Local Const $IMAGE_SCN_MEM_READ = 0x40000000 Local Const $IMAGE_SCN_MEM_WRITE = 0x80000000 Local Const $IMAGE_SCN_MEM_NOT_CACHED = 0x4000000 Local Const $IMAGE_SCN_CNT_INITIALIZED_DATA = 64 Local Const $IMAGE_SCN_CNT_UNINITIALIZED_DATA = 128 Local Const $PAGE_WRITECOPY = 0x0008 Local Const $PAGE_EXECUTE_WRITECOPY = 0x0080 Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) Local $SizeOfFileHeader = DllStructGetPtr($IMAGE_NT_HEADER, 'Magic') - $PEHeader Local $SizeOfOptionalHeader = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfOptionalHeader') Local $NumberOfSections = DllStructGetData($IMAGE_NT_HEADER, 'NumberOfSections') Local $SectionAlignment = DllStructGetData($IMAGE_NT_HEADER, 'SectionAlignment') Local $SectionPtr = $PEHeader + $SizeOfFileHeader + $SizeOfOptionalHeader For $i = 1 To $NumberOfSections Local $Section = DllStructCreate($tagIMAGE_SECTION_HEADER, $SectionPtr) Local $Characteristics = DllStructGetData($Section, 'Characteristics') Local $SizeOfRawData = DllStructGetData($Section, 'SizeOfRawData') Local $Executable = (BitAND($Characteristics, $IMAGE_SCN_MEM_EXECUTE) <> 0) Local $Readable = (BitAND($Characteristics, $IMAGE_SCN_MEM_READ) <> 0) Local $Writeable = (BitAND($Characteristics, $IMAGE_SCN_MEM_WRITE) <> 0) Local $ProtectList[8] = [$PAGE_NOACCESS, $PAGE_EXECUTE, $PAGE_READONLY, $PAGE_EXECUTE_READ, $PAGE_WRITECOPY, $PAGE_EXECUTE_WRITECOPY, $PAGE_READWRITE, $PAGE_EXECUTE_READWRITE] Local $Protect = $ProtectList[$Executable + $Readable * 2 + $Writeable * 4] If BitAND($Characteristics, $IMAGE_SCN_MEM_NOT_CACHED) Then $Protect = BitOR($Protect, $PAGE_NOCACHE) Local $Size = $SizeOfRawData If $Size = 0 Then If BitAND($Characteristics, $IMAGE_SCN_CNT_INITIALIZED_DATA) Then $Size = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfInitializedData') ElseIf BitAND($Characteristics, $IMAGE_SCN_CNT_UNINITIALIZED_DATA) Then $Size = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfUninitializedData') EndIf EndIf If $Size > 0 Then Local $PhysicalAddress = $CodeBase + DllStructGetData($Section, 'VirtualSize') API_VirtualProtect($PhysicalAddress, $Size, $Protect) EndIf $SectionPtr += DllStructGetSize($Section) Next EndFunc ;==>MemLib_FinalizeSections Func MemLib_FreeLibrary($ModulePtr) If Not MemLib_Vaild($ModulePtr) Then Return 0 Local $Module = DllStructCreate($tagModule, $ModulePtr) Local $CodeBase = DllStructGetData($Module, 'CodeBase') Local $DllEntry = DllStructGetData($Module, 'DllEntry') Local $Initialized = DllStructGetData($Module, 'Initialized') Local $ImportListPtr = DllStructGetData($Module, 'ImportList') Local $ExportListPtr = DllStructGetData($Module, 'ExportList') If $Initialized And $DllEntry Then Local $Success = MemoryFuncCall('bool', $DllEntry, 'ptr', $CodeBase, 'dword', 0, 'ptr', 0) DllStructSetData($Module, 'Initialized', 0) EndIf If $ExportListPtr Then _MemGlobalFree($ExportListPtr) If $ImportListPtr Then Local $ImportList = StringSplit(Peek('str', $ImportListPtr), ',') For $i = 1 To $ImportList[0] If $ImportList[$i] Then API_FreeLibrary($ImportList[$i]) Next _MemGlobalFree($ImportListPtr) EndIf If $CodeBase Then _MemVirtualFree($CodeBase, 0, $MEM_RELEASE) DllStructSetData($Module, 'CodeBase', 0) DllStructSetData($Module, 'ExportList', 0) _MemGlobalFree($ModulePtr) Return 1 EndFunc ;==>MemLib_FreeLibrary Func MemLib_GetExportList($CodeBase, $PEHeader) Local Const $IMAGE_DIRECTORY_ENTRY_EXPORT = 0 Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) Local $SizeOfDataDirectory = DllStructGetSize(DllStructCreate($tagIMAGE_DATA_DIRECTORY)) Local $ExportDirectoryPtr = $PEHeader + DllStructGetSize($IMAGE_NT_HEADER) + $IMAGE_DIRECTORY_ENTRY_EXPORT * $SizeOfDataDirectory Local $ExportDirectory = DllStructCreate($tagIMAGE_DATA_DIRECTORY, $ExportDirectoryPtr) Local $ExportSize = DllStructGetData($ExportDirectory, 'Size') Local $ExportVirtualAddress = DllStructGetData($ExportDirectory, 'VirtualAddress') Local $ExportList = '' If $ExportSize > 0 Then Local $IMAGE_EXPORT_DIRECTORY = DllStructCreate($tagIMAGE_EXPORT_DIRECTORY, $CodeBase + $ExportVirtualAddress) Local $NumberOfNames = DllStructGetData($IMAGE_EXPORT_DIRECTORY, 'NumberOfNames') Local $NumberOfFunctions = DllStructGetData($IMAGE_EXPORT_DIRECTORY, 'NumberOfFunctions') Local $AddressOfFunctions = DllStructGetData($IMAGE_EXPORT_DIRECTORY, 'AddressOfFunctions') If $NumberOfNames = 0 Or $NumberOfFunctions = 0 Then Return '' Local $NameRef = $CodeBase + DllStructGetData($IMAGE_EXPORT_DIRECTORY, 'AddressOfNames') Local $Ordinal = $CodeBase + DllStructGetData($IMAGE_EXPORT_DIRECTORY, 'AddressOfNameOrdinals') For $i = 1 To $NumberOfNames Local $Ref = Peek('dword', $NameRef) Local $Idx = Peek('word', $Ordinal) Local $FuncName = Peek('str', $CodeBase + $Ref) If $Idx <= $NumberOfFunctions Then Local $Addr = $CodeBase + Peek('dword', $CodeBase + $AddressOfFunctions + $Idx * 4) $ExportList &= $FuncName & Chr(1) & $Addr & Chr(1) EndIf $NameRef += 4 $Ordinal += 2 Next EndIf Return $ExportList EndFunc ;==>MemLib_GetExportList Func MemLib_GetProcAddress($ModulePtr, $FuncName) Local $ExportPtr = Peek('ptr', $ModulePtr) If Not $ExportPtr Then Return 0 Local $ExportList = Peek('str', $ExportPtr) Local $Match = StringRegExp($ExportList, '(?i)' & $FuncName & '\001([^\001]*)\001', 3) If Not @error Then Return Ptr($Match[0]) Return 0 EndFunc ;==>MemLib_GetProcAddress Func MemLib_LoadLibrary($DllBinary) $DllBinary = Binary($DllBinary) Local $DllData = DllStructCreate('byte[' & BinaryLen($DllBinary) & ']') Local $DllDataPtr = DllStructGetPtr($DllData) DllStructSetData($DllData, 1, $DllBinary) Local $IMAGE_DOS_HEADER = DllStructCreate($tagIMAGE_DOS_HEADER, $DllDataPtr) If DllStructGetData($IMAGE_DOS_HEADER, 'e_magic') <> 0x5A4D Then Return SetError(1, 0, 0) EndIf Local $PEHeader = $DllDataPtr + DllStructGetData($IMAGE_DOS_HEADER, 'e_lfanew') Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) If DllStructGetData($IMAGE_NT_HEADER, 'Signature') <> 0x4550 Then Return SetError(1, 0, 0) EndIf Switch DllStructGetData($IMAGE_NT_HEADER, 'Magic') Case 0x10B If @AutoItX64 Then Return SetError(2, 0, 0) Case 0x20B If Not @AutoItX64 Then Return SetError(2, 0, 0) EndSwitch Local $ImageBase = DllStructGetData($IMAGE_NT_HEADER, 'ImageBase') Local $SizeOfImage = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfImage') Local $SizeOfHeaders = DllStructGetData($IMAGE_NT_HEADER, 'SizeOfHeaders') Local $AddressOfEntryPoint = DllStructGetData($IMAGE_NT_HEADER, 'AddressOfEntryPoint') Local $ModulePtr = _MemGlobalAlloc(DllStructGetSize(DllStructCreate($tagModule)), $GPTR) If $ModulePtr = 0 Then Return SetError(3, 0, 0) Local $Module = DllStructCreate($tagModule, $ModulePtr) Local $CodeBase = _MemVirtualAlloc($ImageBase, $SizeOfImage, $MEM_RESERVE, $PAGE_READWRITE) If $CodeBase = 0 Then $CodeBase = _MemVirtualAlloc(0, $SizeOfImage, $MEM_RESERVE, $PAGE_READWRITE) If $CodeBase = 0 Then Return SetError(3, 0, 0) DllStructSetData($Module, 'CodeBase', $CodeBase) _MemVirtualAlloc($CodeBase, $SizeOfImage, $MEM_COMMIT, $PAGE_READWRITE) Local $Base = _MemVirtualAlloc($CodeBase, $SizeOfHeaders, $MEM_COMMIT, $PAGE_READWRITE) _MemMoveMemory($DllDataPtr, $Base, $SizeOfHeaders) MemLib_CopySections($CodeBase, $PEHeader, $DllDataPtr) Local $LocationDelta = $CodeBase - $ImageBase If $LocationDelta <> 0 Then MemLib_PerformBaseRelocation($CodeBase, $PEHeader, $LocationDelta) Local $ImportList = MemLib_BuildImportTable($CodeBase, $PEHeader) If @error Then MemLib_FreeLibrary($ModulePtr) Return SetError(2, 0, 0) EndIf Local $ExportList = MemLib_GetExportList($CodeBase, $PEHeader) Local $ImportListPtr = _MemGlobalAlloc(StringLen($ImportList) + 2, $GPTR) Local $ExportListPtr = _MemGlobalAlloc(StringLen($ExportList) + 2, $GPTR) DllStructSetData($Module, 'ImportList', $ImportListPtr) DllStructSetData($Module, 'ExportList', $ExportListPtr) If $ImportListPtr = 0 Or $ExportListPtr = 0 Then MemLib_FreeLibrary($ModulePtr) Return SetError(3, 0, 0) EndIf Poke('str', $ImportListPtr, $ImportList) Poke('str', $ExportListPtr, $ExportList) MemLib_FinalizeSections($CodeBase, $PEHeader) Local $DllEntry = $CodeBase + $AddressOfEntryPoint DllStructSetData($Module, 'DllEntry', $DllEntry) DllStructSetData($Module, 'Initialized', 0) If $AddressOfEntryPoint Then Local $Success = MemoryFuncCall('bool', $DllEntry, 'ptr', $CodeBase, 'dword', 1, 'ptr', 0) If Not $Success[0] Then MemLib_FreeLibrary($ModulePtr) Return SetError(4, 0, 0) EndIf DllStructSetData($Module, 'Initialized', 1) EndIf Return $ModulePtr EndFunc ;==>MemLib_LoadLibrary Func MemLib_PerformBaseRelocation($CodeBase, $PEHeader, $LocationDelta) Local Const $IMAGE_DIRECTORY_ENTRY_BASERELOC = 5 Local Const $IMAGE_REL_BASED_HIGHLOW = 3 Local Const $IMAGE_REL_BASED_DIR64 = 10 Local $IMAGE_NT_HEADER = DllStructCreate($tagIMAGE_NT_HEADER, $PEHeader) Local $SizeOfDataDirectory = DllStructGetSize(DllStructCreate($tagIMAGE_DATA_DIRECTORY)) Local $RelocDirectoryPtr = $PEHeader + DllStructGetSize($IMAGE_NT_HEADER) + $IMAGE_DIRECTORY_ENTRY_BASERELOC * $SizeOfDataDirectory Local $RelocDirectory = DllStructCreate($tagIMAGE_DATA_DIRECTORY, $RelocDirectoryPtr) Local $RelocSize = DllStructGetData($RelocDirectory, 'Size') Local $RelocVirtualAddress = DllStructGetData($RelocDirectory, 'VirtualAddress') If $RelocSize > 0 Then Local $Relocation = $CodeBase + $RelocVirtualAddress While 1 Local $IMAGE_BASE_RELOCATION = DllStructCreate($tagIMAGE_BASE_RELOCATION, $Relocation) Local $VirtualAddress = DllStructGetData($IMAGE_BASE_RELOCATION, 'VirtualAddress') Local $SizeOfBlock = DllStructGetData($IMAGE_BASE_RELOCATION, 'SizeOfBlock') If $VirtualAddress = 0 Then ExitLoop Local $Dest = $CodeBase + $VirtualAddress Local $Entries = ($SizeOfBlock - 8) / 2 Local $RelInfo = DllStructCreate('word[' & $Entries & ']', $Relocation + 8) For $i = 1 To $Entries Local $Info = DllStructGetData($RelInfo, 1, $i) Local $Type = BitShift($Info, 12) If $Type = $IMAGE_REL_BASED_HIGHLOW Or $Type = $IMAGE_REL_BASED_DIR64 Then Local $Addr = DllStructCreate('ptr', $Dest + BitAND($Info, 0xFFF)) DllStructSetData($Addr, 1, DllStructGetData($Addr, 1) + $LocationDelta) EndIf Next $Relocation += $SizeOfBlock WEnd EndIf EndFunc ;==>MemLib_PerformBaseRelocation Func MemLib_Vaild($ModulePtr) Local $ModuleSize = DllStructGetSize(DllStructCreate($tagModule)) If API_IsBadReadPtr($ModulePtr, $ModuleSize) Then Return False Local $Module = DllStructCreate($tagModule, $ModulePtr) Local $CodeBase = DllStructGetData($Module, 'CodeBase') If Not $CodeBase Then Return False Return True EndFunc ;==>MemLib_Vaild Func MemoryDllCall($Module, $RetType, $FuncName, $Type1 = '', $Param1 = 0, $Type2 = '', $Param2 = 0, $Type3 = '', $Param3 = 0, $Type4 = '', $Param4 = 0, $Type5 = '', $Param5 = 0, $Type6 = '', $Param6 = 0, $Type7 = '', $Param7 = 0, $Type8 = '', $Param8 = 0, $Type9 = '', $Param9 = 0, $Type10 = '', $Param10 = 0, $Type11 = '', $Param11 = 0, $Type12 = '', $Param12 = 0, $Type13 = '', $Param13 = 0, $Type14 = '', $Param14 = 0, $Type15 = '', $Param15 = 0, $Type16 = '', $Param16 = 0, $Type17 = '', $Param17 = 0, $Type18 = '', $Param18 = 0, $Type19 = '', $Param19 = 0, $Type20 = '', $Param20 = 0) Local $Ret, $OpenFlag = False Local Const $MaxParams = 20 If (@NumParams < 3) Or (@NumParams > $MaxParams * 2 + 3) Or (Mod(@NumParams, 2) = 0) Then Return SetError(4, 0, 0) If Not IsPtr($Module) Then $OpenFlag = True $Module = MemoryDllOpen($Module) If @error Then Return SetError(1, 0, 0) EndIf Local $Addr = MemLib_GetProcAddress($Module, $FuncName) If Not $Addr Then Return SetError(3, 0, 0) Poke('ptr', $_MFHookPtr + 1 + @AutoItX64, $Addr) Switch @NumParams Case 3 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi) Case 5 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1) Case 7 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2) Case 9 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3) Case 11 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4) Case 13 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5) Case Else Local $DllCallStr = 'DllCall ( $_KERNEL32DLL, $RetType, $_MFHookApi', $n = 1 For $i = 5 To @NumParams Step 2 $DllCallStr &= ', $Type' & $n & ', $Param' & $n $n += 1 Next $DllCallStr &= ' )' $Ret = Execute($DllCallStr) EndSwitch Local $Err = @error If $OpenFlag Then MemoryDllClose($Module) Return SetError($Err, 0, $Ret) EndFunc ;==>MemoryDllCall Func MemoryDllClose($Module) MemLib_FreeLibrary($Module) EndFunc ;==>MemoryDllClose Func MemoryDllOpen($DllBinary) If Not IsDllStruct($_MFHookBak) Then MemoryFuncInit() Local $Module = MemLib_LoadLibrary($DllBinary) If @error Then Return SetError(@error, 0, -1) Return $Module EndFunc ;==>MemoryDllOpen Func MemoryFuncCall($RetType, $Address, $Type1 = '', $Param1 = 0, $Type2 = '', $Param2 = 0, $Type3 = '', $Param3 = 0, $Type4 = '', $Param4 = 0, $Type5 = '', $Param5 = 0, $Type6 = '', $Param6 = 0, $Type7 = '', $Param7 = 0, $Type8 = '', $Param8 = 0, $Type9 = '', $Param9 = 0, $Type10 = '', $Param10 = 0, $Type11 = '', $Param11 = 0, $Type12 = '', $Param12 = 0, $Type13 = '', $Param13 = 0, $Type14 = '', $Param14 = 0, $Type15 = '', $Param15 = 0, $Type16 = '', $Param16 = 0, $Type17 = '', $Param17 = 0, $Type18 = '', $Param18 = 0, $Type19 = '', $Param19 = 0, $Type20 = '', $Param20 = 0) If Not IsDllStruct($_MFHookBak) Then MemoryFuncInit() Poke('ptr', $_MFHookPtr + 1 + @AutoItX64, $Address) Local $Ret Switch @NumParams Case 2 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi) Case 4 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1) Case 6 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2) Case 8 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3) Case 10 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4) Case 12 $Ret = DllCall($_KERNEL32DLL, $RetType, $_MFHookApi, $Type1, $Param1, $Type2, $Param2, $Type3, $Param3, $Type4, $Param4, $Type5, $Param5) Case Else Local $DllCallStr = 'DllCall($_KERNEL32DLL, $RetType, $_MFHookApi', $n = 1 For $i = 4 To @NumParams Step 2 $DllCallStr &= ', $Type' & $n & ', $Param' & $n $n += 1 Next $DllCallStr &= ')' $Ret = Execute($DllCallStr) EndSwitch Return SetError(@error, 0, $Ret) EndFunc ;==>MemoryFuncCall Func MemoryFuncInit() Local $KernelHandle = API_LoadLibrary('kernel32.dll') API_FreeLibrary($KernelHandle) Local $HookPtr = API_GetProcAddress($KernelHandle, $_MFHookApi) Local $HookSize = 7 + @AutoItX64 * 5 $_MFHookPtr = $HookPtr $_MFHookBak = DllStructCreate('byte[' & $HookSize & ']') If Not API_VirtualProtect($_MFHookPtr, $HookSize, $PAGE_EXECUTE_READWRITE) Then Return False DllStructSetData($_MFHookBak, 1, Peek('byte[' & $HookSize & ']', $_MFHookPtr)) If @AutoItX64 Then Poke('word', $_MFHookPtr, 0xB848) Poke('word', $_MFHookPtr + 10, 0xE0FF) Else Poke('byte', $_MFHookPtr, 0xB8) Poke('word', $_MFHookPtr + 5, 0xE0FF) EndIf Return True EndFunc ;==>MemoryFuncInit Func Peek($Type, $Ptr) If $Type = 'str' Then $Type = 'char[' & API_lstrlenA($Ptr) & ']' ElseIf $Type = 'wstr' Then $Type = 'wchar[' & API_lstrlenW($Ptr) & ']' EndIf Return DllStructGetData(DllStructCreate($Type, $Ptr), 1) EndFunc ;==>Peek Func Poke($Type, $Ptr, $Value) If $Type = 'str' Then $Type = 'char[' & (StringLen($Value) + 1) & ']' ElseIf $Type = 'wstr' Then $Type = 'wchar[' & (StringLen($Value) + 1) & ']' EndIf DllStructSetData(DllStructCreate($Type, $Ptr), 1, $Value) EndFunc ;==>Poke #EndRegion Download UDF, DLLs and examples on my 1Drv: WebP (to download all marked files, you must login first, otherwise 1by1 only)
    2 points
  9. @pixelsearch let me think tomorrow about it. I changed a lot of internal functions from str to wstr to support unicode filenames and all examples must be touched otherwise crash. Currently I'm writing on an example in Freebasic (WebP Encoder GUI) how to use the DLL. Freebasic WebP DLL source code (my written DLL stuff, Google WebP dll will be linked as static library to my DLL) and other stuff can be found on my OneDrive, if you want to have a look under the hood.
    2 points
  10. I was about to answer what follows, but @ioa747 was faster Help file, function GUIGetMsg : If the GUIOnEventMode option is set to 1 then the return from GUIGetMsg is always 0 and the @error is set to 1. You can't use at same time : Opt('GUIOnEventMode', 1) ... GUIGetMsg() ; will not work when GUIOnEventMode option is set to 1
    2 points
  11. Since you have Opt('GUIOnEventMode', 1) GUIGetMsg() does not read it at all (In my example I do not want to use #include "GIFAnimation.au3" and I disabled it for that - because I haven't read/analyzed it yet) The basic changes you need to make are declare the event in the $hGUI Global $hGUI = GUICreate('', $aGIFDimension[0], $aGIFDimension[1], -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_DragMe") ; *** <--- 1 disable the event from $cButton ;~ GUICtrlSetOnEvent(-1, "_DragMe") ; *** <--- 2 disabling the entire ;~ Switch GUIGetMsg() ; *** <--- 3 from the main loop and in _DragMe() clean the part ;~ Switch GUIGetMsg() ; *** <--- 4 and leave only the $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then ... EndIf ; https://www.autoitscript.com/forum/topic/213062-move-gui-with-gif-animation-by-button/#findComment-1545090 #AutoIt3Wrapper_Au3Check_Parameters=-w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #NoTrayIcon #include <Constants.au3> #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> ;~ #include "GIFAnimation.au3" Opt('GUIOnEventMode', 1) Global Const $SC_DRAGMOVE = 0xF012 ; Flag to show if GUI was moved Global $fMoved = False Global $sFile = @ScriptDir & "\gif.gif" HotKeySet('{ESC}', '_Exit') ; Get dimension of the GIF ;~ Global $aGIFDimension = _GIF_GetDimension($sFile) Global $hGUI = GUICreate('', 600, 300, -1, -1, $WS_POPUP) ;, BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST)) GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_DragMe") ; *** <--- 1 ;~ _WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF) Global $cButton = GUICtrlCreateButton('Drag me', 225, 100, 100, 100) ;~ GUICtrlSetOnEvent(-1, "_DragMe") ; *** <--- 2 Global $bButtonQuit = GUICtrlCreateButton("EXIT", 225, 200, 100, 20) GUICtrlSetOnEvent(-1, "_Exit") ; GIF job ;~ Global $hGIF = _GUICtrlCreateGIF($sFile, "", 120, -75) ; Additional processing of some windows messages (for example) ;~ GUIRegisterMsg(133, "_Refresh") ; WM_NCPAINT ;~ GUIRegisterMsg(15, "_ValidateGIFs") ; WM_PAINT Global $iPlay = 1 ; Make GUI transparent ;~ GUISetBkColor(345) ; some random color ;~ _WinAPI_SetLayeredWindowAttributes($hGui, 345, 255) ; making the GUI transparent ;~ _WinAPI_SetParent($hGui, 0) GUISetState(@SW_SHOW, $hGUI) ; Loop till end While 1 Sleep(500) ;~ Switch GUIGetMsg() ; *** <--- 3 ;~ Case $GUI_EVENT_PRIMARYDOWN ;~ ; Check mouse is over button ;~ $cInfo = GUIGetCursorInfo($hGUI) ;~ If $cInfo[4] = $cButton Then ;~ ; Clear the flag ;~ $fMoved = False ;~ ; Get initial positions of mouse and GUI ;~ $aInit_Pos = MouseGetPos() ;~ $aWin_Pos = WinGetPos($hGUI) ;~ ; Wait until mouse button released ;~ Do ;~ ; Check if mouse still pressed ;~ $cInfo = GUIGetCursorInfo($hGUI) ;~ ; Get current mouse position ;~ $aCurr_Pos = MouseGetPos() ;~ ; How far has mouse moved ;~ $iDiff_X = $aInit_Pos[0] - $aCurr_Pos[0] ;~ $iDiff_Y = $aInit_Pos[1] - $aCurr_Pos[1] ;~ ; Move GUI ;~ WinMove($hGUI, "", $aWin_Pos[0] - $iDiff_X, $aWin_Pos[1] - $iDiff_Y) ;~ Until Not $cInfo[2] ;~ ; See if mouse moved while it was pressed - allow for 5 pixel margin ;~ If (Abs($aCurr_Pos[0] - $aInit_Pos[0]) > 5) Or (Abs($aCurr_Pos[1] - $aInit_Pos[1]) > 5) Then ;~ ; If moved then set flag ;~ $fMoved = True ;~ EndIf ;~ EndIf ;~ EndSwitch WEnd Func _Exit() Exit EndFunc ;==>_Exit Func _DragMe() ;~ _GIF_PauseAnimation($sFile) ;~ Switch GUIGetMsg() ; *** <--- 4 ;~ Case $GUI_EVENT_PRIMARYDOWN ; Check mouse is over button $cInfo = GUIGetCursorInfo($hGUI) If $cInfo[4] = $cButton Then ; Clear the flag $fMoved = False ConsoleWrite("$fMoved=" & $fMoved & @CRLF) ; Get initial positions of mouse and GUI $aInit_Pos = MouseGetPos() $aWin_Pos = WinGetPos($hGUI) ; Wait until mouse button released Do ; Check if mouse still pressed $cInfo = GUIGetCursorInfo($hGUI) ; Get current mouse position $aCurr_Pos = MouseGetPos() ; How far has mouse moved $iDiff_X = $aInit_Pos[0] - $aCurr_Pos[0] $iDiff_Y = $aInit_Pos[1] - $aCurr_Pos[1] ; Move GUI WinMove($hGUI, "", $aWin_Pos[0] - $iDiff_X, $aWin_Pos[1] - $iDiff_Y) Until Not $cInfo[2] ; See if mouse moved while it was pressed - allow for 5 pixel margin If (Abs($aCurr_Pos[0] - $aInit_Pos[0]) > 5) Or (Abs($aCurr_Pos[1] - $aInit_Pos[1]) > 5) Then ; If moved then set flag $fMoved = True EndIf EndIf ;~ EndSwitch EndFunc ;==>_DragMe Func _Refresh($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ;~ _GIF_RefreshGIF($hGIF) EndFunc ;==>_Refresh Func _ValidateGIFs($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ;~ _GIF_ValidateGIF($hGIF) EndFunc ;==>_ValidateGIFs
    2 points
  12. Good news I found a way to display the vertical line constantly while dragging the horizontal scrollbar, with very few flickering. To do this : 1) Add the extended style $LVS_EX_DOUBLEBUFFER to your line _GUICtrlListView_SetExtendedListViewStyle(...) 2) In the code of my preceding post, please change one line as indicated below : ; If BitAND($wParam, 0xFFFF) = 0x4 Then ; LoWord . $SB_THUMBPOSITION = 0x4 . Msdn : "the user has dragged the scroll box (thumb) and released the mouse button" If BitAND($wParam, 0xFFFF) = 0x5 Then ; LoWord . $SB_THUMBTRACK = 0x5 . Msdn : "the user is dragging the scroll box"
    2 points
  13. Don't belittle yourself so much 😅 , your knowledge of AutoIt isn't bad at all. But I get your point @WildByDesign , yes. For beginners with JSON a proper example flow would be helpful. 🤝
    2 points
  14. Once it is parsed the array is the same as any other Array in AutoIt , when you're done with modifying the array you can simply pass it as the value to your favourite JSON function without any additional steps
    2 points
  15. ioa747

    _SectionsArrays

    _SectionsArrays A library for reading, writing, and managing 1D or 2D arrays, stored in a single text file using a section-based format. It provides functions to easily handle data, update existing sections, or add new ones. ; ; https://www.autoitscript.com/forum/topic/213059-_sectionsarrays/ ;--------------------------------------------------------------------------------------- ; Title...........: _SectionsArrays ; Description.....: A library for reading, writing, and managing 1D or 2D arrays, ; stored in a single text file using a section-based format. ; It provides functions to easily handle data, update existing sections, or add new ones. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.3 ; 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 <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> Example() Func Example() Local $sArraysFilepath = @ScriptDir & "\arrays.txt" If Not FileExists($sArraysFilepath) Then _MakeArrays($sArraysFilepath) If @error Then ConsoleWrite("_MakeArrays @error=" & @error & @CRLF) Local $aSections = _ArraysFromFile($sArraysFilepath) If @error Then ConsoleWrite("_ArraysFromFile @error=" & @error & @CRLF) ShellExecute($sArraysFilepath) Sleep(500) _ArraysDisplay($aSections, "Array Sections") EndFunc ;==>Example Func _MakeArrays($sFilePath) ; Make examples arrays ; Prepare Sections array Local $aSections[1][2] $aSections[0][0] = 0 Local $Info ; "Monthly zoo Report" array Local $Array[][] = [ _ ["Month", "Bears", "Dolphins", "Whales"], _ ["jan", 8, 150, 80], _ ["feb", 54, 77, 54], _ ["mar", 93, 32, 10], _ ["apr", 116, 11, 76], _ ["may", 137, 6, 93], _ ["jun", 184, 1, 72]] ; Add array to Sections array $Info = _AddArrayToArrays($aSections, "Monthly zoo Report", $Array) ConsoleWrite("add $Info=" & $Info & @CRLF) ; "Base Items" array Local $aArray_Base[2][2] = [["Item 0 - 0", "Item 0 - 1"], ["Item 1 - 0", "Item 1 - 1"]] ; Add array to Sections array $Info = _AddArrayToArrays($aSections, "Base Items", $aArray_Base) ConsoleWrite("add $aArray_Base=" & $Info & @CRLF) ; "item Index" array Local $aIndex[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] ; Add array to Sections array $Info = _AddArrayToArrays($aSections, "item Index", $aIndex) ConsoleWrite("add $aIndex=" & $Info & @CRLF) ; "item Index2" array Local $aIndex2[1][10] = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]] $Info = _AddArrayToArrays($aSections, "item Index2", $aIndex2) ConsoleWrite("add $aIndex2=" & $Info & @CRLF) ; Save arrays to file _ArraysToFile($sFilePath, $aSections) EndFunc ;==>_MakeArrays ;-------------------------------------------------------------------------------------------------------------------------------- ; Help functions (A library for reading, writing, and managing 1D or 2D arrays, stored in a single text file using a section-based format.) ;-------------------------------------------------------------------------------------------------------------------------------- Func _ArraysDisplay(ByRef $aItems, $sTitle = "") ; Creates a GUI window to display and browse the contents of multiple arrays. Local $hGUI = GUICreate($sTitle, 300, 200, -1, -1, $WS_OVERLAPPEDWINDOW) Local $idListview = GUICtrlCreateListView("Sections | Arrays", 0, 0, 300, 200, $LVS_SINGLESEL) GUICtrlSetFont(-1, 10) _GUICtrlListView_SetExtendedListViewStyle($idListview, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) _GUICtrlListView_SetColumnWidth($idListview, 0, 170) _GUICtrlListView_SetColumnWidth($idListview, 1, 120) GUISetState(@SW_SHOW) Local $aIdItems[UBound($aItems, 1)] If @error Then Return SetError(@error, 0, 0) $aIdItems[0] = $aItems[0][0] For $i = 1 To $aIdItems[0] Local $sLabel = "error" Local $aArray = $aItems[$i][1] If IsArray($aArray) Then Local $iDimension = UBound($aArray, $UBOUND_DIMENSIONS) ; The dimension of the array e.g. 1/2/3 dimensional. Local $sDim = "" For $d = 1 To $iDimension $sDim &= "[" & UBound($aArray, $d) & "]" Next $sLabel = "Array" & $sDim EndIf $aIdItems[$i] = GUICtrlCreateListViewItem($aItems[$i][0] & " | {" & $sLabel & "}", $idListview) Next Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_RESIZED Local $iWH = WinGetClientSize($hGUI) GUICtrlSetPos($idListview, 0, 0, $iWH[0], $iWH[1]) Case $aIdItems[1] To $aIdItems[$aIdItems[0]] Local $id = $iMsg - $aIdItems[1] + 1 $aArray = $aItems[$id][1] _ArrayDisplay($aArray, $aItems[$id][0]) EndSwitch WEnd GUIDelete() EndFunc ;==>_ArraysDisplay ;-------------------------------------------------------------------------------------------------------------------------------- Func _AddArrayToArrays(ByRef $aArrays, $sName, $aNewArray) ; Adds a new array to the main array structure, or updates an existing one. Local $iCurrentSections = $aArrays[0][0] ; Check if the section name already exists For $i = 1 To $iCurrentSections If $aArrays[$i][0] = $sName Then ; Section exists, update the array $aArrays[$i][1] = $aNewArray Return True EndIf Next ; Section does not exist, add a new one ReDim $aArrays[$iCurrentSections + 2][2] ; Add the new section name and the array $aArrays[$iCurrentSections + 1][0] = $sName $aArrays[$iCurrentSections + 1][1] = $aNewArray ; Update the total number of sections count $aArrays[0][0] = $iCurrentSections + 1 Return True EndFunc ;==>_AddArrayToArrays ;-------------------------------------------------------------------------------------------------------------------------------- Func _ArraysToFile($sFilePath, $aArrays, $sDelim_Col = "|") ; Saves a multi-array structure back to a text file. Local $sOutput = "" Local $iNumSections = $aArrays[0][0] ; Loop through each section For $i = 1 To $iNumSections Local $sSectionName = $aArrays[$i][0] Local $aCurrentArray = $aArrays[$i][1] ; Get the array dimension Local $iDimension = UBound($aCurrentArray, $UBOUND_DIMENSIONS) ; Append the section name with the dimension to the output string $sOutput &= "[" & $sSectionName & "]" & $iDimension & "D" & @CRLF ; Convert the array to a string Local $sArrayString = _ArrayToString($aCurrentArray, $sDelim_Col) ; Append the array string to the output, followed by a newline $sOutput &= $sArrayString & @CRLF & @CRLF Next Local $hFile = FileOpen($sFilePath, $FO_OVERWRITE + $FO_UTF8_NOBOM) If $hFile = -1 Then Return SetError(1, 0, False) EndIf FileWrite($hFile, $sOutput) FileClose($hFile) Return True EndFunc ;==>_ArraysToFile ;-------------------------------------------------------------------------------------------------------------------------------- Func _RemoveArraySection(ByRef $aArrays, $sName) ; Removes a section and its corresponding array from the main array structure. Local $iCurrentSections = $aArrays[0][0] ; Check if the section name exists For $i = 1 To $iCurrentSections If $aArrays[$i][0] = $sName Then _ArrayDelete($aArrays, $i) $aArrays[0][0] = $iCurrentSections - 1 ReDim $aArrays[$iCurrentSections][2] Return True EndIf Next Return False ; Section not found EndFunc ;==>_RemoveArraySection ;-------------------------------------------------------------------------------------------------------------------------------- Func _ArraysFromFile($sFilePath, $sDelim_Col = "|") ; Reads a text file containing multiple sections and converts them into a 2D array structure. Local $sFileTxt = FileRead($sFilePath) If @error Then Return SetError(1, 0, "") ; Put a @CRLF in start, and convert all @LF, @CR to @CRLF $sFileTxt = @CRLF & StringRegExpReplace($sFileTxt, "(\r\n|\n)", @CRLF) ; split String in (@CRLF & "[") Local $aPart = StringSplit($sFileTxt, @CRLF & "[", 1) If $aPart[0] < 2 Then Return SetError(2, 0, "") Local $aSections[$aPart[0]][2] $aSections[0][0] = $aPart[0] - 1 For $i = 2 To $aPart[0] ; normal first line is the (name & ]) Local $iPos = StringInStr($aPart[$i], "]", 0, -1) If Not $iPos > 0 Or @error Then Return SetError(3, 0, "") ; find the name and the Dimension Local $sName = StringLeft($aPart[$i], $iPos - 1) Local $iDimension = 0 + Number(StringMid($aPart[$i], $iPos + 1, 1)) If Not ($iDimension = 1 Or $iDimension = 2) Then Return SetError(4, 0, "") ; remove leading CRLF or LF from front & back Local $sString = StringRegExpReplace(StringTrimLeft($aPart[$i], $iPos + 2), '(^[\r\n]+|[\r\n]+$)', '') Local $aArrayFromText ; $iDimension - 1 to $bForce2D => true $aArrayFromText = _ArrayFromString($sString, $sDelim_Col, Default, $iDimension - 1) $aSections[$i - 1][0] = $sName $aSections[$i - 1][1] = $aArrayFromText Next Return $aSections EndFunc ;==>_ArraysFromFile ;-------------------------------------------------------------------------------------------------------------------------------- Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
    2 points
  16. Here one way : ; From Nine #include <GDIPlus.au3> #include <GUIConstants.au3> Opt("MustDeclareVars", True) Example() Func Example() _GDIPlus_Startup() Local $hGUI = GUICreate("Example", 400, 400) GUISetState() Local $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) _GDIPlus_GraphicsClear($hGraphic, 0xFFFFFFFF) Local $hBrush = _GDIPlus_LineBrushCreate(50, 200, 320, 200, 0xFF000000, 0xFFFFFFFF) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Arial") Local $hFont = _GDIPlus_FontCreate($hFamily, 28, 2) Local $tLayout = _GDIPlus_RectFCreate(80, 100, 320, 40) Local $aInfo = _GDIPlus_GraphicsMeasureString($hGraphic, "AutoIt Rulez !", $hFont, $tLayout, $hFormat) _GDIPlus_GraphicsDrawStringEx($hGraphic, "AutoIt Rulez !", $hFont, $aInfo[0], $hFormat, $hBrush) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_FontDispose($hFont) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() EndFunc ;==>Example
    2 points
  17. argumentum

    _SectionsArrays

    ;Local $aIndex[10] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Local $aIndex[1][10] = [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]] It'd be nice to do something to differentiate between 1D and 2D. Tho this is the only scene where it would not conform to recreate the original array 🤔 Thanks for sharing Edit: ; split String in (@CRLF & @CRLF & "{") ; for 1D ? ; split String in (@CRLF & @CRLF & "[") ; for 2D ?, and yes I added a 2nd @CRLF Edit2: or, add what it is to it, like: [my array 1D] or [my array 2D] just as an internal indicator ?
    2 points
  18. Here a example how you can do it with jq directly instead of using the JSON.au3 UDF. Don't get me wrong, I like the JSON library (UDF) from @AspirinJunkie - he already knows that. I simply try to give you another perspective how you can handle a JSON file with a widespread (AutoIt independent) library. In case you want to stick with AutoIt, no problem, use the JQ adaption of @TheXman who creates this lovely json-processor. Best regards Sven
    2 points
  19. You'll have to parse the array first and then manually insert the correct index into your commands. If you want to do it in a "cleaner" way, you can just modify the Array in AutoIt and insert the whole thing back with your changes.
    2 points
  20. smbape

    OpenCV v4 UDF

    Update OpenCV to 4.12.0
    2 points
  21. if that was the case then my "face delimited(TM)" approach using chr(1) is just as good It would have to be a keyboard character ( yes, I know about Win + "." ) so that a user could add a comment. The C style is widely known and should work. But is a pain to remove the last comment using regex. Local $sString = "Some code here /* first comment */ more code /* second comment */ /* /* last comment */" The AI is stuck and I don't know regex. I can do it with StringInStr() but regex is the challenge
    1 point
  22. Brief: native WinMove() has a "speed" parameter for a more fluent movement. unfortunately, that applies to the change in position, but not the change in size. the position changes in the specified "speed", but size changes abruptly. _WinPose() is similar to WinMove(), except that move and resize are simultaneous, both conform to the speed parameter. UDF: (save as "WinPose.au3") #include-once #include <WinAPISysWin.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinPose ; Description ...: same as native WinMove(), except that move and resize are simultaneous, both conform to the speed parameter. ; Syntax ........: _WinPose($hWnd, $sText, $x, $y, $w, $h[, $speed = 0]) ; Parameters ....: $hWnd - the title/hWnd/class of the window to pose. ; $sText - the text of the window to pose. ; $x - X coordinate to move to. ; $y - Y coordinate to move to. ; $w - [optional] new width of the window. ; $h - [optional] new height of the window. ; $speed - [optional] the speed to pose the window (smaller value = faster speed, 0 = instantaneous). ; Return values .: Success - a handle to the window. ; Failure - 0 if the window is not found (also sets @error to non-zero). ; Author ........: orbs ; Modified ......: ; Remarks .......: parameters and return values are practically identical to those of the native WinMove() function. ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _WinPose($hWnd, $sText, $x, $y, $w = Default, $h = Default, $speed = 0) ; find the window to move If Not IsHWnd($hWnd) Then $hWnd = WinGetHandle($hWnd, $sText) If @error Then Return SetError(1, 0, False) EndIf Local $aPos = WinGetPos($hWnd) If @error Then Return SetError(2, 0, False) ; initialize variables Local Enum $pos_x, $pos_y, $pos_w, $pos_h Local Enum $aiCurrent, $aiTarget, $aiDelta, $aiRatio Local $aPosTarget[4][4] = [[$aPos[$pos_x], $x, 0, 0], [$aPos[$pos_y], $y, 0, 0], [$aPos[$pos_w], $w, 0, 0], [$aPos[$pos_h], $h, 0, 0]] ; accomodate for Default keyword For $iElement = 0 To 3 If $aPosTarget[$iElement][$aiTarget] = Default Then $aPosTarget[$iElement][$aiTarget] = $aPos[$iElement] Next ; calculate delta For $iElement = 0 To 3 $aPosTarget[$iElement][$aiDelta] = $aPosTarget[$iElement][$aiTarget] - $aPosTarget[$iElement][$aiCurrent] Next ; find the maximum delta Local $iMaxElement = 0, $iMaxDelta = 0 For $iElement = 0 To 3 If Abs($aPosTarget[$iElement][$aiDelta]) > $iMaxDelta Then $iMaxElement = $iElement $iMaxDelta = $aPosTarget[$iElement][$aiDelta] EndIf Next ; accomodate for negative delta If ($aPosTarget[$iMaxElement][$aiTarget] - $aPos[$iMaxElement]) < 0 Then $iMaxDelta = -$iMaxDelta ; calculate ratio for all elements For $iElement = 0 To 3 $aPosTarget[$iElement][$aiRatio] = $aPosTarget[$iElement][$aiDelta] / $iMaxDelta Next ; move & resize the window gradually For $iStep = 0 To $iMaxDelta For $iElement = 0 To 3 $aPosTarget[$iElement][$aiCurrent] += $aPosTarget[$iElement][$aiRatio] Next For $i = 1 To $speed _WinAPI_MoveWindow($hWnd, _ $aPosTarget[$pos_x][$aiCurrent], _ $aPosTarget[$pos_y][$aiCurrent], _ $aPosTarget[$pos_w][$aiCurrent], _ $aPosTarget[$pos_h][$aiCurrent], False) Next Next ; validate final outcome is as expected Return WinMove($hWnd, '', $x, $y, $w, $h) EndFunc ;==>_WinPose Example: #AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <AutoItConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include 'WinPose.au3' Global Const $iMinW = 250, $iMinH = 100 Global $x, $y, $w, $h, $speed Global $hGUI = GUICreate('_WinPose() Example', $iMinW, $iMinH) Global $gButton = GUICtrlCreateButton('Click Me!', 25, 25, 200, 50) GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) GUISetState(@SW_SHOW) Global $msg While True $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop Case $gButton $w = Random($iMinW, @DesktopWidth / 3, 1) $h = Random($iMinH, @DesktopHeight / 3, 1) $x = Random(0, @DesktopWidth - $w, 1) $y = Random(0, @DesktopHeight - $h, 1) $speed = Random(10, 100, 1) _WinPose($hGUI, '', $x, $y, $w, $h, $speed) EndSwitch WEnd click the button to pose the window in a new random position and size, in a random speed. enjoy 🙂
    1 point
  23. Festerini

    AutoIT and 1Password

    That kind of project is not for the faint hearted. If you are new to Autoit, I'd give it a pass. I have such an application but it is not for public use. Allows automatic connection to hardware VPNs, Servers, PCs, Devices etc. Thousands of lines of code, built from small beginnings, with encryption, security, logging and monitoring. I was inspired to learn Autoit by a colleague 13+ years ago and have written hundreds of apps and services for MSP automation over that time. However I still consider myself a novice, as I don't know everything, and have to research. And I started with small programs. Start with small apps. Read the help files, try the examples. Test, test, test. Read, read, read. Good luck.
    1 point
  24. Nine

    AutoIT and 1Password

    The guy didn't find the time to read the replies of his thread. Hope is not a method, but it sure is a base of resilience...
    1 point
  25. Numeric1

    AutoIT and 1Password

    The question might be: is it possible to integrate AutoIt into a security application? Everything is feasible, provided you clearly understand what you're doing and in what context you're doing it. Perhaps your issue is simply that you need AutoIt to automate field filling while ensuring maximum security.
    1 point
  26. I ended up using this same technique of using _GUICtrlMenu_TrackPopupMenu to control the exact placement of a context/popup menu for a statusbar item recently as well with excellent results. Link: https://github.com/WildByDesign/ImmersiveUX/blob/main/ImmersiveUX.au3#L865 Measurement was easier for that though because it was the bottom of the GUI and so titlebar did not need to be calculated in this case.
    1 point
  27. Musashi

    Auto(it)Runs

    It also looks nice to me. Thanks for the effort
    1 point
  28. It's like you put them in a blender and mixed them well. Let's start from this. Func _ShowStep($msg, $sLineNo = @ScriptLineNumber) GUICtrlSetData($LineLabel, "Line: " & $sLineNo & " -" & $msg) EndFunc ;==>_ShowStep What does the help say about this? GUICtrlSetData ( controlID, data [, default] ) --- Modifies the data for a control. but you have no control so we will send it to the console Func _ShowStep($msg, $sLineNo = @ScriptLineNumber) ; GUICtrlSetData($LineLabel, "Line: " & $sLineNo & " -" & $msg) ConsoleWrite("Line: " & $sLineNo & " -" & $msg & @CRLF) EndFunc ;==>_ShowStep so you don't even need the ;~ Global $LineLabel one #RequireAdmin is enough, delete the second one these are not needed both, DirCreate('C:\Dnload\Macrium') are enough, because if it does it, automatically, 'C:\Dnload' also exists ;~ If Not FileExists('C:\Dnload') Then ;~ DirCreate('C:\Dnload') ;~ EndIf If Not FileExists('C:\Dnload\Macrium') Then DirCreate('C:\Dnload\Macrium') EndIf
    1 point
  29. Thank you so much, Pixelsearch. Your solution is fantastic. It worked wonders for me, and my problem was solved. I was desperate after trying so many things and nothing. I really appreciate your help, Pixelsearch.
    1 point
  30. 1 point
  31. 1 point
  32. @DonChunior Using your example, the correct syntax would be: $iCount = Json_Get($Data, '."@odata.count"') ;Using dot-notation or $iCount = Json_Get($Data, '["@odata.count"]') ;Using bracket-notation If key names contain special characters, such as periods, the key names should be wrapped in double quotes.
    1 point
  33. The function header is thanks to your "press F10" toy @ioa747
    1 point
  34. @angel83 you did well posting a picture of the issue. I could reproduce your issue : there is a bad redrawing of the listview, when it got $LVS_EX_GRIDLINES in its extended styles. Now the vertical gridline can disappear momentarily when you scroll horizontally. I just found a very old thread (from 2007) where the issue was described. Now I just scripted a workaround which seems to help. It involves subclassing the listview scrollbars (which are child windows of the listview) but the result seems encouraging. My workaround is : when you release the mouse button from the scrollbar, then the listview is immediately redrawn and the vertical gridline reappears. If you absolutely want the vertical line to appear constantly while using the horizontal scrollbar, then it is possible but the listview will flicker because of too many redraws while scrolling. To keep it simple, I suggest to redraw the listview only once, when you release the mouse button from the scrollbar. The lines for subclassing the listview scrollbars are : #include <WinAPIShellEx.au3> ... Local $pListViewCallback = DllCallbackGetPtr(DllCallbackRegister("ListViewCallback", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr")) _WinAPI_SetWindowSubclass(GUICtrlGetHandle($hListView), $pListViewCallback, 9999, 0) GUISetState(@SW_SHOW) While True Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $Button206 ExitLoop Case $OkButton _FillList() EndSwitch WEnd _WinAPI_RemoveWindowSubclass(GUICtrlGetHandle($hListView), $pListViewCallback, 9999) ;============================================== Func ListViewCallback($hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData) #forceref $iSubclassId, $pData Switch $iMsg Case $WM_HSCROLL ; , $WM_VSCROLL If BitAND($wParam, 0xFFFF) = 0x4 Then ; LoWord . $SB_THUMBPOSITION = 0x4 . Msdn : "the user has dragged the scroll box (thumb) and released the mouse button" _WinAPI_RedrawWindow($hWnd) EndIf EndSwitch Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>ListViewCallback Good luck
    1 point
  35. Trong

    ImageSearchUDF beta

    Version 1.0.0

    28 downloads

    ImageSearchDLL & UDF - The Complete Guide Author: Dao Van Trong - TRONG.PRO Last Updated: 2025-08-04 1. Introduction ImageSearchDLL is a high-performance image recognition solution for Windows, designed to be both powerful for modern systems and compatible with legacy environments. The project consists of three distinct C++ DLL versions and a smart AutoIt User-Defined Function (UDF) that automatically selects the best DLL for the job. This architecture ensures that your scripts get the best possible performance on modern systems (like Windows 10/11) while maintaining full functionality on older systems like Windows 7 and even Windows XP. New is the Special Feature is the function of searching for pictures in pictures! 2. How it Works: The Smart UDF Loader The core of this project is the AutoIt UDF (ImageSearch_UDF.au3). You don’t need to worry about which DLL to use; the _ImageSearch_Startup() function handles it all automatically. Here is the loading logic: On Modern OS (Windows 8, 10, 11+): It first looks for the Modern DLL (ImageSearch_x64.dll or ImageSearch_x86.dll). If not found, it falls back to the Windows 7 DLL. If neither is found, it deploys the Embedded XP DLL. On Windows 7: It prioritizes the Windows 7 DLL (ImageSearch_Win7_x64.dll or ImageSearch_Win7_x86.dll). If not found, it deploys the Embedded XP DLL. On Windows XP: It exclusively uses the Embedded XP DLL, which is extracted from a HEX string inside the UDF. This ensures maximum performance where possible and maximum compatibility where needed. 3. The DLL Versions Explained There are three distinct DLLs, each compiled for a specific purpose. Feature Modern (Win10+) Windows 7 Legacy (XP) Target OS Windows 8, 10, 11+ Windows 7 SP1+ Windows XP SP3+ Filename ImageSearch_x64.dll ImageSearch_x86.dll ImageSearch_Win7_x64.dll ImageSearch_Win7_x86.dll Embedded in UDF Compiler VS 2022 (C++23) VS 2017+ (C++14) VS 2010 (C++03) Performance Excellent Very Good Good AVX2 Support Yes (auto-detected) Yes (auto-detected) No Thread-Safety Yes (thread_local) Yes (thread_local) No (static buffer) Best Use Case High-performance automation on modern PCs. Scripts that need to run reliably on both modern systems and Windows 7 machines. Maximum compatibility for legacy systems or when no external DLLs are provided. 4. Getting Started (For AutoIt Users) Using the library is simple. Just make sure your files are organized correctly. File Structure For the best experience, place the DLL files in the same directory as your script and the UDF. /YourScriptFolder/ | |-- MyScript.au3 |-- ImageSearch_UDF.au3 |-- ImageSearch_x64.dll (Modern DLL for 64-bit) |-- ImageSearch_x86.dll (Modern DLL for 32-bit) |-- ImageSearch_Win7_x64.dll (Win7 DLL for 64-bit) |-- ImageSearch_Win7_x86.dll (Win7 DLL for 32-bit) | /-- images/ |-- button.png Quick Start Example Here is a basic AutoIt script to get you started. #include "ImageSearch_UDF.au3" ; 1. Initialize the library. The UDF will automatically load the best DLL. _ImageSearch_Startup() If @error Then MsgBox(16, "Error", "ImageSearch DLL could not be initialized. Exiting.") Exit EndIf ; You can check which version was loaded ConsoleWrite(">> Loaded DLL Version: " & _ImageSearch_GetVersion() & @CRLF) ConsoleWrite(">> System Info: " & _ImageSearch_GetSysInfo() & @CRLF) ; 2. Perform a search for an image on the entire screen. Local $sImagePath = @ScriptDir & "\images\button.png" Local $aResult = _ImageSearch($sImagePath) ; 3. Process the results. The result is ALWAYS a 2D array. If $aResult[0][0] > 0 Then ConsoleWrite("Found " & $aResult[0][0] & " match(es)!" & @CRLF) ; Loop through each match For $i = 1 To $aResult[0][0] Local $iX = $aResult[$i][1] ; X coordinate Local $iY = $aResult[$i][2] ; Y coordinate ConsoleWrite("Match #" & $i & " found at: " & $iX & ", " & $iY & @CRLF) MouseMove($iX, $iY, 20) Sleep(1000) Next Else ConsoleWrite("Image not found." & @CRLF) EndIf ; 4. Shutdown is handled automatically when the script exits. No need to call _ImageSearch_Shutdown(). 5. Full API Reference Main Functions _ImageSearch_Area(…): The main function with all available options. _ImageSearch(…): A simplified wrapper for searching the entire screen. _ImageInImageSearch_Area(…): Searches for an image within another image file. Common Parameters Parameter Description Default $sImageFile Path to the image(s). Use | to search for multiple images. $iLeft, $iTop, $iRight, $iBottom The coordinates of the search area. Entire Screen $iTolerance Color tolerance (0-255). Higher values allow for more variation. 10 $iTransparent A color in 0xRRGGBB format to be ignored during the search. -1 (disabled) $iMultiResults The maximum number of results to return. 1 $iCenterPos 1 returns the center coordinates; 0 returns the top-left. 1 $fMinScale, $fMaxScale Minimum and maximum scaling factor (e.g., 0.8 for 80%). 1.0 $fScaleStep The increment between scales (e.g., 0.1 for 10% steps). 0.1 $iFindAllOccurrences 1 finds all matches; 0 stops after the first. 0 $iUseCache 1 enables the file-based location cache; 0 disables it. 1 $iDisableAVX2 1 disables AVX2 optimization (for debugging). 0 Return Value All search functions return a 2D array. $aResult[0][0]: Contains the number of matches found. For each match $i (from 1 to $aResult[0][0]): aResult[aResult[i][1]: X coordinate aResult[aResult[i][2]: Y coordinate aResult[aResult[i][3]: Width of the found image aResult[aResult[i][4]: Height of the found image Utility Functions _ImageSearch_GetVersion(): Returns the version string of the currently loaded DLL. _ImageSearch_GetSysInfo(): Returns system info from the DLL (AVX2 support, screen resolution). _ImageSearch_ClearCache(): Deletes all cache files from the temp directory.
    1 point
  36. I saw this, but because it was downloading a file, I made the false assumption that it wouldn't work. To make matters worse, I then was informed of wget, and went about installing that, and it worked fine. I didn't put it all together until just now. This also works, as does InetRead() Yep. I have full remote access, but I need something to run automatically in case I forget to run the link. To expand, that link re-adds scheduled programs. I have someone in the house who likes to delete scheduled recordings ... Finally, it took a while to return here, as wget resolved my issue, and there were no e-mail notifications telling me there had been replies. My bad for not coming back😔
    1 point
  37. Yes, you can't know everything from the start. Either you assume that a certain functionality already exists - then you explicitly search for it. Or you implement the functionality yourself. You have done the latter and that shows that you have understood what is necessary and how to implement it. I don't care in principle. However, I think it takes me longer with Github to see that something is there. In addition, only problems and feature requests should really be posted there and not a general discussion about how to deal with the UDF. Ok - I just saw that the JSON-Test.au3 is still in German. I could adapt that at the same time. But I still don't quite know what is meant by "Write in the JSON file". How to create the JSON string is already shown in the example. Basically, all you need is a FileWrite and you're done. So perhaps I haven't quite understood what exactly needs to be added.
    1 point
  38. Ok !. The the trac entry is marked as fixed
    1 point
  39. This Ubound example is really nice. Short, sweet and concise. I ended up writing a Do...Until loop lastnight that is about 12 lines that does exactly what your single Ubound line does. Sometimes I learn and figure things out the hard way. However, I am definitely switching to your single line method now. Now this is magical. It always amazed me, here in the AutoIt forums, how there always seems to be an almost unlimited amount of ways to achieve the same end goal. Thank you for enlightening me with several methods and for taking time out of your day to share your knowledge. It was helped tremendously.
    1 point
  40. I would agree with this. For AutoIt/JSON beginners like myself, this was exactly the first thing that I was looking for in an example from the various JSON UDFs. I don't think any of them had an example of a simple load/parse/modify/save JSON. I think that an example would certainly be beneficial.
    1 point
  41. Hi @AspirinJunkie 👋 , I would suggest to extend the JSON-Test.au3 by a example of how to write in the json file. If so, also adjust the README with this example. I cannot promise it, but I would add a PR (pull request) for that. But not in the next days - too much workload at the moment. What do you think? Is it worth it? Best regards Sven
    1 point
  42. ioa747

    _SectionsArrays

    and imagine that I tried it, and it didn't work. But now with the certainty that you said it, and with a second glance it cleared up, and it worked Thank you very much for the support. update to version: 0.3
    1 point
  43. argumentum

    _SectionsArrays

    #include <Array.au3> _ArrayFromString ( $sArrayStr [, $sDelim_Col = "|" [, $sDelim_Row = @CRLF [, $bForce2D = False [, $iStripWS = $STR_STRIPLEADING + $STR_STRIPTRAILING]]]] ) $bForce2D [optional] default is False. True will force a 2 dimensional array even if 1 dimensional. If it does not work as described, let me know to fix it.
    1 point
  44. WildByDesign

    DwmColorBlurMica

    Version 1.1.3 has been added to the first post. As usual, detailed release notes are also updated on the first post with each release. The main highlight of this release is adding a 1-click option to patch all VSCode/VSCodium install locations on the system to allow for backdrop materials to be applied. Modified files are backed up and restored if/when you choose to do so. Those files get restored with each VSCode/VSCodium update also. Therefore, patching is required with each VSCode/VSCodium update. The entire GUI has been made draggable as well since there is space to do so and also because some of the backdrop materials can make it hard to tell where the titlebar is anyway. Also some nice bug fixes in this release. Next release, I will try to make a 1-click patch to patch Windows Terminal settings.json file so that users do not have to do it manually.
    1 point
  45. #include <WinApi.au3> GUIRegisterMsg($WM_TIMECHANGE, _WM_TIMECHANGE) Func _WM_TIMECHANGE($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam ConsoleWrite('> >>> WM_TIMECHANGE' & @CRLF) EndFunc @Trong, the above triggers when the time zone changes. Maybe you can reload if the unlikely possibility that it ( the time zone ) changes, for now, until the next version is released.
    1 point
  46. smbape

    Mediapipe UDF

    Update MediaPipe to 0.10.26
    1 point
  47. Trong

    ImageSearchUDF

    Version 2025.5.25.5

    11,221 downloads

    High-Performance ImageSearch UDF & DLL for AutoIt This project provides a highly optimized UDF (User Defined Function) and two versions of a DLL (Dynamic-Link Library) for fast and flexible image searching on the screen using AutoIt. It serves as a powerful replacement for standard image search functions, delivering superior speed, especially on modern CPUs, by leveraging advanced SIMD instructions. ✨ Key Features Superior Speed: The modern version utilizes the AVX2 instruction set to accelerate the search speed by several factors compared to traditional methods. Two DLL Versions: Provides both a modern version (optimized for speed) and a legacy version (for Windows XP support). Multi-Image Search: Search for multiple image files in a single function call by separating paths with a pipe (|). Multi-Scale Searching: Automatically search for an image across a range of sizes (e.g., from 80% to 120% of its original size). Color Tolerance: Find images even with slight color variations by setting a tolerance value (0-255). Transparent Color Support: Specify a color in the source image to be ignored during the search. Flexible Result Handling: Find and return the first match. Find and return all matches on the screen. Limit the maximum number of results. Smart (Hybrid) DLL Loading: The UDF prioritizes an external DLL for maximum performance and automatically falls back to an embedded DLL to ensure the script always runs. Unicode Support: Works flawlessly with file paths containing Unicode characters. Thread-Safe: The DLL is designed to operate stably in multi-threaded scenarios. Debug Information: Provides an option to return a detailed debug string for easy troubleshooting. 🚀 The Two DLL Versions The project offers two DLL versions to meet different needs: 1. ImageSearch_x86.dll ImageSearch_x64.dll (Modern Version) (Attached in the same UDF folder - Because the DLL file with AVX2 support is large in size) This is the recommended version for most users. Strengths: AVX2 Support: Leverages Advanced Vector Extensions 2 on modern CPUs to process multiple pixels in parallel, resulting in extremely fast search speeds. Built with modern C++, ensuring stability and efficiency. Limitations: Not compatible with Windows XP. When to use: When you need maximum performance on Windows 7, 8, 10, 11, and newer. 2. ImageSearch_XP.dll (Legacy Version) (Embedded in UDF code) This version is created for backward compatibility. Strengths: Windows XP Compatibility: Works well on the Windows XP (SP3) operating system. Limitations: No AVX2 Support: Search speed will be significantly slower than the modern version on AVX2-supported CPUs. When to use: When your script must run in a Windows XP environment. ⚙️ How the UDF Works The ImageSearch_UDF.au3 file uses a very smart "hybrid" DLL loading mechanism: Prioritize External DLL: When the _ImageSearch function is called, the UDF first looks for ImageSearch_x86.dll and ImageSearch_x64.dll in the same directory as the script (@ScriptDir). If found, it uses this file to achieve the best performance (with AVX2 if available). Fallback to Embedded DLL: If the external DLL is not found, the UDF will automatically extract and use a legacy (non-AVX2) compatible DLL version that is embedded within it as a hex string. ➡️ This ensures that your script can always run, even if you forget to copy the DLL file. However, for the highest speed, always place the modern ImageSearch_x86.dll and ImageSearch_x64.dll next to your script. 📦 Setup Place the DLL file: Copy ImageSearch_x86.dll and ImageSearch_x64.dll (the modern version) into the same directory as your AutoIt script file. Include the UDF in your script: Use the line #include <ImageSearch_UDF.au3> in your script. 📖 API Reference The main function for performing an image search. _ImageSearch($sImageFile, [$iLeft = 0], [$iTop = 0], [$iRight = 0], [$iBottom = 0], [$iTolerance = 10], [$iTransparent = 0xFFFFFFFF], [$iMultiResults = 0], [$iCenterPOS = 1], [$iReturnDebug = 0], [$fMinScale = 1.0], [$fMaxScale = 1.0], [$fScaleStep = 0.1], [$iFindAllOccurrences = 0]) Parameters Parameter Type Default Description $sImageFile String - Path to the image file. To search for multiple images, separate paths with a pipe (` $iLeft Int 0 The left coordinate of the search area. 0 defaults to the entire screen. $iTop Int 0 The top coordinate of the search area. 0 defaults to the entire screen. $iRight Int 0 The right coordinate of the search area. 0 defaults to the entire screen. $iBottom Int 0 The bottom coordinate of the search area. 0 defaults to the entire screen. $iTolerance Int 10 Color tolerance (0-255). A higher value allows for greater color variation. $iTransparent Int 0xFFFFFFFF The color (in 0xRRGGBB format) to be ignored in the source image. 0xFFFFFFFF means no transparency. $iMultiResults Int 0 The maximum number of results to return. 0 means no limit. $iCenterPOS Bool 1 (True) If True, the returned X/Y coordinates will be the center of the found image. If False, they will be the top-left corner. $iReturnDebug Bool 0 (False) If True, the function returns a debug string instead of the results array. $fMinScale Float 1.0 The minimum scaling factor for the search (e.g., 0.8 for 80%). Must be >= 0.1. $fMaxScale Float 1.0 The maximum scaling factor for the search (e.g., 1.2 for 120%). $fScaleStep Float 0.1 The increment to use when searching between min and max scales. Must be >= 0.01. $iFindAllOccurrences Bool 0 (False) If False, the search stops after the first match. If True, it finds all possible matches. Return Value On Success: Returns a 2D array containing the coordinates of the found images. $aResult[0][0] = The number of matches found. $aResult[1] to $aResult[$aResult[0][0]] = An array for each match. $aResult[$i][0] = X coordinate $aResult[$i][1] = Y coordinate $aResult[$i][2] = Width of the found image $aResult[$i][3] = Height of the found image On Failure / No Match: Sets @error to 1 and returns 0. In Debug Mode: If $iReturnDebug is True, returns a string containing detailed information about the last search operation. 💻 Examples Example 1: Basic Search Find the first occurrence of button.png on the screen. #include <ImageSearch_UDF.au3> Local $aResult = _ImageSearch("C:\images\button.png") If @error Then MsgBox(48, "Error", "Image not found on screen.") Else Local $iCount = $aResult[0][0] Local $iX = $aResult[1][0] Local $iY = $aResult[1][1] MsgBox(64, "Success", "Found " & $iCount & " image(s). First match is at: " & $iX & ", " & $iY) MouseMove($iX, $iY, 20) ; Move mouse to the center of the found image EndIf Example 2: Advanced Search (Multiple Images, Tolerance, Scaling) Search for icon1.png or icon2.png within a specific region, with a tolerance of 20 and scaling from 90% to 110%. Find all occurrences. #include <ImageSearch_UDF.au3> Local $sImages = "icon1.png|icon2.png" Local $iTolerance = 20 Local $fMinScale = 0.9 Local $fMaxScale = 1.1 Local $fStep = 0.05 Local $aResult = _ImageSearch($sImages, 500, 300, 1200, 800, $iTolerance, 0xFFFFFFFF, 0, True, False, $fMinScale, $fMaxScale, $fStep, True) If @error Then MsgBox(48, "Error", "No matching images found in the specified region.") Else Local $iCount = $aResult[0][0] ConsoleWrite("Found " & $iCount & " total matches." & @CRLF) For $i = 1 To $iCount ConsoleWrite("Match #" & $i & ": X=" & $aResult[$i][0] & ", Y=" & $aResult[$i][1] & ", W=" & $aResult[$i][2] & ", H=" & $aResult[$i][3] & @CRLF) Next EndIf Example 3: Using Debug Mode To diagnose issues, use the $iReturnDebug parameter. #include <ImageSearch_UDF.au3> Local $2dDLLResult = _ImageSearch("image_not_exist.png", 0, 0, 0, 0, 10, 0xFFFFFFFF, 0, True, True) ConsoleWrite(">> DLL Return: " & $g_sLastDllReturn & @CRLF) ; Example output: {0}[No Match Found] | DEBUG: File=image_not_exist.png, Rect=(0,0,1920,1080), Tol=10, Trans=0xffffffff, Multi=0, Center=1, FindAll=0, AVX2=true, Scale=(1.00,1.00,0.10) SPECIAL NOTE: The function always returns a 2D array for both results and errors. Credits Author: Dao Van Trong - TRONG.PRO Source Dll on GitHub: daovantrong/ImageSearchDLL: A DLL for finding an image on the screen
    1 point
  48. #include <json.au3> ; https://github.com/Sylvan86/autoit-json-udf $object=_JSON_Parse(FileRead(StringTrimRight(@ScriptFullPath, 4) & ".json")) ConsoleWrite('- >' & _JSON_Get($object, '.History[0].Timestamp') & '<' & @CRLF) ; 1735872629 ConsoleWrite('- >' & _JSON_Get($object, '.History[0].OtherUserId') & '<' & @CRLF) ; 10001 ConsoleWrite('- >' & _JSON_Get($object, '.History[0].Given.Currency.1755f59b3e6849db4171f93c524db28f.amount') & '<' & @CRLF) ; 2480 ..or.. #include <json.au3> ; https://github.com/Sylvan86/autoit-json-udf $object=_JSON_Parse(FileRead(StringTrimRight(@ScriptFullPath, 4) & ".json")) $iIndex = 0 While _JSON_Get($object, '.History[' & $iIndex & '].Timestamp') ConsoleWrite('- >' & _JSON_Get($object, '.History[' & $iIndex & '].Timestamp') & '<' & @CRLF) ConsoleWrite('- >' & _JSON_Get($object, '.History[' & $iIndex & '].OtherUserId') & '<' & @CRLF) $mMap = _JSON_Get($object, '.History[' & $iIndex & '].Given.Currency') $aMapKeys = MapKeys($mMap) For $n = 0 To UBound($aMapKeys) -1 ConsoleWrite('- ' & $n & ' - >' & _JSON_Get($object, '.History[' & $iIndex & '].Given.Currency.' & $aMapKeys[$n] & '.amount') & '<' & @CRLF) ConsoleWrite('- ' & $n & ' - >' & _JSON_Get($object, '.History[' & $iIndex & '].Given.Currency.' & $aMapKeys[$n] & '.id') & '<' & @CRLF) Next $iIndex += 1 WEnd using https://github.com/Sylvan86/autoit-json-udf ..also, remember to read the forum rules
    1 point
  49. Sure -- this should work... ;Check existance of a URL ;adapted to AutoIt from http://www.developerfusion.co.uk/show/1605/ ;by DaleHohm ;Timeout values in milliseconds $ResolveTimeout = 500 $ConnectTimeout = 500 $SendTimeout = 500 $ReceiveTimeout = 500 $oHttpRequest = ObjCreate("MSXML2.ServerXMLHTTP") If $oHttpRequest = 0 Then ConsoleWrite("Error creating Object $oHttpRequest. " & _ "You must have 3.0 or later of the MSXML library to use this code" & @CR) EndIf $sTestUrl = "http://www.microsoft.com/nonexistingpage.html" With $oHttpRequest .SetTimeouts ($ResolveTimeout, $ConnectTimeout, $SendTimeout, $ReceiveTimeout) .Open ("GET", $sTestUrl) .Send Select Case .Status = 200;No problem! ConsoleWrite($sTestUrl & " is a valid, available URL" & @CR) Case .Status = 404;Not found ConsoleWrite($sTestUrl & " could not be found (404 Error)" & @CR) Case Else;Some other problem ConsoleWrite("An unexpected HTTP Status value was returned: " & .Status & @CR) EndSelect EndWith $oHttpRequest = "" Enjoy, Dale Edit: Added check object creation and caveat about MSXML 3.0
    1 point
×
×
  • Create New...