Leaderboard
Popular Content
Showing content with the highest reputation since 09/20/2025 in Posts
-
So maybe i just haven't been looking hard enough, but i could not find how to make toast notifications in win8+ from AutoIt. I looked at it on and off, and finally made some progress. Github repository: https://github.com/genius257/au3toast Zip download: https://github.com/genius257/au3toast/archive/refs/tags/1.0.0.zip Enjoy!7 points
-
V1.0.0 released! 🎊 Event on toast interaction now works! 🎉6 points
-
Released v1.1.0 yesterday! Added Support for running the Format Document command via the Command Palette or hotkey using Tidy.exe on scripts, including automatic formatting on save Jest testing framework with test suite for language features and services Changed Refactored monolithic command code Upgraded build toolchain Diagnostic system overhaul with encoding handling and problem script source tracking Fixed Restored Go to Definition functionality for symbols declared outside of current script Restored Open Include file (Alt+i) functionality Path handling improvements Completion provider accuracy with user-defined functions View and Rate on VSCode Marketplace View and Rate on OpenVSX Star, Submit Issues, and Contribute on GitHub6 points
-
Added File path validation to prevent path traversal attacks Parameter safety warnings for autoit.consoleParams to detect potentially dangerous shell metacharacters Workspace symbol performance optimizations with batch processing to prevent UI freezing on large projects Configuration options autoit.workspaceSymbolMaxFiles (default: 500) and autoit.workspaceSymbolBatchSize (default: 10) Configuration option autoit.symbolMaxLines (default: 50000) to control maximum lines processed for symbol information Warning message when files exceed symbol processing limit with actionable instructions Comprehensive unit tests for completion provider with 8 test cases Comprehensive README documentation improvements with installation guide, quick start section, platform support matrix, troubleshooting guide, and reorganized configuration Distribution scripts for packaging the extension to multiple marketplaces: package-all.js for simultaneous packaging to VS Code Marketplace and OpenVSX package-openvsx.js for OpenVSX-specific packaging with publisher name handling Fixed Command injection risk in registry update functionality by replacing exec with execFile for safer argument handling Multiple global output panels opening for AutoIt on startup Memory leak in completion provider where include cache grew indefinitely across document switches Incorrect array comparison logic in completion cache invalidation Cross-document contamination of completion items from include files Changed Simplified ESLint configuration by using globals package and removing redundant rules Workspace symbol cache now uses incremental updates instead of full invalidation on file changes Completion provider now uses per-document Map-based caching with LRU eviction (50 document limit) Include cache automatically cleans up when documents are closed Symbol processing limit increased from hardcoded 10,000 to configurable 50,000 lines by default Removed The unused autoit.YAML-tmLanguage file Rate and View on VS Code Marketplace Star & Submit Issues on GitHub5 points
-
Hi @genius257, Very cool, I'm not familiar with this stuff, but it looks interesting. You've done a great job implementing it in AutoIt! I tried creating some simple test toasts in XML, but not all the tags work correctly at the moment (for example, the <image> tag doesn't display the image if the "src=" parameter is a URL...). Furthermore, it's mandatory to specify the activationType="background" parameter in the initial <toast...> tag... To generate my test toasts in XML, I installed this app (which also has ready-made templates): https://apps.microsoft.com/detail/9nblggh5xsl1 then, to insert the generated XML code into your example listing in AutoIt, I copy the generated code to the clipboard (select the listing and press Ctrl-C), and immediately run this little script (F5 in SciTE), which adapts it and puts it back in the clipboard. I then paste it into the AutoIt listing. Local $sVarName = "$sToast" Local $aStr = StringSplit(ClipGet(), @CRLF, 1) ; get the clipboard content Local $sListing ; = "Func " & $sFuntionName & "()" & @CRLF $sListing &= 'Local ' & $sVarName & ' = ""' & @CRLF For $i = 1 To $aStr[0] $sListing &= $sVarName & ' &= "' & StringReplace($aStr[$i], '"', '""') & '" ' & @CRLF Next ClipPut($sListing) ConsoleWrite($sListing) This is an example of output (which I later modified a bit) to insert into the example script. Local $sToast = "" $sToast &= "<toast activationType=""background"" launch=""action=viewAlarm&alarmId=3"" scenario=""alarm"">" $sToast &= "" $sToast &= " <visual>" $sToast &= " <binding template=""ToastGeneric"">" $sToast &= " <text>Time to wake up!</text>" $sToast &= " <text>To prove you're awake, select which of the following fruits is yellow...</text>" $sToast &= ' <image placement="appLogoOverride" src="file://' & @TempDir & '\e21cd29c9fb51c3a5b82f009ec33fc997d2edd1ece931e8568f37e205c445778.jpeg" hint-crop="circle"/>' $sToast &= " </binding>" $sToast &= " </visual>" $sToast &= "" $sToast &= " <actions>" $sToast &= "" $sToast &= " <input id=""answer"" type=""selection"" defaultInput=""wrongDefault"">" $sToast &= " <selection id=""wrong"" content=""Orange""/>" $sToast &= " <selection id=""wrongDefault"" content=""Blueberry""/>" $sToast &= " <selection id=""right"" content=""Banana""/>" $sToast &= " <selection id=""wrong"" content=""Avacado""/>" $sToast &= " <selection id=""wrong"" content=""Cherry""/>" $sToast &= " </input>" $sToast &= "" $sToast &= " <action" $sToast &= " activationType=""system""" $sToast &= " arguments=""snooze""" $sToast &= " content=""""/>" $sToast &= "" $sToast &= " <action" $sToast &= " activationType=""background""" $sToast &= " arguments=""dismiss""" $sToast &= " content=""Dismiss""/>" $sToast &= "" $sToast &= " </actions>" $sToast &= ' <audio src=''ms-winsoundevent:Notification.Looping.Alarm'' loop=''false''/>' $sToast &= "</toast>" .. I hope you can implement support for events too... Bye and thanks! P.S. There was a notification "emulator" at this link:: Notifications UDF - Desktop notifications 1.2 (updated Mai 1st) - AutoIt Example Scripts - AutoIt Forums4 points
-
Move window behind desktop icons
Parsix and 2 others reacted to WildByDesign for a topic
That's a very good point. I shouldn't have used a hardcoded path like that. I like the creative way that you used the @AutoItExe macro to get the AutoIt install directory. Thanks for sharing. This was a really fun example. Thanks for sharing. I didn't expect that a child GUI would work in this type of situation, so that was a neat surprise.3 points -
to test different patterns simultaneously ; https://www.autoitscript.com/forum/topic/212981-move-window-behind-desktop-icons/page/2/#findComment-1544444 #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", True) Example() Func Example() Local $hWorkerW = _GetDesktopWorkerW() If @error Then Exit MsgBox(16, @ScriptName, "! Error - Couldn't find WorkerW under Progman", 30) ConsoleWrite("WorkerW = " & $hWorkerW & @CRLF) ; Overlay GUICreate Local $hGUI = GUICreate("Overlay", @DesktopWidth, @DesktopHeight, -1, -1, $WS_POPUP, $WS_EX_TOOLWINDOW) Local $BkColor = 0x000000 GUISetBkColor($BkColor, $hGUI) GUISetFont(12) _WinAPI_SetParent($hGUI, $hWorkerW) _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_LAYERED)) _WinAPI_SetLayeredWindowAttributes($hGUI, 0, 150, $LWA_ALPHA) GUISetState(@SW_SHOWNOACTIVATE) Local $aChildGui[10] = [9], $aLbl[10] = [9] Local $iW = @DesktopWidth * 0.33, $iH = @DesktopHeight * 0.33, $iX = 0, $iY = 20, $iCnt = 0 For $i = 1 To 3 For $j = 1 To 3 $iCnt += 1 $aChildGui[$iCnt] = GUICreate("Child_" & $iCnt, $iW, $iH, $iX, $iY, $WS_CHILD, $WS_EX_TOOLWINDOW, $hGUI) $BkColor = "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) ConsoleWrite("$BkColor=" & $BkColor & @CRLF) GUISetBkColor($BkColor, $aChildGui[$iCnt]) $aLbl[$iCnt] = GUICtrlCreateLabel("Child_" & $iCnt & ", BkColor:" & $BkColor, 0, 0, $iW, 25) GUICtrlSetFont(-1, 18) GUISetState(@SW_SHOWNOACTIVATE) $iX += $iW Next $iX = 0 $iY += $iH Next $iCnt = 0 While GUIGetMsg() <> $GUI_EVENT_CLOSE Sleep(50) $iCnt += 1 If $iCnt > 40 Then $iCnt = 0 For $i = 1 To $aChildGui[0] $BkColor = "0x" & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) & Hex(Random(0, 255, 1), 2) GUISetBkColor($BkColor, $aChildGui[$i]) GUICtrlSetData($aLbl[$i], "Child_" & $i & ", BkColor:" & $BkColor) Next EndIf WEnd EndFunc ;==>Example Func _GetDesktopWorkerW() Local $hWorkerW = 0, $hProgman = _WinAPI_GetShellWindow() _WinAPI_SendMessageTimeout($hProgman, 0x052C, 0, 0, 3000, $SMTO_NORMAL) ; same as _SendMessage() Local $aEnumWindows = WinList("[CLASS:WorkerW]") For $n = 1 To $aEnumWindows[0][0] Local $hWnd = $aEnumWindows[$n][1] If _WinAPI_GetParent($hWnd) = $hProgman Then Return SetError(0, $hProgman, $hWnd) Next Return SetError(1, $hProgman, 0) EndFunc ;==>_GetDesktopWorkerW3 points
-
Move window behind desktop icons
Parsix and 2 others reacted to WildByDesign for a topic
I was so grouchy at the thought of blasting away my Windows partition to reinstall Windows but thankfully I figured it out before I got that far. In Advanced System Properties (SystemPropertiesAdvanced.exe) in the Performance settings dialog - Visual Effects tab, there is a checkbox labelled "Animate controls and element inside windows". Apparently that simple little checkbox controls whether or not a WorkerW window is even allowed to be created under Progman. I have always disabled any and all animation effects in Windows for years. And this was one of them. After checking this box, WorkerW is able to be created under Progman and all is good now. All examples work on my machine now. I would have reinstalled Windows and it still would have failed because disabling animation effects is one of the first things that I do after a clean install. 😄3 points -
No need to click for see it, just put your mouse on the left side of your screen Why on the left? Because the taskbar is already crowded, on the right side we scroll, and at the top when we use our browser tab by tab, it's not convenient to have a GUI in the way. You can add Shortcut, InternetShortcut, Files, and Folder by drag and drop on any button (special folders not supported) Right click menu on it for delete item See tray menu for options To exit, click on the InfoBar at the bottom of the GUI or by tray menu SlidingToolbar.7z3 points
-
I don't know if something like this has already been posted. DarkMode API Calls (undocumented): ;Coded by UEZ build 2025-10-10 ;IMMERSIVE_HC_CACHE_MODE Enum $IHCM_USE_CACHED_VALUE, $IHCM_REFRESH Enum $Default, $AllowDark, $ForceDark, $ForceLight, $Max ;$iPreferredAppMode ;~ Enum $DWMWA_USE_IMMERSIVE_DARK_MODE = (@OSBuild <= 18985) ? 19 : 20 Func _WinAPI_ShouldAppsUseDarkMode() Local $aResult = DllCall("UxTheme.dll", "bool", 132) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_ShouldAppsUseDarkMode Func _WinAPI_AllowDarkModeForWindow($hWND, $bAllow = True) Local $aResult = DllCall("UxTheme.dll", "bool", 133, "hwnd", $hWND, "bool", $bAllow) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_AllowDarkModeForWindow Func _WinAPI_AllowDarkModeForApp($bAllow = True) ;Windows 10 Build 17763 Return _WinAPI_SetPreferredAppMode($bAllow ? 1 : 0) ; 1 = AllowDark, 0 = Default EndFunc ;==>_WinAPI_AllowDarkModeForApp Func _WinAPI_SetPreferredAppMode($iPreferredAppMode) ;Windows 10 Build 18362+ Local $aResult = DllCall("UxTheme.dll", "long", 135, "long", $iPreferredAppMode) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_SetPreferredAppMode Func _WinAPI_FlushMenuThemes() Local $aResult = DllCall("UxTheme.dll", "none", 136) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_FlushMenuThemes Func _WinAPI_RefreshImmersiveColorPolicyState() Local $aResult = DllCall("UxTheme.dll", "none", 104) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_RefreshImmersiveColorPolicyState Func _WinAPI_IsDarkModeAllowedForWindow($hWND) Local $aResult = DllCall("UxTheme.dll", "bool", 137, "hwnd", $hWND) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_IsDarkModeAllowedForWindow Func _WinAPI_GetIsImmersiveColorUsingHighContrast($iIMMERSIVE_HC_CACHE_MODE) Local $aResult = DllCall("UxTheme.dll", "bool", 106, "long", $iIMMERSIVE_HC_CACHE_MODE) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_GetIsImmersiveColorUsingHighContrast Func _WinAPI_OpenNcThemeData($hWND, $tClassList) Local $aResult = DllCall("UxTheme.dll", "hwnd", 49, "hwnd", $hWND, "struct*", $tClassList) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_OpenNcThemeData Func _WinAPI_ShouldSystemUseDarkMode() Local $aResult = DllCall("UxTheme.dll", "bool", 138) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_ShouldSystemUseDarkMode Func _WinAPI_IsDarkModeAllowedForApp() Local $aResult = DllCall("UxTheme.dll", "bool", 139) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_IsDarkModeAllowedForApp Requires OSBuild > 17762! API may change in next Windows updates! PS: I've reinvented the wheel ->3 points
-
read and write xlsx files without Excel
ermar and 2 others reacted to AspirinJunkie for a topic
Several adjustments were made within the UDF. 1. Writing Excel function cells _xlsx_WriteFromArray() can now write Excel functions. For this, the element value in the input array must be a string that starts with `=`. The string itself is then interpreted as an Excel function. Example: =IF(F2>E2,"yes","no") Note: For Excel to interpret this correctly, only the English notation is permitted. If you need to write a string that starts with `=` but should not be interpreted as a function, escape the first `=` by doubling it (`==`). 2. Smallest possible .xlsx output files The .xlsx file generated with _xlsx_WriteFromArray() has been consistently optimized for minimal size. Files produced this way are close to the minimum possible for the format given the data. Sample dataset: [[1,2,3],[4,5,6]] Excel: 8.45 KB _xlsx_WriteFromArray(): 1.23 KB 3. Formatting of date and time If an element value in the input array for _xlsx_WriteFromArray() contains a date or time, the cell in the .xlsx file is formatted accordingly as date, time, or date/time style. The string format for these cells must be as follows: Date: YYYY-MM-DD Time: HH:MM[:SS[.mmmmmm]] Date + Time: YYYY-MM-DD[T ]HH:MM[:SS[.mmmmmm]] Note: Date and Date+Time remain as string values. A pure time, however, is encoded as a number (Excel notation where 24h = 1.0). Bug fixes and style _xlsx_2Array() can now also handle files whose sharedstrings.xml elements have a prefix (= higher compatibility). _xlsx_2Array() now also reads files that skip empty rows (= higher compatibility). Au3Check no longer emits (partly incorrect) warnings when using the UDF.3 points -
here is a simple powershell command I use to set an ignore exclusion in Defender for a specific folder Run(@ComSpec & ' /c powershell -Command Add-MpPreference -ExclusionPath ' & '"' & @ScriptDir & '"' & ' -Force', @ScriptDir, @SW_HIDE) Use this command where ever your compiled script is to be created. By changing the word Add to Remove, it will remove the set exclusion. This script will require Administrative rights to be able to perform its function(s).3 points
-
UEZ's solution is better - but I did the work so... Technically it'll be in the ttf/otf itself in the name table #include <AutoitConstants.au3> #include <FileConstants.au3> Local $hFontFile = FileOpen("C:\Windows\Fonts\wingding.ttf", $FO_BINARY) Local $tagTTCHeader = "align 4; uint sfntVersion; ushort numTables; ushort searchRange; ushort entrySelector; ushort rangeShift" Local $tTTCHeader = DllStructCreate($tagTTCHeader) Local $iTTCHeaderLen = DllStructGetSize($tTTCHeader) Local $tTTCHeaderBuff = DllStructCreate(StringFormat("byte data[%d]", $iTTCHeaderLen), DllStructGetPtr($tTTCHeader)) $tTTCHeaderBuff.Data = FileRead($hFontFile, $iTTCHeaderLen) Local $iNumTables = _ByteSwap($tTTCHeader.numTables, 16) Local $tagTableRecord = "align 4; char tag[4]; uint checksum; uint offset; uint length" Local $tTableRecord = DllStructCreate($tagTableRecord) Local $iTableRecordLen = DllStructGetSize($tTableRecord) Local $tTableRecordBuff = DllStructCreate(StringFormat("byte data[%d]", $iTableRecordLen), DllStructGetPtr($tTableRecord)) Local $iNameTabOffset, $iNameTabTotalLen For $i = 1 To $iNumTables $tTableRecordBuff.Data = FileRead($hFontFile, $iTableRecordLen) ConsoleWrite(StringFormat("table: %s Offset: %08x Length: %08x\r\n", _ $tTableRecord.tag, _ByteSwap($tTableRecord.Offset), _ByteSwap($tTableRecord.Length))) If $tTableRecord.tag = "name" Then $iNameTabOffset = _ByteSwap($tTableRecord.Offset) $iNameTabLen = _ByteSwap($tTableRecord.Length) ExitLoop EndIf Next FileSetPos($hFontFile, $iNameTabOffset, $FILE_BEGIN) Local $tagNameTable = "align 4; ushort version; ushort count; ushort storageOffset" Local $tNameTable = DllStructCreate($tagNameTable) Local $iNameTabLen = DllStructGetSize($tNameTable) Local $tNameTableBuff = DllStructCreate(StringFormat("byte data[%d]", $iNameTabLen), DllStructGetPtr($tNameTable)) $tNameTableBuff.data = FileRead($hFontFile, $iNameTabLen) Local $iNameRecordCount = _ByteSwap($tNameTable.count, 16) Local $iNameStorageOffset = _ByteSwap($tNameTable.storageOffset, 16) Local $tagNameRecord = "align 4; ushort platformID; ushort encodingID; ushort languageID; ushort nameID; ushort length; ushort stringOffset;" Local $tNameRecord = DllStructCreate($tagNameRecord) Local $iNameRecordLen = DllStructGetSize($tNameRecord) Local $tNameRecordBuff = DllStructCreate(StringFormat("byte data[%d]", $iNameRecordLen), DllStructGetPtr($tNameRecord)) Local $iFontFamilyNameOffset, $iFontFamilyNameLen For $i = 1 To $iNameRecordCount $tNameRecordBuff.data = FileRead($hFontFile, $iNameRecordLen) ConsoleWrite(StringFormat("NameRecord: nameID: %04x length %04x offset %04x", _ _ByteSwap($tNameRecord.nameID, 16), _ByteSwap($tNameRecord.length, 16), _ByteSwap($tNameRecord.stringOffset, 16)) & @CRLF) If _ByteSwap($tNameRecord.nameID, 16) = 1 Then ; Font Family name. $iFontFamilyNameLen = _ByteSwap($tNameRecord.length, 16) $iFontFamilyNameOffset = _ByteSwap($tNameRecord.stringOffset, 16) ExitLoop EndIf Next FileSetPos($hFontFile, $iNameTabOffset + $iNameStorageOffset + $iFontFamilyNameOffset, $FILE_BEGIN) Local $tFontFamilyName = DllStructCreate(StringFormat("char Name[%d]", $iFontFamilyNameLen)) Local $tFontFamilyNameBuff = DllStructCreate(StringFormat("byte data[%d]", $iFontFamilyNameLen), DllStructGetPtr($tFontFamilyName)) $tFontFamilyNameBuff.Data = FileRead($hFontFile, $iFontFamilyNameLen) MsgBox(0, "Font Family Name", $tFontFamilyName.Name) FileClose($hFontFile) Func _ByteSwap($iInt, $iSize = 32) Switch $iSize Case 16 Return BitAND(0xFFFF, BitOR(BitAND(0xFF00, BitShift($iInt, -8)), BitShift($iInt, 8))) Case 32 Local $tBuff = DllStructCreate("byte[4]") For $i = 1 To 4 DllStructSetData($tBuff, 1, BitAND($iInt, 0xFF), 5-$i) $iInt = BitShift($iInt, 8) Next Local $tInt = DllStructCreate("int", DllStructGetPtr($tBuff)) Return DllStructGetData($tInt, 1) EndSwitch EndFunc3 points
-
Free style DateTimeFormat
argumentum and 2 others reacted to ioa747 for a topic
_DTFormat Formats a given date/time string according to the specified format. _DTFormat($sDate, $sFormat [, $iLcid = $LOCALE_USER_DEFAULT]) $sDate - The date string to be formatted "[YYYY/MM/DD][ HH:MM:SS [ tt]]" $sFormat - A string containing the desired format for the date and time. Supported tokens are: Date and/or Time Date: d, dd = day; ddd, dddd = day of week; M= month; y = year Time: h= hour m= minute s = second (long time only) tt= AM. or P.M. h/H = 12/24 hour hh, mm, ss = display leading zero h, m, s = do not display leading zero Tokens can be separated by '|' to specify different formats for date and time. $iLcid - [optional] The locale identifier. Defaults to the user's default locale (default is $LOCALE_USER_DEFAULT). ; https://www.autoitscript.com/forum/topic/213249-free-style-datetimeformat/ ;---------------------------------------------------------------------------------------- ; Title...........: _DTFormat.au3 ; Description.....: Formats a given date/time string according to the specified format. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.1 ; Note............: Testet in Win10 22H2 Date:07/10/2025 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <Date.au3> Example() ; Function to demonstrate the use of _DTFormat Func Example() ; https://help.tradestation.com/10_00/eng/tsdevhelp/elobject/class_el/lcid_values.htm ; Example using specific LCID (German=1031, English=1033, Spain=1034, France=1036) ConsoleWrite("- German : " & _DTFormat("2025/09/01 08:30:00 PM", "dddd, d MMMM yyyy|, HH:mm", 1031) & @CRLF) ConsoleWrite("- English : " & _DTFormat("2025/09/01 08:30:00 PM", "dddd, d MMMM yyyy|, HH:mm", 1033) & @CRLF) ConsoleWrite("- Spain : " & _DTFormat("2025/09/01 08:30:00 PM", "dddd, d MMMM yyyy|, HH:mm", 1034) & @CRLF) ConsoleWrite("- France : " & _DTFormat("2025/09/01 08:30:00 PM", "dddd, d MMMM yyyy|, HH:mm", 1036) & @CRLF) ConsoleWrite("-" & @CRLF) ; Example using the default User Locale LCID ConsoleWrite("- User Locale : " & _DTFormat("2025/09/01 20:30:00", "dddd, d MMMM yyyy|, hh:mm tt") & @CRLF) ConsoleWrite("- MMMM yyyy : " & _DTFormat("2025/09/01", "MMMM yyyy") & @CRLF) ConsoleWrite("- Date & Time : " & _DTFormat("2025/09/01 20:30:00", "'Date:' dddd d|, 'Time:' HH:mm") & @CRLF) ConsoleWrite("-" & @CRLF) ; More Example ConsoleWrite("- only Time : " & _DTFormat("08:30:00 PM", "HH:mm:ss") & @CRLF) ConsoleWrite("- only Date : " & _DTFormat("2025/09/01", "dddd, d MMMM yyyy") & @CRLF) ConsoleWrite("-" & @CRLF) ConsoleWrite("- _NowCalc() : " & _NowCalc() & @CRLF) ConsoleWrite("- only Time : " & _DTFormat(_NowCalc(), "|HH:mm:ss") & @CRLF) ConsoleWrite("- only Date : " & _DTFormat(_NowCalc(), "dddd, d MMMM yyyy|") & @CRLF) ConsoleWrite("-" & @CRLF) ConsoleWrite("- ! HH with tt: " & _DTFormat("08:30:00 PM", "HH:mm tt") & @CRLF) ConsoleWrite("- Now Stamp : " & _DTFormat(_NowCalc(), "yyyy_MM_dd|_HH_mm_ss_" & @MSEC) & @CRLF) ConsoleWrite("-" & @CRLF) EndFunc ;==>Example ; #FUNCTION# ==================================================================================================================== ; Name...........: _DTFormat ; Description....: Formats a given date/time string according to the specified format. ; Syntax.........: _DTFormat($sDate, $sFormat [, $iLcid = $LOCALE_USER_DEFAULT]) ; Parameters.....: $sDate - The date string to be formatted "[YYYY/MM/DD][ HH:MM:SS [ tt]]". ; $sFormat - A string containing the desired format for the date and time. ; Supported tokens are: Date and/or Time ; Date: ; d, dd = day; ddd, dddd = day of week; M= month; y = year ; Time: ; h= hour m= minute ; s = second (long time only) ; tt= AM. or P.M. ; h/H = 12/24 hour ; hh, mm, ss = display leading zero ; h, m, s = do not display leading zero ; Tokens can be separated by '|' to specify different formats for date and time. ; $iLcid - [optional] The locale identifier. Defaults to the user's default locale (default is $LOCALE_USER_DEFAULT). ; Return values .: Success: Returns the formatted date string. ; Failure: Returns an empty string and set the @error flag to non-zero. ; @error: ; 1 - Error date is not valid. ; 2 - Error in splitting the date string ; 3 - Error in encoding SystemTime ; 4 - Error in time formatting ; 5 - Error in date formatting ; Author ........: ioa747 ; Modified ......: ; Remarks .......: This function uses the Windows API to format date and time according to the specified locale. ; Related .......: _Date_Time_EncodeSystemTime, _WinAPI_GetDateFormat, _WinAPI_GetTimeFormat, _WinAPI_GetLocaleInfo ; Link ..........: https://learn.microsoft.com/en-us/windows/win32/intl/day--month--year--and-era-format-pictures ; Example .......: MsgBox(0, "Formatted Date", _DTFormat("2023/10/05 14:30:00", "MM/DD/YYYY|, HH:MM:SS")) ; =============================================================================================================================== Func _DTFormat($sDate, $sFormat, $iLcid = $LOCALE_USER_DEFAULT) Local $asDatePart[4], $asTimePart[4] Local $sTempDate = "", $sTempTime = "" Local $sAM, $sPM, $sTempString = "" Local $bDate = True ; If there is no date, add a dummy one (2000/01/01) If StringInStr($sDate, "/") = 0 And Not @error Then $bDate = False $sDate = "2000/01/01 " & $sDate Else ; Verify If InputDate is valid If Not _DateIsValid($sDate) Then Return SetError(1, 0, "") ; Error date is not valid. EndIf ; Split the date and time into arrays _DateTimeSplit($sDate, $asDatePart, $asTimePart) If @error Then Return SetError(2, @error, "") ; Error in splitting the date string Local $aPart = StringSplit($sFormat, "|") If $bDate Then $sTempDate = $aPart[1] $sTempTime = "" If $aPart[0] = 2 Then $sTempTime = $aPart[2] Else $sTempTime = $aPart[1] EndIf ; If time parts exist, check for AM/PM and convert to 24-hour format If $asTimePart[0] > 1 Then ; Get locale's AM designator, or AM $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S1159) ; AM designator. If Not @error And Not ($sTempString = '') Then $sAM = $sTempString Else $sAM = "AM" EndIf ; Get locale's PM designator, or PM $sTempString = _WinAPI_GetLocaleInfo($iLcid, $LOCALE_S2359) ; PM designator. If Not @error And Not ($sTempString = '') Then $sPM = $sTempString Else $sPM = "PM" EndIf ; Convert 12-hour clock (with PM) to 24-hour clock If (StringInStr($sDate, 'pm') > 0) Or (StringInStr($sDate, $sPM) > 0) Then If $asTimePart[1] < 12 Then $asTimePart[1] += 12 ; Convert 12-hour clock (with AM) to 24-hour clock (handle 12 AM midnight case) ElseIf (StringInStr($sDate, 'am') > 0) Or (StringInStr($sDate, $sAM) > 0) Then If $asTimePart[1] = 12 Then $asTimePart[1] = 0 EndIf EndIf ; Remove ' tt' if hour is in format H/24 hour If StringInStr($sTempTime, "H", 1) > 0 Then $sTempTime = StringReplace($sTempTime, " tt", "") ; Encode a system time structure (required by WinAPI date/time functions) Local $tSystem = _Date_Time_EncodeSystemTime($asDatePart[2], $asDatePart[3], $asDatePart[1], $asTimePart[1], $asTimePart[2], $asTimePart[3]) If @error Then Return SetError(3, @error, "") ; Error in encoding SystemTime Local $sfinalTime = _WinAPI_GetTimeFormat($iLcid, $tSystem, 0, $sTempTime) If @error Then Return SetError(4, @error, "") ; Error in time formatting ; Force AM/PM if the format string contains 'tt' but regional settings didn't include it If StringInStr($sTempTime, "tt") Then If (StringInStr($sfinalTime, 'pm') = 0) And (StringInStr($sfinalTime, $sPM) = 0) And _ (StringInStr($sfinalTime, 'am') = 0) And (StringInStr($sfinalTime, $sAM) = 0) Then If $asTimePart[1] < 12 Then $sfinalTime &= " " & $sAM Else $sfinalTime &= " " & $sPM EndIf EndIf EndIf Local $sResult = "" If $sTempDate <> "" Then $sResult &= _WinAPI_GetDateFormat($iLcid, $tSystem, 0, $sTempDate) If @error Then Return SetError(5, @error, "") ; Error in date formatting If $sTempTime <> "" Then $sResult &= $sfinalTime Return $sResult EndFunc ;==>_DTFormat Please, every comment is appreciated! leave your comments and experiences here! Thank you very much3 points -
Show Adapters (Disable/Enable/Info)
argumentum and 2 others reacted to TheSaint for a topic
Just a little program I whipped up today. If like me, you connect to the web via LAN, but don't always like your PC to be connected all the time, especially at boot up, then you might find my script handy. Basically I use it to turn my Ethernet connection off. A fairly simple affair, and the state persists after shutdown. BIG THANKS to jguinch for the Network configuration UDF. My script uses and requires the Network.au3 include file from the first post of that topic. My script runs with Admin Rights, as per the first line of the script. Show Adapters.au3 NOTE - On my system, some adapters have a CRLF in the middle of the returned entry. My script changes that, within program, to a backward slash (\) for ease of use etc. As can be noted in the screenshot, the second portion, after the backslash, is the actual adapter name used for ENABLE and DISABLE and getting INFO. To work with the same adapter by default, you can SAVE a selected entry as the one, which can appear selected at startup after first being checked. Enjoy!3 points -
_LinksInspector
argumentum and 2 others reacted to ioa747 for a topic
Links Inspector This AutoIt script designed to scan a text-based file (e.g., TXT, HTML, XML, MD) for URLs and check their current HTTP status code. (to see if the link is active) (The tool is a "Public Link Accessibility Checker" and not a full HTTP client with authentication capabilities.) Results can be filtered to show: All links '*' All non-200 codes '!' Specific codes e.g. '404, 503, 301' HTTP response status codes _LinksInspector.au3 ; https://www.autoitscript.com/forum/topic/213221-_linksinspector/ ;---------------------------------------------------------------------------------------- ; Title...........: _LinksInspector.au3 ; Description.....: Searches a file for URLs and checks their status codes. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.4 ; Note............: Testet in Win10 22H2 Date:03/10/2025 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #include <GuiListView.au3> #include <GUIConstants.au3> #include <WinAPIShellEx.au3> ; Constants for Filtering Global Const $LINKS_BROKEN = "0, 404, 500, 501, 502, 503, 504" Global Const $LINKS_NEEDS_REVIEW = "301, 302, 307, 400, 401, 403" ; (Redirections, Unauthorized, Forbidden) ; Constant for WinHttp Options Global Const $WinHttpRequestOption_EnableRedirects = 6 ; Global variable Global $g_hListView, $g_iListIndex = -1 Global $g_ObjErr = ObjEvent("AutoIt.Error", "__ObjAutoItErrorEvent") Global $g_aLastComError[0] ; Global variable to store the last COM error: [Description, Number, Source, ScriptLine] Global $g_oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") If Not IsObj($g_oHTTP) Then MsgBox(16, "Error", "Failed to create WinHttp.WinHttpRequest.5.1 COM object.") Exit EndIf ; #FUNCTION# ==================================================================================================================== ; Name...........: _LinksInspector ; Description....: Searches a file for URLs and checks their status codes, filtering based on specified criteria. ; Syntax.........: _LinksInspector($sFilePath [, $sFilter = "*" [, $bAttribOnly = False [, $idProgress = 0]]]) ; Parameters.....: $sFilePath - The path to the file containing the text to be searched. ; $sFilter - [Optional] Filtering mode: ; "*": Show all results (default for full review). ; "!": Show all except 200 (i.e., all errors and redirects). ; "400, 404": Show only the specific comma-separated status codes. ; $bAttribOnly - [Optional] True = Search ONLY for URLs within HTML/XML attributes (e.g., href="..."). (Default = False) ; : $idProgress - [Optional] The control ID of the progress bar to update, if there is a GUI. Default 0 (no update). ; Return values..: Success - Returns a 2D array: [LineNumbers (delimited by ';'), StatusCode, StatusText, URL]. ; Failure - Returns a empty 2D array and sets @error: ; 1 - The specified file path is invalid. ; 2 - No links found in the file content. ; Author ........: ioa747 ; Modified ......: ; Remarks .......: This function it uses the WinHttp.WinHttpRequest.5.1 COM object for efficient and reliable network requests. ; Checks each unique URL only once, regardless of how many times it appears in the file. ; Uses the HEAD method to retrieve status codes without downloading the full page content. ; Automatically follows redirects (3xx codes) to find the final status (e.g., 200 or 404). ; Utilizes ObjEvent to silently capture and log COM errors (like timeouts or DNS failures) as Status Code 0. ; Related .......: __CheckLinkStatus, __ObjAutoItErrorEvent ; Link ..........: https://www.autoitscript.com/forum/topic/213221-_linksinspector/ ; https://learn.microsoft.com/en-us/windows/win32/winhttp/winhttprequest ; https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status ; Example .......: _LinksInspector("C:\example.txt", "400, 404") ; to find and check URLs with specific status codes. ; =============================================================================================================================== Func _LinksInspector($sFilePath, $sFilter = "*", $bAttribOnly = False, $idProgress = 0) Local $aResults[0][4] Local $aUniqueLinks[0][2] ; [URL, Line_Numbers_String (e.g., "12;24")] ; Define Regex Patterns based on the optional flag ; Pattern for ATTRIBUTE SEARCH (Higher precision for HTML/XML): Finds URLs starting after =" or =' Local $sPatternAttrib = '(?i)[=""''](https?:\/\/[^""''\s<>]+)' ; Pattern for FULL SEARCH (Includes Attributes and Plain Text): The original broad pattern Local $sPatternFull = '(?i)(https?:\/\/[^""''\s<>]+)' Local $aFileLines = FileReadToArray($sFilePath) If @error Then MsgBox(16, "Error", "Failed to read file: " & $sFilePath) Return SetError(1, 0, $aResults) EndIf ; Filter Preprocessing (Logic remains the same) $sFilter = StringStripWS($sFilter, 8) Local $bFilterAll = ($sFilter = "*") Local $bFilterExclude200 = ($sFilter = "!") Local $aFilterCodes = 0 If Not $bFilterAll And Not $bFilterExclude200 Then $aFilterCodes = StringSplit($sFilter, ",", 2) EndIf Local $iLineCount = UBound($aFileLines) ; Select the appropriate pattern Local $sPattern = $sPatternFull If $bAttribOnly Then $sPattern = $sPatternAttrib EndIf ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; STAGE 1: Extract all links and record all lines where they appear (Handling Duplicates) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For $i = 0 To $iLineCount - 1 Local $sLine = $aFileLines[$i] Local $iLineNum = $i + 1 ; Use the selected pattern to find links Local $aLinks = StringRegExp($sLine, $sPattern, 3) If Not @error And IsArray($aLinks) Then For $j = 0 To UBound($aLinks) - 1 Local $sCleanURL = StringReplace($aLinks[$j], "&", "&") $sCleanURL = StringRegExpReplace($sCleanURL, '[\)\(\"''<>,\.]$', "") $sCleanURL = StringStripWS($sCleanURL, 3) ; Find if the URL already exists in our unique list Local $iIndex = _ArraySearch($aUniqueLinks, $sCleanURL, 0, 0, 0, 0, 1, 0) If $iIndex = -1 Then ; URL is new, add it to the unique list _ArrayAdd($aUniqueLinks, $sCleanURL & "|" & $iLineNum, "|") Else ; URL already exists, append the current line number to the string $aUniqueLinks[$iIndex][1] = $aUniqueLinks[$iIndex][1] & ";" & $iLineNum EndIf Next EndIf Next If UBound($aUniqueLinks) = 0 Then Return SetError(2, 0, $aResults) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; STAGE 2: Check the status of each UNIQUE link and apply filter ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Local $iUniqueCount = UBound($aUniqueLinks) For $i = 0 To $iUniqueCount - 1 ; *** Update GUI only if a valid Progress Bar ID is given *** If $idProgress <> 0 Then Local $iPercent = Int((($i + 1) / $iUniqueCount) * 100) GUICtrlSetData($idProgress, $iPercent) Sleep(10) ; Short pause for GUI response EndIf Local $sURL = $aUniqueLinks[$i][0] Local $sLineNums = $aUniqueLinks[$i][1] Local $aStatus = __CheckLinkStatus($sURL) Local $iStatusCode = $aStatus[0] ; Filtering Logic Local $bAddResult = False If $bFilterAll Then $bAddResult = True ElseIf $bFilterExclude200 Then If $iStatusCode <> 200 Then $bAddResult = True ElseIf IsArray($aFilterCodes) Then If _ArraySearch($aFilterCodes, $iStatusCode) <> -1 Then $bAddResult = True EndIf If $bAddResult Then _ArrayAdd($aResults, $sLineNums & "|" & $iStatusCode & "|" & $aStatus[1] & "|" & $sURL) EndIf ; for debugging purposes only ConsoleWrite(($bAddResult ? "+ " : "- ") & $sLineNums & " |> " & $aStatus[1] & " |> " & $sURL & @CRLF) Next If UBound($aResults) = 0 Then Return SetError(2, 0, $aResults) Return $aResults EndFunc ;==>_LinksInspector ;--------------------------------------------------------------------------------------- Func __CheckLinkStatus($sURL) Local $iStatusCode = 0 Local $sStatusText = "Failed - Connection/Timeout Error" ; Set timeouts for the current request ; ResolveTimeout: 5 sec ; ConnectTimeout: 5 sec ; SendTimeout: 10 sec ; ReceiveTimeout: 10 sec $g_oHTTP.SetTimeouts(5000, 5000, 10000, 10000) ; *** WinHttp will follow up to 10 redirects to find the final code ($200 or $404). $g_oHTTP.SetOption($WinHttpRequestOption_EnableRedirects, True) ; Clear the global COM error log before the call ReDim $g_aLastComError[0] ; Open and Send the Request $g_oHTTP.Open("HEAD", $sURL, False) $g_oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36") ; If a COM error occurs here (e.g. DNS fail), it will fill $g_aLastComError, ; but the script flow will continue without a MsgBox. $g_oHTTP.Send() ; Check the global COM error log immediately after the call If UBound($g_aLastComError) > 0 Then ; A COM errors $iStatusCode = 0 $sStatusText = "Failed - COM Error: (" & StringReplace($g_aLastComError[0], @CRLF, " ") & ")" ElseIf @error Then ; AutoIt errors $iStatusCode = 0 $sStatusText = "Failed - AutoIt Error (" & @error & ")" Else ; The call was successful, retrieve the HTTP status $iStatusCode = $g_oHTTP.Status $sStatusText = $g_oHTTP.StatusText EndIf ; Process Status Text for final output Select Case $iStatusCode == 0 ; Status text is already set Case $iStatusCode == 200 $sStatusText = "Alive - OK" Case $iStatusCode >= 300 And $iStatusCode < 400 ; With automatic tracking, 3xx codes will rarely appear here, ; unless 10 redirects are exceeded. $sStatusText = "Redirected (Needs Review)" Case $iStatusCode == 404 $sStatusText = "Not Found" Case $iStatusCode >= 400 And $iStatusCode < 500 $sStatusText = "Client Error" Case $iStatusCode >= 500 And $iStatusCode < 600 $sStatusText = "Server Error" Case Else If StringStripWS($sStatusText, 3) == "" Then $sStatusText = "Unknown Status (" & $iStatusCode & ")" EndSelect Local $aResults = [$iStatusCode, $sStatusText] Return $aResults EndFunc ;==>__CheckLinkStatus ;--------------------------------------------------------------------------------------- Func __ObjAutoItErrorEvent() If IsObj($g_ObjErr) Then ; This filters out false positives with an empty description. If $g_ObjErr.Number <> 0 And StringStripWS($g_ObjErr.Description, 3) <> "" Then ; Store the error details in the global array (instead of showing MsgBox) ReDim $g_aLastComError[4] $g_aLastComError[0] = $g_ObjErr.description $g_aLastComError[1] = Hex($g_ObjErr.Number, 8) ; $g_ObjErr.Number $g_aLastComError[2] = $g_ObjErr.Source $g_aLastComError[3] = $g_ObjErr.ScriptLine ; ConsoleWrite('@@(' & $g_aLastComError[3] & ') :: COM Error Logged: Desc.: "' & StringReplace($g_aLastComError[0], @CRLF, " ") & '"' & @CRLF) EndIf ; Clear the properties of ObjEvent $g_ObjErr.Description = "" $g_ObjErr.Number = 0 EndIf EndFunc ;==>__ObjAutoItErrorEvent ;--------------------------------------------------------------------------------------- Func _LinksInspectorGUI($sFilePath = "") ; Function to create the main graphical user interface _WinAPI_SetCurrentProcessExplicitAppUserModelID(StringTrimRight(@ScriptName, 4)) Local $hGUI = GUICreate("Links Inspector", 700, 500) GUISetIcon(@SystemDir & "\shell32.dll", -136) GUICtrlCreateLabel("File Path:", 10, 15, 50, 20) ; *** Local $idInputFile = GUICtrlCreateInput($sFilePath, 60, 10, 530, 24) Local $idBtnBrowse = GUICtrlCreateButton("Browse", 600, 10, 90, 24) GUICtrlCreateLabel("Filter:", 60, 45, 30, 20) ; *** GUICtrlSetTip(-1, " '*' Show all results" & @CRLF & " '!' Show all except 200" & @CRLF & " '400, 404' Show only the specific status codes.") Local $idInputFilter = GUICtrlCreateInput("*", 90, 40, 200, 24) ; *** GUICtrlSetFont(-1, 12) Local $idCheckboxAttrib = GUICtrlCreateCheckbox("Attribute Search Only", 310, 43, 150, 20) ; *** Local $idBtnInspect = GUICtrlCreateButton("Start Inspection", 600, 40, 90, 24) Local $idBtnSaveReport = GUICtrlCreateButton("Save Report", 500, 40, 90, 24) GUICtrlSetState(-1, $GUI_DISABLE) Local $idIconInfo = GUICtrlCreateIcon("wmploc.dll", -60, 20, 44, 16, 16) $g_hListView = _GUICtrlListView_Create($hGUI, "", 10, 80, 680, 380) Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER, $LVS_EX_INFOTIP) _GUICtrlListView_SetExtendedListViewStyle($g_hListView, $iExListViewStyle) Local $idProgress = GUICtrlCreateProgress(10, 470, 680, 20) GUISetState(@SW_SHOW) _GUICtrlListView_RegisterSortCallBack($g_hListView, 0) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ; Add columns to $g_hListView "Line(s)|Code|Status|URL" _GUICtrlListView_AddColumn($g_hListView, "Line(s)", 50) _GUICtrlListView_AddColumn($g_hListView, "Code", 40) _GUICtrlListView_AddColumn($g_hListView, "Status", 80) _GUICtrlListView_AddColumn($g_hListView, "URL", 500) Local $mCODES[] Local $aHTTP_STATUS = _HTTP_STATUS($mCODES) Local $nMsg, $aResults, $iLastStatusID, $sTipTitle, $sTipText, $iLastIndex = -1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $idBtnBrowse $sFilePath = FileOpenDialog("Select File to Inspect", @ScriptDir, "All Files (*.*)", 1, GUICtrlRead($idInputFile)) If @error Then ContinueLoop GUICtrlSetData($idInputFile, $sFilePath) _GUICtrlListView_DeleteAllItems($g_hListView) ; Clear Listview GUICtrlSetState($idBtnSaveReport, $GUI_DISABLE) ; disable the Save_Report button $aResults = 0 Case $idBtnInspect ; Reset UI elements _GUICtrlListView_DeleteAllItems($g_hListView) ; Clear Listview GUICtrlSetData($idProgress, 0) GUICtrlSetState($idBtnSaveReport, $GUI_DISABLE) ; disable the Save_Report button $aResults = 0 ; Get user input $sFilePath = GUICtrlRead($idInputFile) Local $sFilter = GUICtrlRead($idInputFilter) Local $bAttribOnly = GUICtrlRead($idCheckboxAttrib) = $GUI_CHECKED ; Input validation If Not FileExists($sFilePath) Then MsgBox(48, "Error", "File not found: " & $sFilePath) ContinueLoop EndIf GUICtrlSetState($idBtnInspect, $GUI_DISABLE) ; Temporarily disable the Inspect button during inspection $aResults = _LinksInspector($sFilePath, $sFilter, $bAttribOnly, $idProgress) ; Handle results If @error = 1 Then ; Error 1 is already handled inside _LinksInspector (FileReadToArray error) ElseIf @error = 2 Then MsgBox(64, "Info", "No links found matching the criteria in the file.") Else ; Add results to Listview _GUICtrlListView_SetItemCount($g_hListView, UBound($aResults)) _GUICtrlListView_AddArray($g_hListView, $aResults) ; MsgBox(64, "Success", "Inspection complete. Found " & $iCount & " results.") EndIf Sleep(500) ; give some time to show the ProgressBar GUICtrlSetData($idProgress, 0) ; Update progress bar to 0% GUICtrlSetState($idBtnInspect, $GUI_ENABLE) ; enable Inspect button If UBound($aResults) > 0 Then GUICtrlSetState($idBtnSaveReport, $GUI_ENABLE) ; enable Save_Report button Case $idBtnSaveReport Local $sReportPath = FileSaveDialog("Save LinksInspector Report", @ScriptDir, _ "Text Files (*.txt)", 1, "LinksInspector Report.txt") If Not @error And $sReportPath <> "" Then If FileExists($sReportPath) Then If MsgBox($MB_YESNO + $MB_ICONWARNING, "File already exists", $sReportPath & @CRLF & _ "Do you want to replace it?") = $IDNO Then ContinueLoop FileDelete($sReportPath) EndIf Local $sReportData = _ArrayToString($aResults) $sReportData = "Line(s)|Code|Status|URL" & @CRLF & $sReportData FileWrite($sReportPath, $sReportData) EndIf EndSwitch ; Update the ToolTip of the info icon If $iLastIndex <> $g_iListIndex Then $iLastIndex = $g_iListIndex ; ConsoleWrite("$iLastIndex=" & $iLastIndex & @CRLF) $iLastStatusID = Int(_GUICtrlListView_GetItemText($g_hListView, $iLastIndex, 1)) If $iLastStatusID = 0 Then $sTipTitle = "(0) COM Error" $sTipText = _GUICtrlListView_GetItemText($g_hListView, $iLastIndex, 2) Else $sTipTitle = "" $sTipText = "" If MapExists($mCODES, $iLastStatusID) Then $sTipTitle = "(" & $aHTTP_STATUS[$mCODES[$iLastStatusID]][0] & ") " & $aHTTP_STATUS[$mCODES[$iLastStatusID]][1] $sTipText = StringFormat($aHTTP_STATUS[$mCODES[$iLastStatusID]][2]) EndIf EndIf GUICtrlSetTip($idIconInfo, $sTipText, $sTipTitle, $TIP_INFOICON) EndIf WEnd EndFunc ;==>_LinksInspectorGUI ;--------------------------------------------------------------------------------------- Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR, $tInfo, $index, $subitem, $sURL $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $g_hListView Switch $iCode Case $LVN_COLUMNCLICK $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) ;$index = DllStructGetData($tInfo, "Index") $subitem = DllStructGetData($tInfo, "SubItem") ; Kick off the sort callback _GUICtrlListView_SortItems($hWndFrom, $subitem) ; No return value Case $NM_DBLCLK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $index = DllStructGetData($tInfo, "Index") $subitem = DllStructGetData($tInfo, "SubItem") $g_iListIndex = $index $sURL = _GUICtrlListView_GetItemText($g_hListView, $index, 3) If $subitem = 3 Then ShellExecute($sURL) ; No return value Case $NM_CLICK $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) $index = DllStructGetData($tInfo, "Index") ;$subitem = DllStructGetData($tInfo, "SubItem") $g_iListIndex = $index ; ConsoleWrite("$g_iListIndex=" & $g_iListIndex & @CRLF) ; No return value EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY ;--------------------------------------------------------------------------------------- Func _HTTP_STATUS(ByRef $mMap) Local $aHTTP_STATUS_CODES[63][3] = [ _ [100, "Continue", "This interim response indicates that the client \nshould continue the request or \nignore the response if the request is already finished."], _ [101, "Switching Protocols", "This code is sent in response to \nan Upgrade request header from the \nclient and indicates the protocol the server is switching to."], _ [102, "Processing Deprecated", "This code was used in WebDAV contexts to indicate \nthat a request has been received by the server, \nbut no status was available at the time of the response."], _ [103, "Early Hints", "This status code is primarily intended to be used with the Link header, \nletting the user agent start preloading resources while the server \nprepares a response or preconnect to an origin from which the page will need resources."], _ [200, "OK", "The request succeeded. The result and meaning of 'success' depends on the HTTP method:\nGET: The resource has been fetched and transmitted in the message body.\nHEAD: Representation headers are included in the response without any message body.\nPUT or POST: The resource describing the result of the action is transmitted in the message body. \nTRACE: The message body contains the request as received by the server."], _ [201, "Created", "The request succeeded, \nand a new resource was created as a result. \nThis is typically the response sent after POST requests, \nor some PUT requests."], _ [202, "Accepted", "The request has been received but not yet acted upon. \nIt is noncommittal, since there is no way in HTTP to later send an \nasynchronous response indicating the outcome of the request. \nIt is intended for cases where another process \nor server handles the request, or for batch processing."], _ [203, "Non-Authoritative Information", "This response code means the returned metadata \nis not exactly the same as is available from the origin server, \nbut is collected from a local or a third-party copy. \nThis is mostly used for mirrors or backups of another resource. \nExcept for that specific case, the 200 OK response is preferred to this status."], _ [204, "No Content", "There is no content to send for this request, but the headers are useful. \nThe user agent may update its cached headers for this resource with the new ones."], _ [205, "Reset Content", "Tells the user agent to reset the document which sent this request."], _ [206, "Partial Content", "This response code is used in response to a range request \nwhen the client has requested a part or parts of a resource."], _ [207, "Multi-Status (WebDAV)", "Conveys information about multiple resources, \nfor situations where multiple status codes might be appropriate."], _ [208, "Already Reported (WebDAV)", "Used inside a <dav:propstat> response element to avoid \nrepeatedly enumerating the internal members of multiple bindings to the same collection."], _ [226, "IM Used (HTTP Delta encoding)", "The server has fulfilled a GET request for the resource, \nand the response is a representation of the result of one or more \ninstance-manipulations applied to the current instance."], _ [300, "Multiple Choices", "In agent-driven content negotiation, \nthe request has more than one possible response and \nthe user agent or user should choose one of them. \nThere is no standardized way for clients to automatically \nchoose one of the responses, so this is rarely used."], _ [301, "Moved Permanently", "The URL of the requested resource has been changed permanently. \nThe new URL is given in the response."], _ [302, "Found", "This response code means that the URI of \nrequested resource has been changed temporarily. \nFurther changes in the URI might be made in the future, \nso the same URI should be used by the client in future requests."], _ [303, "See Other", "The server sent this response to direct the client \nto get the requested resource at another URI with a GET request."], _ [304, "Not Modified", "This is used for caching purposes. \nIt tells the client that the response has not been modified, \nso the client can continue to use the same cached version of the response."], _ [305, "Use Proxy Deprecated", "Defined in a previous version of the HTTP specification \nto indicate that a requested response must be accessed by a proxy. \nIt has been deprecated due to security concerns regarding in-band configuration of a proxy."], _ [306, "unused", "This response code is no longer used; \nbut is reserved. It was used in a previous version of the HTTP/1.1 specification."], _ [307, "Temporary Redirect", "The server sends this response to direct the client to get the requested resource \nat another URI with the same method that was used in the prior request. \nThis has the same semantics as the 302 Found response code, \nwith the exception that the user agent must not change the HTTP method used: \nif a POST was used in the first request, a POST must be used in the redirected request."], _ [308, "Permanent Redirect", "This means that the resource is now permanently located at another URI, \nspecified by the Location response header. \nThis has the same semantics as the 301 Moved Permanently HTTP response code, \nwith the exception that the user agent must not change the HTTP method used: \nif a POST was used in the first request, \na POST must be used in the second request."], _ [400, "Bad Request", "The server cannot or will not process the request due \nto something that is perceived to be a client error \n(e.g., malformed request syntax, invalid request message framing, \nor deceptive request routing)."], _ [401, "Unauthorized", "Although the HTTP standard specifies 'unauthorized', \nsemantically this response means 'unauthenticated'. \nThat is, the client must authenticate itself to get the requested response."], _ [402, "Payment Required", "The initial purpose of this code was for digital payment systems, \nhowever this status code is rarely used and no standard convention exists."], _ [403, "Forbidden", "The client does not have access rights to the content; \nthat is, it is unauthorized, so the server is refusing \nto give the requested resource. \nUnlike 401 Unauthorized, \nthe client's identity is known to the server."], _ [404, "Not Found", "The server cannot find the requested resource. \nIn the browser, this means the URL is not recognized. \nIn an API, this can also mean that the endpoint is valid but the resource itself does not exist. \nServers may also send this response instead of 403 Forbidden \nto hide the existence of a resource from an unauthorized client. \nThis response code is probably the most well known \ndue to its frequent occurrence on the web."], _ [405, "Method Not Allowed", "The request method is known by the server \nbut is not supported by the target resource. \nFor example, an API may not allow DELETE on a resource, \nor the TRACE method entirely."], _ [406, "Not Acceptable", "This response is sent when the web server, \nafter performing server-driven content negotiation, \ndoesn't find any content that conforms to the criteria \ngiven by the user agent."], _ [407, "Proxy Authentication Required", "This is similar to 401 Unauthorized but \nauthentication is needed to be done by a proxy."], _ [408, "Request Timeout", "This response is sent on an idle connection by some servers, \neven without any previous request by the client. \nIt means that the server would like to shut down this unused connection. \nThis response is used much more since some browsers use HTTP pre-connection mechanisms to speed up browsing. \nSome servers may shut down a connection without sending this message."], _ [409, "Conflict", "This response is sent when a request conflicts with the current state of the server. \nIn WebDAV remote web authoring, \n409 responses are errors sent to the client so that a user might be \nable to resolve a conflict and resubmit the request."], _ [410, "Gone", "This response is sent when the requested content has been \npermanently deleted from server, \nwith no forwarding address. \nClients are expected to remove their caches and links to the resource. \nThe HTTP specification intends this status code to be used for 'limited-time, \npromotional services'. \nAPIs should not feel compelled to indicate resources \nthat have been deleted with this status code."], _ [411, "Length Required", "Server rejected the request because \nthe Content-Length header field is not defined and \nthe server requires it."], _ [412, "Precondition Failed", "In conditional requests, \nthe client has indicated preconditions in its headers \nwhich the server does not meet."], _ [413, "Content Too Large", "The request body is larger than limits defined by server. \nThe server might close the connection or \nreturn an Retry-After header field."], _ [414, "URI Too Long", "The URI requested by the client is \nlonger than the server is willing to interpret."], _ [415, "Unsupported Media Type", "The media format of the requested data is not supported by the server, \nso the server is rejecting the request."], _ [416, "Range Not Satisfiable", "The ranges specified by the Range header field in the request cannot be fulfilled. \nIt's possible that the range is outside the size of the target resource's data."], _ [417, "Expectation Failed", "This response code means the expectation indicated by \nthe Expect request header field cannot be met by the server."], _ [418, "I'm a teapot", "The server refuses the attempt to brew coffee with a teapot."], _ [421, "Misdirected Request", "The request was directed at a server that is not able to produce a response. \nThis can be sent by a server that is not configured \nto produce responses for the combination of scheme and \nauthority that are included in the request URI."], _ [422, "Unprocessable Content (WebDAV)", "The request was well-formed but was unable to be followed due to semantic errors."], _ [423, "Locked (WebDAV)", "The resource that is being accessed is locked."], _ [424, "Failed Dependency (WebDAV)", "The request failed due to failure of a previous request."], _ [425, "Too Early Experimental", "Indicates that the server is unwilling to \nrisk processing a request that might be replayed."], _ [426, "Upgrade Required", "The server refuses to perform the request using the current protocol but \nmight be willing to do so after the client upgrades to a different protocol. \nThe server sends an Upgrade header in a 426 response to indicate the required protocol(s)."], _ [428, "Precondition Required", "The origin server requires the request to be conditional. \nThis response is intended to prevent the 'lost update' problem, \nwhere a client GETs a resource's state, \nmodifies it and PUTs it back to the server, \nwhen meanwhile a third party has modified the state on the server, \nleading to a conflict."], _ [429, "Too Many Requests", "The user has sent too many requests in a given amount of time (rate limiting)."], _ [431, "Request Header Fields Too Large", "The server is unwilling to process the request because its header fields are too large. \nThe request may be resubmitted after reducing the size of the request header fields."], _ [451, "Unavailable For Legal Reasons", "The user agent requested a resource that cannot legally be provided, \nsuch as a web page censored by a government."], _ [500, "Internal Server Error", "The server has encountered a situation it does not know how to handle. \nThis error is generic, indicating that the server cannot find \na more appropriate 5XX status code to respond with."], _ [501, "Not Implemented", "The request method is not supported by the server and cannot be handled. \nThe only methods that servers are required to support \n(and therefore that must not return this code) are GET and HEAD."], _ [502, "Bad Gateway", "This error response means that the server, \nwhile working as a gateway to get a response needed to handle the request, \ngot an invalid response."], _ [503, "Service Unavailable", "The server is not ready to handle the request. \nCommon causes are a server that is down for maintenance or that is overloaded. \nNote that together with this response, \na user-friendly page explaining the problem should be sent. \nThis response should be used for temporary conditions and the Retry-After HTTP header should, \nif possible, contain the estimated time before the recovery of the service. \nThe webmaster must also take care about the caching-related headers that are sent along with this response, \nas these temporary condition responses should usually not be cached."], _ [504, "Gateway Timeout", "This error response is given when the server is \nacting as a gateway and cannot get a response in time."], _ [505, "HTTP Version Not Supported", "The HTTP version used in the request is not supported by the server."], _ [506, "Variant Also Negotiates", "The server has an internal configuration error: during content negotiation, \nthe chosen variant is configured to engage in content negotiation itself, \nwhich results in circular references when creating responses."], _ [507, "Insufficient Storage (WebDAV)", "The method could not be performed on the resource because the server is unable \nto store the representation needed to successfully complete the request."], _ [508, "Loop Detected (WebDAV)", "The server detected an infinite loop while processing the request."], _ [510, "Not Extended", "The client request declares an HTTP Extension (RFC 2774) that should be used to process the request, \nbut the extension is not supported."], _ [511, "Network Authentication Required", "Indicates that the client needs to authenticate to gain network access."] _ ] Local $m[] Local $STATUS_CODES For $i = 0 To UBound($aHTTP_STATUS_CODES) - 1 $STATUS_CODES = Int($aHTTP_STATUS_CODES[$i][0]) $m[$STATUS_CODES] = $i Next $mMap = $m Return $aHTTP_STATUS_CODES EndFunc ;==>_HTTP_STATUS ;--------------------------------------------------------------------------------------- ; ##### Example Usage demonstrating filters ##### ;--------------------------------------------------------------------------------------- _Example() Func _Example() Local $sTestFilePath = @ScriptDir & "\links_test.txt" ; With GUI _LinksInspectorGUI($sTestFilePath) ; or just as function Local $aLinks ;~ $aLinks = _LinksInspector($sTestFilePath, "*") ; Show ALL links ;~ $aLinks = _LinksInspector($sTestFilePath, "*", True) ; Show ALL, but ONLY for URLs within HTML/XML attributes (e.g., href="..."). ;~ $aLinks = _LinksInspector($sTestFilePath, "!") ; Show ALL results except 200 ;~ $aLinks = _LinksInspector($sTestFilePath, "400, 404") ; Show ONLY the 400 and 404 ;~ $aLinks = _LinksInspector($sTestFilePath, $LINKS_BROKEN) ; Show $LINKS_BROKEN = "0, 404, 500, 501, 502, 503, 504" ;~ $aLinks = _LinksInspector($sTestFilePath, $LINKS_NEEDS_REVIEW) ; Show $LINKS_NEEDS_REVIEW = "301, 302, 307, 400, 401, 403" _ArrayDisplay($aLinks, "$aLinks", "", 0, Default, "Line(s)|Code|Status|URL") EndFunc ;==>_Example Please, every comment is appreciated! leave your comments and experiences here! Thank you very much3 points -
Hi @donnyh13, One of the changes in in v1.0.14 is the minimum supported vscode engine, from 1.52.0 to 1.96.0. relevant commit here: https://github.com/loganch/AutoIt-VSCode/commit/ede5ceab464f74149f5f46a2741f6536ae7664d4 I'm pretty sure this is what is preventing you from installing, since version 1.70.3 is the last vscode version that supports windows7. source: https://code.visualstudio.com/updates/v1_70 I would argue that a change in supported vscode engine version should require a release version to bump the major version number, this was released as part of a patch version. Self promotion 😛: my extension should still work, since my vscode engine version is on 1.61.0 as it was since the beginning3 points
-
You're perfectly right. Relevant neurons fixed!3 points
-
AutoIt Extension for Visual Studio Code
Musashi and 2 others reacted to argumentum for a topic
I could install Win7 in a VM but am clueless to all VSCode. I don't use it. Would not know what works and what don't. If you don't have a Win7 ISO, go to torrent-land and get an up to date one. I'll retire the day I die. Maybe even after ! I loved WinXP but time moves forward. Win11 ain't bad ( after you tweak the heck out of it ). I install Windows on any language is not because am a polyglot, but because everything is always pretty much the same in the same place, same icons. Remember: Your feet don't stay on the ground because of gravity. The whole planet stick to your feet because of your gravitas 🙇3 points -
Hour AM/PM ( yes, one more of these )
ioa747 and 2 others reacted to argumentum for a topic
@water... I'll get me some cafe, take a walk, ..something. I edited my post above. I took everything out of context. My brain is hooked on a work project and I can not do more than one thing at the time Ok. That addition to the Date.au3 UDF, was right there for the taking. All I did was to add the strings for options 6 and 7 ... Case 6 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm tt" EndIf Case 7 If $asTimePart[0] > 1 Then $sTempTime = "hh:mm:ss tt" EndIf ... Now including the AM/PM to it, ...I'll need to be in a happy place ( no pressure ) to get my brain in gear for that. Now any and every one, is welcomed to present a _DateTimeFormat() that includes that. I'll ( well, the MVPs ) will look at it and say "yey/ney". Remember ( not just you ), that all these UDFs were scripts users of the forum coded and expanded with the participation of everyone. Don't be shy. Your nationforum needs you !. ( nowalways recruiting coders )3 points -
So that means I am really getting too old for all of this. Sorry @rcmaehl for not staying up-to-date on the "street lingo".3 points
-
User Interface Builder Overview Use this tool to visually design Windows applications with a focus on Metro windows, standard windows, and Tool windows. This is for users who want a faster and simpler development tool. Drag-and-drop GUI creation, code generation, and easy control alignment tools. No more clicking through property sheets to set variable names, sizes, and the control’s text. Please replace "MetroUDF-Required\SSCtrlHover.au3" within the metro UDF files to see more meaningful messages in the console. The following line was inserted into the function. This prevents crashing on syntax and logical errors while Metro buttons are in use. Func _cHvr_Register($idCtrl, $fnHovOff = '', $fnHoverOn = '', $fnClick = '', $fnDblClk = '', $HoverData = 0,$ClickData = 0,$fnRightClick = '') If $BLOCK_HOVER_REGISTRATION Then Return Unfortunately, the following will have to added to your scripts if you already use Metro UDF and you replace "SSCtrlHover.au3". Global $BLOCK_HOVER_REGISTRATION = False #include "MetroGUI_UDF.au3" #include "MetroGUI_UDF_xpk.au3" #include "_GUIDisable.au3" ; For dim effects when msgbox is displayed Features Metro Controls for all window types WYSIWYG real-time preview Generates AutoIt GUI and message loop code Multiple control selection and manipulation Make additional selections with the CTRL key Accelerated control movements with the SHIFT key Change controls position with mouse or arrow keys Double click a control to precisely set its size and text Save/load GUI layouts and Control layouts to files Custom styles/themes and Controls using Metro Snap-to-guide, and toolbar alignment aids Drag down guides from the top and left sides of the Designer window Copy-n-paste between different window types Technical Details .Gui/.Ctrls file is a simple delimited text file Copy-n-paste is a similar file without the window specifications The application is meant to be portable, so it is one file The only Custom UDFs in use is Metro 5.1, and my Metro Expansion pack The script uses Label controls for everything. No GDI was used. Every control handle is saved in an array Maps are used in Metro and in future UDFs containing new controls You need Metro 5.1 UDF Limitations and known issues Resizing the Metro window with the mouse is flaky Changing control and window styles is not implemented Window size cannot be changed precisely Undo functionality might cause problems with code generation No Redo implemented Thank you BB19 and everyone that contributed to Metro UDF. MetroGUI_UDF_xpk.au3 SSCtrlHover.au3 UserInterfaceBuilder.au32 points
-
Bug: Menu and Controls stop working after SW_SHOW from another process
ioa747 and one other reacted to argumentum for a topic
#NoTrayIcon #include <AutoItConstants.au3> #include <TrayConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> Global $hGUI Opt("TrayMenuMode", 3) Opt("TrayAutoPause", 0) Opt("TrayOnEventMode", 1) TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, 'idGUI') TraySetClick(16) Global $idGUI = TrayCreateItem("Show GUI") TrayItemSetOnEvent($idGUI, "idGUI") TrayCreateItem("") Global $idExit = TrayCreateItem('Exit') TrayItemSetOnEvent($idExit, "_Exit") TraySetIcon(@AutoItExe, 1) TraySetToolTip("Show GUI") Example() Func Example() Local $sDefaultstatus = "Ready" $hGUI = GUICreate("My GUI menu", 300, 200) Local $idMnu_File = GUICtrlCreateMenu("&File") Local $idMnu_Help = GUICtrlCreateMenu("Help") Local $idMni_Info = GUICtrlCreateMenuItem("About", $idMnu_Help) Local $idMnu_View = GUICtrlCreateMenu("View", -1, 1) Local $idBtn_Hide = GUICtrlCreateButton("Hide GUI", 50, 130, 70, 20) GUICtrlSetState(-1, $GUI_FOCUS) Local $idBtn_Cancel = GUICtrlCreateButton("Exit", 180, 130, 70, 20) Local $idLbl_Status = GUICtrlCreateLabel($sDefaultstatus, 0, 165, 300, 16, BitOR($SS_SIMPLE, $SS_SUNKEN)) GUISetState(@SW_SHOW) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $idBtn_Hide ;~ GUISetState(@SW_HIDE, $hGUI) WinSetState($hGUI, "", @SW_HIDE) Case $idBtn_Cancel, $GUI_EVENT_CLOSE ExitLoop Case $idMni_Info MsgBox($MB_SYSTEMMODAL, "Info", "Only a test...") EndSwitch WEnd GUIDelete() EndFunc ;==>Example Func _Exit() Exit EndFunc Func idGUI() If Not BitAND(WinGetState($hGUI), $WIN_STATE_VISIBLE) Then WinSetState($hGUI, "", @SW_SHOW) ;~ ; get GUI window state ;~ Local $iState = WinGetState($hGUI) ;~ If $iState <> $WIN_STATE_VISIBLE Then GUISetState(@SW_SHOW, $hGUI) EndFunc yes, is an old bug, and the way it is. Fortunately you can get around it.2 points -
I tried to apply dark mode to the SampleControls.au3 example. What I did so far: ; Coded by UEZ build 2025-10-17 beta ;not DPI aware! #include <APIConstants.au3> #include <AVIConstants.au3> #include <GUIConstantsEx.au3> #include <GuiDateTimePicker.au3> #include <GuiMenu.au3> #include <GuiMonthCal.au3> #include <GuiScrollBars.au3> #include <GuiTab.au3> #include <TreeViewConstants.au3> #include <ListViewConstants.au3> #include <WinAPIConstants.au3> #include <WinAPIGdi.au3> #include <WinAPIRes.au3> #include <WinAPIShellEx.au3> #include <WinAPISys.au3> #include <WinAPISysWin.au3> #include <WinAPITheme.au3> #include <WindowsConstants.au3> Enum $IHCM_USE_CACHED_VALUE, $IHCM_REFRESH Enum $APPMODE_DEFAULT = 0, $APPMODE_ALLOWDARK, $APPMODE_FORCEDARK, $APPMODE_FORCELIGHT, $APPMODE_MAX Const $PRF_CLIENT = 0x04 ; Dark Mode Colors (RGB) Global Const $COLOR_BG_DARK = 0x202020 Global Const $COLOR_TEXT_LIGHT = 0xFFFFFF Global Const $COLOR_CONTROL_BG = 0x2B2B2B Global Const $COLOR_EDIT_BG = 0x1E1E1E Global Const $COLOR_BUTTON_BG = 0x333333 Global Const $COLOR_BORDER = 0x3F3F3F ; Global variables for subclassing (MUST be declared before _Example()!) Global $g_hGUI = 0, $g_hTab, $g_ListView Global $g_aControls[50][3] = [[0, 0, 0]] ; [ControlID, hWnd, OldWndProc] Global $g_iControlCount = 0 Global $g_pSubclassProc = 0 ; Global brushes for _WM_CTLCOLOR (avoids memory leaks) Global $g_hBrushEdit = 0 Global $g_hBrushButton = 0 Global $g_hBrushBg = 0 Global $g_hBrushGreen Global $g_hLabelGreen = 0, $g_idLabelGreen Global $g_idLabelPic, $g_hLabelPic Global $g_hMenu = 0 Global $g_idDate = 0, $g_hDate = 0 ; Global variable for tab subclassing Global $g_hTab_CB, $g_pTab_CB, $g_hProc ; Structure for NM_CUSTOMDRAW notification Global Const $tagNMCUSTOMDRAW = _ $tagNMHDR & ";" & _ ; Contains NM_CUSTOMDRAW / NMHDR header among other things "dword dwDrawStage;" & _ ; Current drawing stage (CDDS_*) "handle hdc;" & _ ; Device Context Handle "long left;long top;long right;long bottom;" & _ ; Drawing rectangle "dword_ptr dwItemSpec;" & _ ; Item index or other info (depending on the control) "uint uItemState;" & _ ; State Flags (CDIS_SELECTED, CDIS_FOCUS etc.) "lparam lItemlParam" ; lParam set by the item (e.g., via LVITEM.lParam) Global $g_hMenu = 0, $hMenuFont Global $g_aMenuText = [] ; dynamic array for top-level menu texts Global $arMenuItems[1][8] $arMenuItems[0][0] = 0 Global $arSideItems[1][10] $arSideItems[0][0] = 0 Const $ODT_MENU = 1 Const $ODS_SELECTED = 0x0001 Const $ODS_DISABLED = 0x0004 _Example() Func _Example() ; Create global brushes $g_hBrushEdit = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_EDIT_BG)) $g_hBrushButton = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BUTTON_BG)) $g_hBrushBg = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) #Region GUI $g_hGUI = GUICreate("Sample GUI with Dark Mode", 400, 400) GUISetIcon(@SystemDir & "\mspaint.exe", 0) GUISetBkColor($COLOR_BG_DARK, $g_hGUI) ; Register GUI-level WM_CTLCOLOR messages GUIRegisterMsg($WM_CTLCOLOREDIT, "_WM_CTLCOLOR") GUIRegisterMsg($WM_CTLCOLORLISTBOX, "_WM_CTLCOLOR") GUIRegisterMsg($WM_CTLCOLORBTN, "_WM_CTLCOLOR") GUIRegisterMsg($WM_CTLCOLORSTATIC, "_WM_CTLCOLOR") GUIRegisterMsg($WM_INITMENUPOPUP, "_OnInitMenuPopup") GUIRegisterMsg($WM_MEASUREITEM, "WM_MEASUREITEM_Handler") GUIRegisterMsg($WM_DRAWITEM, "WM_DRAWITEM_Handler") GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUIRegisterMsg($WM_ACTIVATE, "_WM_ACTIVATE_OverpaintLine") GUIRegisterMsg($WM_WINDOWPOSCHANGED, "_WM_WINDOWPOSCHANGED_OverpaintLine") #EndRegion GUI #Region MENU Global $g_aMenuText[4] $g_aMenuText[0] = "Menu &One" $g_aMenuText[1] = "Menu &Two" $g_aMenuText[2] = "Menu Th&ree" $g_aMenuText[3] = "Menu &Four" Local $idMenu1 = GUICtrlCreateMenu($g_aMenuText[0]) Local $idMenu2 = GUICtrlCreateMenu($g_aMenuText[1]) GUICtrlCreateMenu($g_aMenuText[2]) GUICtrlCreateMenu($g_aMenuText[3]) GUICtrlCreateMenuItem('SubMenu One &A', $idMenu1) GUICtrlCreateMenuItem('SubMenu One &B', $idMenu1) ; Owner-draw Top-Level Menu einrichten _MakeMenuOwnerDraw($g_hGUI) #EndRegion MENU #Region CONTEXT MENU Local $idContextMenu = GUICtrlCreateContextMenu() GUICtrlCreateMenuItem("Context Menu", $idContextMenu) GUICtrlCreateMenuItem("", $idContextMenu) GUICtrlCreateMenuItem("&Properties", $idContextMenu) #EndRegion CONTEXT MENU #Region PIC Local $idPic = GUICtrlCreatePic("", 0, 0, 169, 68) GUICtrlSetImage($idPic, "C:\Program Files (x86)\AutoIt3\Examples\GUI\logo4.gif") GUICtrlSetTip(-1, '#Region PIC') $g_idLabelPic = GUICtrlCreateLabel("Sample Pic", 75, 1, 53, 15) $g_hLabelPic = GUICtrlGetHandle($g_idLabelPic) #EndRegion PIC #Region AVI Local $idAvi = GUICtrlCreateAvi("C:\Program Files (x86)\AutoIt3\Examples\GUI\SampleAVI.avi", 0, 180, 10, 32, 32, $ACS_AUTOPLAY) GUICtrlSetTip(-1, '#Region AVI') GUICtrlCreateLabel("Sample avi", 175, 50) #EndRegion AVI #Region TAB Local $idTab = GUICtrlCreateTab(240, 0, 150, 70), $g_hTab = GUICtrlGetHandle($idTab) _AddControlForSubclass($idTab) GUICtrlCreateTabItem("One") GUICtrlSetTip(-1, '#Region TAB1') GUICtrlCreateLabel("Sample Tab", 250, 40) GUICtrlCreateTabItem("Two") GUICtrlSetTip(-1, '#Region TAB2') GUICtrlCreateTabItem("Three") GUICtrlSetTip(-1, '#Region TAB3') GUICtrlCreateTabItem("") $g_hTab = GUICtrlGetHandle($idTab) #EndRegion TAB #Region COMBO Local $idCombo = GUICtrlCreateCombo("Sample Combo", 250, 80, 120, 100) GUICtrlSetData($idCombo, "Item 2|Item 3", "Sample Combo") _AddControlForSubclass($idCombo) GUICtrlSetTip(-1, '#Region COMBO') #EndRegion COMBO #Region PROGRESS Local $idProgress = GUICtrlCreateProgress(60, 80, 150, 20) _AddControlForSubclass($idProgress) GUICtrlSetTip(-1, '#Region PROGRESS') GUICtrlSetData(-1, 60) GUICtrlCreateLabel("Progress:", 5, 82) #EndRegion PROGRESS #Region EDIT Local $idEdit = GUICtrlCreateEdit(@CRLF & " Sample Edit Control", 10, 110, 150, 70) _AddControlForSubclass($idEdit) GUICtrlSetTip(-1, '#Region EDIT') #EndRegion EDIT #Region LIST Local $idList = GUICtrlCreateList("", 5, 190, 100, 90) _AddControlForSubclass($idList) GUICtrlSetTip(-1, '#Region LIST') GUICtrlSetData(-1, "A.Sample|B.List|C.Control|D.Here", "B.List") #EndRegion LIST #Region ICON GUICtrlCreateIcon("explorer.exe", 0, 175, 120) GUICtrlSetTip(-1, '#Region ICON') GUICtrlCreateLabel("Icon", 180, 160, 50, 20) #EndRegion ICON #Region LIST VIEW Local $idListView = GUICtrlCreateListView("Sample|ListView|", 110, 190, 110, 80, $LVS_REPORT) _AddControlForSubclass($idListView) GUICtrlSetBkColor($idListView, $COLOR_EDIT_BG) GUICtrlSetColor($idListView, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region LIST VIEW') GUICtrlCreateListViewItem("A|One", $idListView) GUICtrlCreateListViewItem("B|Two", $idListView) GUICtrlCreateListViewItem("C|Three", $idListView) $g_ListView = GUICtrlGetHandle($idListView) #EndRegion LIST VIEW #Region GROUP WITH RADIO BUTTONS Local $idGroup = GUICtrlCreateGroup("Sample Group", 230, 120) GUICtrlSetColor($idGroup, $COLOR_TEXT_LIGHT) Local $idRadio1 = GUICtrlCreateRadio("Radio One", 250, 140, 80) GUICtrlSetTip($idRadio1, '#Region RADIO1') GUICtrlSetState($idRadio1, $GUI_CHECKED) Local $idRadio2 = GUICtrlCreateRadio("Radio Two", 250, 165, 80) GUICtrlSetTip($idRadio2, '#Region RADIO2') GUICtrlCreateGroup("", -99, -99, 1, 1) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idGroup), "wstr", 0, "wstr", 0) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idRadio1), "wstr", 0, "wstr", 0) DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idRadio2), "wstr", 0, "wstr", 0) #EndRegion GROUP WITH RADIO BUTTONS #Region UPDOWN GUICtrlCreateLabel("UpDown", 350, 115) GUICtrlSetColor(-1, $COLOR_TEXT_LIGHT) Local $idInput = GUICtrlCreateInput("42", 350, 130, 40, 20) _AddControlForSubclass($idInput) Local $idUpDown = GUICtrlCreateUpdown(-1) _AddControlForSubclass($idUpDown) #EndRegion UPDOWN #Region LABEL $g_idLabelGreen = GUICtrlCreateLabel("Green" & @CRLF & "Label", 350, 165, 40, 40) $g_hLabelGreen = GUICtrlGetHandle($g_idLabelGreen) GUICtrlSetTip($g_idLabelGreen, '#Region LABEL') $g_hBrushGreen = _WinAPI_CreateSolidBrush(_ColorToCOLORREF(0x00FF00)) ; green background #Region SLIDER GUICtrlCreateLabel("Slider:", 235, 215) Local $idSlider = GUICtrlCreateSlider(270, 210, 120, 30) _AddControlForSubclass($idSlider) GUICtrlSetTip(-1, '#Region SLIDER') GUICtrlSetData(-1, 30) #EndRegion SLIDER #Region INPUT Local $idInput2 = GUICtrlCreateInput("Sample Input Box", 235, 255, 130, 20) _AddControlForSubclass($idInput2) GUICtrlSetTip(-1, '#Region INPUT') #EndRegion INPUT #Region DATE $g_idDate = GUICtrlCreateDate("", 5, 280, 200, 20) $g_hDate = GUICtrlGetHandle($g_idDate) _AddControlForSubclass($g_idDate) GUICtrlSetTip(-1, '#Region DATE') GUICtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20) #EndRegion DATE #Region BUTTON Local $idButton = GUICtrlCreateButton("Sample Button", 10, 330, 100, 30) _AddControlForSubclass($idButton) GUICtrlSetTip(-1, '#Region BUTTON') #EndRegion BUTTON #Region CHECKBOX Local $idCheckBox = GUICtrlCreateCheckbox("Checkbox", 130, 335, 80, 20) GUICtrlSetTip(-1, '#Region CHECKBOX') DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", GUICtrlGetHandle($idCheckBox), "wstr", 0, "wstr", 0) #EndRegion CHECKBOX #Region TREEVIEW ONE Local $idTreeView1 = GUICtrlCreateTreeView(210, 290, 80, 80) _AddControlForSubclass($idTreeView1) GUICtrlSetBkColor($idTreeView1, $COLOR_EDIT_BG) GUICtrlSetColor($idTreeView1, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region TREEVIEW ONE') Local $idTreeViewItem = GUICtrlCreateTreeViewItem("TreeView", $idTreeView1) GUICtrlCreateTreeViewItem("Item1", $idTreeViewItem) GUICtrlCreateTreeViewItem("Item2", $idTreeViewItem) GUICtrlCreateTreeViewItem("Foo", -1) GUICtrlSetState($idTreeViewItem, $GUI_EXPAND) #EndRegion TREEVIEW ONE #Region TREEVIEW TWO Local $idTreeView2 = GUICtrlCreateTreeView(295, 290, 103, 80, $TVS_CHECKBOXES) _AddControlForSubclass($idTreeView2) GUICtrlSetBkColor($idTreeView2, $COLOR_EDIT_BG) GUICtrlSetColor($idTreeView2, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region TREEVIEW TWO') GUICtrlCreateTreeViewItem("TreeView", $idTreeView2) GUICtrlCreateTreeViewItem("With", $idTreeView2) GUICtrlCreateTreeViewItem("$TVS_CHECKBOXES", $idTreeView2) GUICtrlSetState(-1, $GUI_CHECKED) GUICtrlCreateTreeViewItem("Style", $idTreeView2) #EndRegion TREEVIEW TWO ; Apply Dark Mode _ApplyDarkModeToAllControls() ; Handle scrollbars for windows that have them _EnableDarkScrollBars() ; Register a custom window procedure for the tab control for owner-drawing $g_hTab_CB = DllCallbackRegister('_WinProc', 'ptr', 'hwnd;uint;wparam;lparam') $g_pTab_CB = DllCallbackGetPtr($g_hTab_CB) $g_hProc = _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_pTab_CB) GUISetState(@SW_SHOW) _OverpaintWhiteLine() _WinAPI_RedrawWindow($g_hGUI, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _CleanupSubclassing() _CleanupBrushes() ExitLoop EndSwitch WEnd ; Restore the original window procedure for the tab control _WinAPI_SetWindowLong($g_hTab, $GWL_WNDPROC, $g_hProc) DllCallbackFree($g_hTab_CB) GUIDelete() EndFunc ;==>_Example Func _OverpaintWhiteLine() Local $hDC = _WinAPI_GetWindowDC($g_hGUI) If Not $hDC Then Return Local $tWndRect = _WinAPI_GetWindowRect($g_hGUI) Local $iWndWidth = $tWndRect.right - $tWndRect.left ; 1. Caption height Local $iCaptionHeight = _WinAPI_GetSystemMetrics($SM_CYCAPTION) ; 2. Border height (top) Local $iBorderHeight = _WinAPI_GetSystemMetrics($SM_CYSIZEFRAME) If $iBorderHeight = 0 Then $iBorderHeight = _WinAPI_GetSystemMetrics($SM_CYFIXEDFRAME) ; 3. Determine menu height dynamically Local $iMenuHeight = _WinAPI_GetSystemMetrics($SM_CYMENU) ; standard menu height ; Alternative: get menu height via GetMenuBarInfo Local $tMenuBarInfo = DllStructCreate("dword cbSize;long left;long top;long right;long bottom;handle hwndMenu;handle hwndItem;bool fBarFocused;bool fFocused") DllStructSetData($tMenuBarInfo, "cbSize", DllStructGetSize($tMenuBarInfo)) Local $aResult = DllCall("user32.dll", "bool", "GetMenuBarInfo", "hwnd", $g_hGUI, "long", 0xFFFFFFFD, "long", 0, "ptr", DllStructGetPtr($tMenuBarInfo)) If IsArray($aResult) And $aResult[0] Then ; Calculate the actual menu height from the coordinates Local $iMenuTop = $tMenuBarInfo.top Local $iMenuBottom = $tMenuBarInfo.bottom ; Convert to window coordinates $iMenuHeight = ($iMenuBottom - $iMenuTop) EndIf ; The white line is directly below the menu Local $iWhiteLineY = $iCaptionHeight + $iBorderHeight + $iMenuHeight - _WinAPI_GetSystemMetrics($SM_CYFIXEDFRAME) * 2 ;~ ConsoleWrite("Caption: " & $iCaptionHeight & ", Border: " & $iBorderHeight & ", Menu: " & $iMenuHeight & " -> White Line at Y=" & $iWhiteLineY & @CRLF) ; Overpaint the white line (1x2 pixels) Local $tRect = DllStructCreate($tagRECT) With $tRect .left = 0 .top = $iWhiteLineY .right = $iWndWidth .bottom = $iWhiteLineY + 2 ; 2 pixels high EndWith Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) ;~ Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF(0xFF0000)) _WinAPI_FillRect($hDC, $tRect, $hBrush) _WinAPI_DeleteObject($hBrush) _WinAPI_ReleaseDC($g_hGUI, $hDC) EndFunc ;==>_OverpaintWhiteLine Func _WM_ACTIVATE_OverpaintLine($hWnd, $iMsg, $wParam, $lParam) If $hWnd <> $g_hGUI Then Return $GUI_RUNDEFMSG _OverpaintWhiteLine() Return $GUI_RUNDEFMSG EndFunc ;==>_WM_ACTIVATE_OverpaintLine Func _WM_WINDOWPOSCHANGED_OverpaintLine($hWnd, $iMsg, $wParam, $lParam) If $hWnd <> $g_hGUI Then Return $GUI_RUNDEFMSG _OverpaintWhiteLine() Return $GUI_RUNDEFMSG EndFunc ;==>_WM_WINDOWPOSCHANGED_OverpaintLine Func _OnInitMenuPopup($hWnd, $iMsg, $wParam, $lParam) ; wParam = HMENU of the popup, lParam = position/index - not needed here ; A small delay sometimes helps to ensure the popup window exists Sleep(100) ; The foreground window is most likely the new menu popup Local $hPopup = _WinAPI_GetForegroundWindow() If Not $hPopup Then Return $GUI_RUNDEFMSG Local $sCls = StringLower(_WinAPI_GetClassName($hPopup)) If $sCls <> "#32768" And $sCls <> "popupmenu" Then ; if no menu popup is detected -> do nothing Return $GUI_RUNDEFMSG EndIf ; Set Theme + AllowDarkMode on the popup itself _WinAPI_SetWindowTheme($hPopup, "DarkMode_Explorer", "") _WinAPI_AllowDarkModeForWindow($hPopup, True) ; Also apply the theme to all child windows of the popup (e.g., scrollbars) Local $hChild = _WinAPI_GetWindow($hPopup, $GW_CHILD) While $hChild Local $sChildCls = StringLower(_WinAPI_GetClassName($hChild)) ; apply theme specifically for scrollbars, UpDown, etc. If $sChildCls = "scrollbar" Or $sChildCls = "msctls_updown32" Or $sChildCls = "traynotifywnd" Then _WinAPI_SetWindowTheme($hChild, "DarkMode_Explorer", "") _WinAPI_AllowDarkModeForWindow($hChild, True) Else ; try generically _WinAPI_SetWindowTheme($hChild, "DarkMode_Explorer", "") _WinAPI_AllowDarkModeForWindow($hChild, True) EndIf $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd ; Force refresh so the change is visible immediately _WinAPI_FlushMenuThemes() _WinAPI_RefreshImmersiveColorPolicyState() _WinAPI_RedrawWindow($hPopup, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW)) Return $GUI_RUNDEFMSG EndFunc ;==>_OnInitMenuPopup Func _ColorToCOLORREF($iColor) ;RGB to BGR Local $iR = BitAND(BitShift($iColor, 16), 0xFF) Local $iG = BitAND(BitShift($iColor, 8), 0xFF) Local $iB = BitAND($iColor, 0xFF) Return BitOR(BitShift($iB, -16), BitShift($iG, -8), $iR) EndFunc ;==>_ColorToCOLORREF Func _AddControlForSubclass($iCtrlID) Local $hCtrl = GUICtrlGetHandle($iCtrlID) If $hCtrl Then $g_aControls[$g_iControlCount][0] = $iCtrlID $g_aControls[$g_iControlCount][1] = $hCtrl $g_aControls[$g_iControlCount][2] = 0 ; Placeholder for OldWndProc $g_iControlCount += 1 EndIf EndFunc ;==>_AddControlForSubclass Func _ApplyDarkModeToAllControls() ; DWM Dark Mode for the main window _WinAPI_SetPreferredAppMode($APPMODE_FORCEDARK) ; Create subclass callback If Not $g_pSubclassProc Then $g_pSubclassProc = DllCallbackRegister("_SubclassProc", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr") EndIf ; Subclass all controls For $i = 0 To $g_iControlCount - 1 Local $hCtrl = $g_aControls[$i][1] If $hCtrl Then Local $sClass = _WinAPI_GetClassName($hCtrl) ; Use SetWindowSubclass _WinAPI_SetWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i, 0) ; Special themes for different control types Switch StringLower($sClass) Case "edit", "richedit", "richedit20a", "richedit20w" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_CFD", 0) Case "button" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case "combobox" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_CFD", 0) ; Handle ComboBox child-edit Local $hEdit = _WinAPI_FindWindowEx($hCtrl, 0, "Edit", "") If $hEdit Then _WinAPI_SetWindowTheme($hEdit, "DarkMode_CFD", 0) _WinAPI_AllowDarkModeForWindow($hEdit, True) EndIf ; ComboBox dropdown list Local $hComboLBox = _WinAPI_FindWindowEx($hCtrl, 0, "ComboLBox", "") If $hComboLBox Then _WinAPI_SetWindowTheme($hComboLBox, "DarkMode_Explorer", 0) _WinAPI_AllowDarkModeForWindow($hComboLBox, True) EndIf Case "syslistview32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) ; ListView extended styles for better dark mode _SendMessage($hCtrl, $LVS_EX_DOUBLEBUFFER, 0x00010000, 0x00010000) ; Also make the ListView header dark Local $hHeader = _SendMessage($hCtrl, $LVM_GETHEADER, 0, 0) If $hHeader Then _WinAPI_SetWindowTheme($hHeader, "DarkMode_ItemsView", 0) EndIf Case "systreeview32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case "msctls_trackbar32" ; Slider _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case "systabcontrol32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", "") ;must be "" ; tab-Control background _SendMessage($hCtrl, 0x132D, 0, $COLOR_BG_DARK) ; TCM_SETBKCOLOR ; Try to make the UpDown (spinner for too many tabs) dark as well Local $hUpDown = _WinAPI_FindWindowEx($hCtrl, 0, "msctls_updown32", "") If $hUpDown Then _WinAPI_SetWindowTheme($hUpDown, "DarkMode_Explorer", 0) Case "listbox" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case "msctls_progress32" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case "scrollbar" _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) Case Else _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) EndSwitch _WinAPI_AllowDarkModeForWindow($hCtrl, True) EndIf Next ; Update theme system _WinAPI_RefreshImmersiveColorPolicyState() _WinAPI_FlushMenuThemes() _WinAPI_DwmSetWindowAttribute($g_hGUI, $DWMWA_USE_IMMERSIVE_DARK_MODE, True) ; Redraw GUI _WinAPI_RedrawWindow($g_hGUI, 0, 0, $RDW_UPDATENOW) EndFunc ;==>_ApplyDarkModeToAllControls Func _CleanupSubclassing() ; Remove all subclasses If $g_pSubclassProc Then For $i = 0 To $g_iControlCount - 1 Local $hCtrl = $g_aControls[$i][1] If $hCtrl Then _WinAPI_RemoveWindowSubclass($hCtrl, DllCallbackGetPtr($g_pSubclassProc), $i) EndIf Next DllCallbackFree($g_pSubclassProc) $g_pSubclassProc = 0 EndIf EndFunc ;==>_CleanupSubclassing Func _SubclassProc($hWnd, $iMsg, $wParam, $lParam, $iID, $pData) Switch $iMsg Case $WM_NOTIFY Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) Local $hFrom = $tNMHDR.hWndFrom Local $iCode = $tNMHDR.Code ; --- Adjust ListView Header text color --- If $iCode = $NM_CUSTOMDRAW Then Local $tNMCUSTOMDRAW = DllStructCreate($tagNMCUSTOMDRAW, $lParam) Local $dwDrawStage = $tNMCUSTOMDRAW.dwDrawStage Local $hDC = $tNMCUSTOMDRAW.hdc Switch $dwDrawStage Case $CDDS_PREPAINT Return $CDRF_NOTIFYITEMDRAW Case $CDDS_ITEMPREPAINT _WinAPI_SetTextColor($hDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) ; White text _WinAPI_SetBkColor($hDC, _ColorToCOLORREF($COLOR_BG_DARK)) ; Dark background Return BitOR($CDRF_NEWFONT, $CDRF_NOTIFYPOSTPAINT) EndSwitch EndIf Case $WM_PAINT ; Custom Paint for better Dark Mode rendering Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndSwitch ; Forward standard message to DefSubclassProc Return _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_SubclassProc Func _MakeMenuOwnerDraw($hWnd) ; Get menu handle $g_hMenu = _GUICtrlMenu_GetMenu($hWnd) If Not $g_hMenu Then Return False Local $iCount = _GUICtrlMenu_GetItemCount($g_hMenu) If $iCount <= 0 Then Return False ReDim $g_aMenuText[$iCount] For $i = 0 To $iCount - 1 ; retrieve text via GetMenuStringW (works better than _GUICtrlMenu_GetItemText) Local $tText = DllStructCreate("wchar s[256]") Local $iLen = DllCall("user32.dll", "int", "GetMenuStringW", _ "handle", $g_hMenu, _ "uint", $i, _ "struct*", $tText, _ "int", 255, _ "uint", 0x0400) ; MF_BYPOSITION If IsArray($iLen) And $iLen[0] > 0 Then $g_aMenuText[$i] = $tText.s Else $g_aMenuText[$i] = "" EndIf ; set top-level item to owner-draw _GUICtrlMenu_SetItemType($g_hMenu, $i, $MFT_OWNERDRAW, True) Next ; redraw menu bar immediately _GUICtrlMenu_DrawMenuBar($hWnd) _WinAPI_RedrawWindow($hWnd, 0, 0, BitOR($RDW_INVALIDATE, $RDW_UPDATENOW)) Return True EndFunc ;==>_MakeMenuOwnerDraw Func WM_MEASUREITEM_Handler($hWnd, $iMsg, $wParam, $lParam) Local $tagMEASUREITEM = "uint CtlType;uint CtlID;uint itemID;uint itemWidth;uint itemHeight;ulong_ptr itemData" Local $t = DllStructCreate($tagMEASUREITEM, $lParam) If Not IsDllStruct($t) Then Return $GUI_RUNDEFMSG If $t.CtlType <> $ODT_MENU Then Return $GUI_RUNDEFMSG Local $itemID = $t.itemID ; itemID is the control ID, not the position! ; We must derive the position from the itemID Local $iPos = -1 For $i = 0 To UBound($g_aMenuText) - 1 If $itemID = ($i + 3) Then ; Offset of 3 due to internal IDs $iPos = $i ExitLoop EndIf Next ; Fallback: try the itemID directly If $iPos < 0 Then $iPos = $itemID If $iPos < 0 Or $iPos >= UBound($g_aMenuText) Then $iPos = 0 Local $sText = $g_aMenuText[$iPos] ; Calculate text dimensions Local $hDC = _WinAPI_GetDC($hWnd) Local $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0) If Not $hFont Then $hFont = _WinAPI_GetStockObject($DEFAULT_GUI_FONT) Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont) Local $tSize = _WinAPI_GetTextExtentPoint32($hDC, $sText) Local $iTextWidth = $tSize.X Local $iTextHeight = $tSize.Y _WinAPI_SelectObject($hDC, $hOldFont) _WinAPI_ReleaseDC($hWnd, $hDC) ; Set dimensions with padding $t.itemWidth = $iTextWidth + 1 $t.itemHeight = $iTextHeight + 1 Return 1 EndFunc ;==>WM_MEASUREITEM_Handler Func WM_DRAWITEM_Handler($hWnd, $iMsg, $wParam, $lParam) Local $tagDRAWITEM = "uint CtlType;uint CtlID;uint itemID;uint itemAction;uint itemState;ptr hwndItem;handle hDC;" & _ "long left;long top;long right;long bottom;ulong_ptr itemData" Local $t = DllStructCreate($tagDRAWITEM, $lParam) If Not IsDllStruct($t) Then Return $GUI_RUNDEFMSG If $t.CtlType <> $ODT_MENU Then Return $GUI_RUNDEFMSG Local $hDC = $t.hDC Local $left = $t.left Local $top = $t.top Local $right = $t.right Local $bottom = $t.bottom Local $state = $t.itemState Local $itemID = $t.itemID ; convert itemID to position Local $iPos = -1 For $i = 0 To UBound($g_aMenuText) - 1 If $itemID = ($i + 3) Then $iPos = $i ExitLoop EndIf Next If $iPos < 0 Then $iPos = $itemID If $iPos < 0 Or $iPos >= UBound($g_aMenuText) Then $iPos = 0 Local $sText = $g_aMenuText[$iPos] $sText = StringReplace($sText, "&", "") ; Colors Local $clrBG = _ColorToCOLORREF($COLOR_BG_DARK) Local $clrSel = _ColorToCOLORREF(0x505050) Local $clrText = _ColorToCOLORREF($COLOR_TEXT_LIGHT) Static $iDrawCount = 0 Static $bFullBarDrawn = False ; Count how many items were drawn in this "draw cycle" $iDrawCount += 1 ; If we are at the first item AND the bar has not yet been drawn If $iPos = 0 And Not $bFullBarDrawn Then ; Get the full window width Local $tClient = _WinAPI_GetClientRect($hWnd) Local $iFullWidth = DllStructGetData($tClient, "right") ; Fill the entire menu bar Local $tFullMenuBar = DllStructCreate($tagRECT) With $tFullMenuBar .left = 0 .top = $top .right = $iFullWidth + 3 .bottom = $bottom EndWith Local $hFullBrush = _WinAPI_CreateSolidBrush($clrBG) _WinAPI_FillRect($hDC, $tFullMenuBar, $hFullBrush) _WinAPI_DeleteObject($hFullBrush) EndIf ; After drawing all items, mark as "drawn" If $iDrawCount >= UBound($g_aMenuText) Then $bFullBarDrawn = True $iDrawCount = 0 EndIf ; Draw background for the area AFTER the last menu item If $iPos = (UBound($g_aMenuText) - 1) Then ; Last menu Local $tClient = _WinAPI_GetClientRect($hWnd) Local $iFullWidth = DllStructGetData($tClient, "right") ; Fill only the area to the RIGHT of the last menu item If $right < $iFullWidth Then Local $tEmptyArea = DllStructCreate($tagRECT) With $tEmptyArea .left = $right .top = $top .right = $iFullWidth + _WinAPI_GetSystemMetrics(7) .bottom = $bottom EndWith Local $hEmptyBrush = _WinAPI_CreateSolidBrush($clrBG) _WinAPI_FillRect($hDC, $tEmptyArea, $hEmptyBrush) _WinAPI_DeleteObject($hEmptyBrush) EndIf EndIf ; Draw item background (selected = lighter) Local $bSelected = BitAND($state, $ODS_SELECTED) Local $hBrush = _WinAPI_CreateSolidBrush($bSelected ? $clrSel : $clrBG) Local $tItemRect = DllStructCreate($tagRECT) With $tItemRect .left = $left .top = $top .right = $right .bottom = $bottom EndWith _WinAPI_FillRect($hDC, $tItemRect, $hBrush) _WinAPI_DeleteObject($hBrush) ; Setup font Local $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0) If Not $hFont Then $hFont = _WinAPI_GetStockObject($DEFAULT_GUI_FONT) Local $hOldFont = _WinAPI_SelectObject($hDC, $hFont) _WinAPI_SetBkMode($hDC, $TRANSPARENT) _WinAPI_SetTextColor($hDC, $clrText) ; Draw text Local $tTextRect = DllStructCreate($tagRECT) With $tTextRect .left = $left + 10 .top = $top + 4 .right = $right - 10 .bottom = $bottom - 4 EndWith DllCall("user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $sText, "int", -1, "ptr", DllStructGetPtr($tTextRect), "uint", BitOR($DT_SINGLELINE, $DT_VCENTER, $DT_LEFT)) If $hOldFont Then _WinAPI_SelectObject($hDC, $hOldFont) Return 1 EndFunc ;==>WM_DRAWITEM_Handler Func _WM_CTLCOLOR($hWnd, $iMsg, $wParam, $lParam) Local $hDC = $wParam Local $hCtrl = $lParam ; If the control is the special green label -> return green background If $hCtrl = $g_hLabelGreen Then ; black text on a green background _WinAPI_SetTextColor($hDC, _ColorToCOLORREF(0x000000)) _WinAPI_SetBkColor($hDC, _ColorToCOLORREF(0x00FF00)) _WinAPI_SetBkMode($hDC, $OPAQUE) ; important, otherwise it remains transparent and you cannot see the background If $g_hBrushGreen Then Return $g_hBrushGreen EndIf ; --- Special case: Make "Sample Pic" label transparent --- If $hCtrl = $g_hLabelPic Then ; set transparent background _WinAPI_SetBkMode($hDC, $TRANSPARENT) ; set text color (if necessary) - e.g., white _WinAPI_SetTextColor($hDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) ; return NULL_BRUSH (stock object), so Windows does NOT fill with your dark brush Local $hNull = _WinAPI_GetStockObject(5) ; 5 = NULL_BRUSH If $hNull Then Return $hNull ; Fallback if not available: Return $GUI_RUNDEFMSG EndIf ; --- Default behavior for all other statics / controls --- _WinAPI_SetTextColor($hDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) Local $hBrush = $g_hBrushEdit Local $iColor = $COLOR_EDIT_BG Switch $iMsg Case $WM_CTLCOLORBTN $hBrush = $g_hBrushButton $iColor = $COLOR_BUTTON_BG Case $WM_CTLCOLORSTATIC $hBrush = $g_hBrushBg $iColor = $COLOR_BG_DARK EndSwitch _WinAPI_SetBkColor($hDC, _ColorToCOLORREF($iColor)) _WinAPI_SetBkMode($hDC, $TRANSPARENT) Return $hBrush EndFunc ;==>_WM_CTLCOLOR Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $tInfo, $tBuffer, $tBuffer2, $iCtrl $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd($tNMHDR.hWndFrom) $iIDFrom = $tNMHDR.IDFrom $iCode = $tNMHDR.Code Switch $hWndFrom Case $g_hDate ;thanks to argumentum for the code :-) Switch $iCode Case $NM_SETFOCUS ; Disable the visual theme when the DateTime control receives focus _WinAPI_SetThemeAppProperties(0) Case $DTN_DROPDOWN ; Apply dark colors when the calendar dropdown appears _WinAPI_SetWindowTheme($iCtrl, "", "") Local $iCtrl = _GUICtrlDTP_GetMonthCal($hWndFrom) _GUICtrlMonthCal_SetColor($iCtrl, $MCSC_TEXT, $COLOR_TEXT_LIGHT) _GUICtrlMonthCal_SetColor($iCtrl, $MCSC_TITLEBK, $COLOR_BG_DARK) _GUICtrlMonthCal_SetColor($iCtrl, $MCSC_TITLETEXT, $COLOR_TEXT_LIGHT) _GUICtrlMonthCal_SetColor($iCtrl, $MCSC_MONTHBK, $COLOR_BG_DARK) _GUICtrlMonthCal_SetColor($iCtrl, $MCSC_TRAILINGTEXT, $COLOR_TEXT_LIGHT) Case $DTN_CLOSEUP ; Calendar will closed EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _CleanupBrushes() ; Delete all brushes If $g_hBrushEdit Then _WinAPI_DeleteObject($g_hBrushEdit) If $g_hBrushButton Then _WinAPI_DeleteObject($g_hBrushButton) If $g_hBrushBg Then _WinAPI_DeleteObject($g_hBrushBg) If $g_hBrushGreen Then _WinAPI_DeleteObject($g_hBrushGreen) EndFunc ;==>_CleanupBrushes Func _EnableDarkScrollBars() ; Try to enable Dark Mode for all scrollbars (also for TreeView with checkboxes) For $i = 0 To $g_iControlCount - 1 Local $hCtrl = $g_aControls[$i][1] If Not $hCtrl Then ContinueLoop ; 1️ Normal attempt (works for most controls) Local $tScrollInfo = _GUIScrollBars_GetScrollInfoEx($hCtrl, 1) If IsDllStruct($tScrollInfo) Then _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) EndIf ; 2️ Extension: If the control has its own scrollbar child windows (e.g., TreeView with $TVS_CHECKBOXES) Local $hChild = _WinAPI_GetWindow($hCtrl, $GW_CHILD) While $hChild Local $sClass = _WinAPI_GetClassName($hChild) If StringCompare($sClass, "ScrollBar") = 0 Then ; Set DarkMode on the ScrollBar itself _WinAPI_SetWindowTheme($hChild, "DarkMode_Explorer", 0) _WinAPI_AllowDarkModeForWindow($hChild, True) EndIf $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) WEnd Next EndFunc ;==>_EnableDarkScrollBars Func _WinProc($hWnd, $iMsg, $wParam, $lParam) ; Custom window procedure for tab control with Dark Mode Switch $iMsg Case $WM_ERASEBKGND Return 1 ; Prevent background erase to avoid flicker Case $WM_PAINT Local $tPaint = DllStructCreate($tagPAINTSTRUCT) Local $hDC = DllCall("user32.dll", "handle", "BeginPaint", "hwnd", $hWnd, "struct*", $tPaint) If @error Or Not $hDC[0] Then Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) $hDC = $hDC[0] ; Get client rectangle Local $tClient = _WinAPI_GetClientRect($hWnd) If Not IsDllStruct($tClient) Then _WinAPI_EndPaint($hWnd, $tPaint) Return 0 EndIf Local $iWidth = $tClient.Right Local $iHeight = $tClient.Bottom ; Create memory DC for double buffering Local $hMemDC = _WinAPI_CreateCompatibleDC($hDC) Local $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $iWidth, $iHeight) Local $hOldBmp = _WinAPI_SelectObject($hMemDC, $hBitmap) ; Fill background Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) _WinAPI_FillRect($hMemDC, $tClient, $hBrush) _WinAPI_DeleteObject($hBrush) ; Get tab info Local $iTabCount = _SendMessage($hWnd, 0x1304, 0, 0) ; TCM_GETITEMCOUNT Local $iCurSel = _SendMessage($hWnd, 0x130B, 0, 0) ; TCM_GETCURSEL ; Setup font Local $hFont = _SendMessage($hWnd, $WM_GETFONT, 0, 0) If Not $hFont Then $hFont = _WinAPI_GetStockObject($DEFAULT_GUI_FONT) Local $hOldFont = _WinAPI_SelectObject($hMemDC, $hFont) _WinAPI_SetBkMode($hMemDC, $TRANSPARENT) _WinAPI_SetTextColor($hMemDC, _ColorToCOLORREF($COLOR_TEXT_LIGHT)) ; Draw each tab Local $tRect, $tRect, $iLeft, $iTop, $iRight, $iBottom For $i = 0 To $iTabCount - 1 ; Get tab rectangle using TCM_GETITEMRECT $tRect = DllStructCreate($tagRECT) $aResult = DllCall("user32.dll", "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", 0x130A, _ ; TCM_GETITEMRECT "wparam", $i, _ "struct*", $tRect) If @error Or Not $aResult[0] Then ContinueLoop $iLeft = $tRect.Left $iTop = $tRect.Top $iRight = $tRect.Right $iBottom = $tRect.Bottom ; Skip if rectangle is invalid If $iLeft >= $iRight Or $iTop >= $iBottom Then ContinueLoop ; Get tab text Local $tItem = DllStructCreate("uint Mask;dword dwState;dword dwStateMask;ptr pszText;int cchTextMax;int iImage;lparam lParam") Local $tText = DllStructCreate("wchar Text[256]") With $tItem .Mask = 0x0001 ; TCIF_TEXT .pszText = DllStructGetPtr($tText) .cchTextMax = 256 EndWith DllCall("user32.dll", "lresult", "SendMessageW", _ "hwnd", $hWnd, _ "uint", 0x133C, _ ; TCM_GETITEMW "wparam", $i, _ "struct*", $tItem) Local $sText = DllStructGetData($tText, "Text") ; Draw tab background Local $bSelected = ($i = $iCurSel) Local $iTabColor = $bSelected ? $COLOR_BUTTON_BG : $COLOR_BG_DARK Local $hTabBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($iTabColor)) Local $tTabRect = DllStructCreate($tagRECT) With $tTabRect .Left = $iLeft .Top = $iTop .Right = $iRight .Bottom = $iBottom EndWith _WinAPI_FillRect($hMemDC, $tTabRect, $hTabBrush) _WinAPI_DeleteObject($hTabBrush) ;~ Local $hTabPen = _WinAPI_CreatePen(0, 1, _ColorToCOLORREF($COLOR_BORDER)) ;~ Local $hOldTabPen = _WinAPI_SelectObject($hMemDC, $hTabPen) ;~ _WinAPI_MoveTo($hMemDC, $iLeft, $iBottom) ;~ _WinAPI_LineTo($hMemDC, $iRight, $iBottom) ;~ _WinAPI_SelectObject($hMemDC, $hOldTabPen) ;~ _WinAPI_DeleteObject($hTabPen) ; Draw selection indicator (top border for selected tab) If $bSelected Then Local $hPen = _WinAPI_CreatePen(0, 2, _ColorToCOLORREF(0x0078D4)) ; Blue accent Local $hOldPen = _WinAPI_SelectObject($hMemDC, $hPen) _WinAPI_MoveTo($hMemDC, $iLeft, $iTop) _WinAPI_LineTo($hMemDC, $iRight - 2, $iTop) _WinAPI_SelectObject($hMemDC, $hOldPen) _WinAPI_DeleteObject($hPen) EndIf ; Draw separator between tabs If $i < $iTabCount - 1 Then Local $hPenSep = _WinAPI_CreatePen(0, 1, _ColorToCOLORREF($COLOR_BORDER)) Local $hOldPenSep = _WinAPI_SelectObject($hMemDC, $hPenSep) _WinAPI_MoveTo($hMemDC, $iRight - 1, $iTop + 4) _WinAPI_LineTo($hMemDC, $iRight - 1, $iBottom - 4) _WinAPI_SelectObject($hMemDC, $hOldPenSep) _WinAPI_DeleteObject($hPenSep) EndIf ; Draw text centered in tab Local $tTextRect = DllStructCreate($tagRECT) With $tTextRect .Left = $iLeft + 6 .Top = $iTop + 3 .Right = $iRight - 6 .Bottom = $iBottom - 3 EndWith DllCall("user32.dll", "int", "DrawTextW", _ "handle", $hMemDC, _ "wstr", $sText, _ "int", -1, _ "struct*", $tTextRect, _ "uint", BitOR($DT_CENTER, $DT_VCENTER, $DT_SINGLELINE)) Next ; Draw border around entire control Local $hBorderPen = _WinAPI_CreatePen(0, 1, _ColorToCOLORREF($COLOR_BORDER)) Local $hOldBorderPen = _WinAPI_SelectObject($hMemDC, $hBorderPen) Local $hNullBrush = _WinAPI_GetStockObject(5) ; NULL_BRUSH Local $hOldBorderBrush = _WinAPI_SelectObject($hMemDC, $hNullBrush) DllCall("gdi32.dll", "bool", "Rectangle", _ "handle", $hMemDC, _ "int", 0, _ "int", 0, _ "int", $iWidth, _ "int", $iHeight) _WinAPI_SelectObject($hMemDC, $hOldBorderPen) _WinAPI_SelectObject($hMemDC, $hOldBorderBrush) _WinAPI_DeleteObject($hBorderPen) ; Copy to screen _WinAPI_BitBlt($hDC, 0, 0, $iWidth, $iHeight, $hMemDC, 0, 0, $SRCCOPY) ; Cleanup _WinAPI_SelectObject($hMemDC, $hOldFont) _WinAPI_SelectObject($hMemDC, $hOldBmp) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) _WinAPI_EndPaint($hWnd, $tPaint) Return 0 EndSwitch Return _WinAPI_CallWindowProc($g_hProc, $hWnd, $iMsg, $wParam, $lParam) EndFunc ;==>_WinProc Func _WinAPI_FindWindowEx($hParent, $hAfter, $sClass, $sTitle = "") Local $ret = DllCall("user32.dll", "hwnd", "FindWindowExW", "hwnd", $hParent, "hwnd", $hAfter, "wstr", $sClass, "wstr", $sTitle) If @error Or Not IsArray($ret) Then Return 0 Return $ret[0] EndFunc ;==>_WinAPI_FindWindowEx #Region DarkMode API Func _WinAPI_ShouldAppsUseDarkMode() Local $aResult = DllCall("UxTheme.dll", "bool", 132) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_ShouldAppsUseDarkMode Func _WinAPI_AllowDarkModeForWindow($hWND, $bAllow = True) Local $aResult = DllCall("UxTheme.dll", "bool", 133, "hwnd", $hWND, "bool", $bAllow) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_AllowDarkModeForWindow Func _WinAPI_FlushMenuThemes() Local $aResult = DllCall("UxTheme.dll", "none", 136) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_FlushMenuThemes Func _WinAPI_RefreshImmersiveColorPolicyState() Local $aResult = DllCall("UxTheme.dll", "none", 104) If @error Then Return SetError(1, 0, False) Return True EndFunc ;==>_WinAPI_RefreshImmersiveColorPolicyState Func _WinAPI_IsDarkModeAllowedForWindow($hWND) Local $aResult = DllCall("UxTheme.dll", "bool", 137, "hwnd", $hWND) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_IsDarkModeAllowedForWindow Func _WinAPI_GetIsImmersiveColorUsingHighContrast($iIMMERSIVE_HC_CACHE_MODE) Local $aResult = DllCall("UxTheme.dll", "bool", 106, "long", $iIMMERSIVE_HC_CACHE_MODE) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_GetIsImmersiveColorUsingHighContrast Func _WinAPI_OpenNcThemeData($hWND, $tClassList) Local $aResult = DllCall("UxTheme.dll", "hwnd", 49, "hwnd", $hWND, "struct*", $tClassList) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_OpenNcThemeData Func _WinAPI_ShouldSystemUseDarkMode() Local $aResult = DllCall("UxTheme.dll", "bool", 138) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_ShouldSystemUseDarkMode Func _WinAPI_IsDarkModeAllowedForApp() Local $aResult = DllCall("UxTheme.dll", "bool", 139) If @error Then Return SetError(1, 0, False) Return ($aResult[0] <> 0) EndFunc ;==>_WinAPI_IsDarkModeAllowedForApp Func _WinAPI_AllowDarkModeForApp($bAllow = True) ;Windows 10 Build 17763 Return _WinAPI_SetPreferredAppMode($bAllow ? 1 : 0) ; 1 = AllowDark, 0 = Default EndFunc ;==>_WinAPI_AllowDarkModeForApp Func _WinAPI_SetPreferredAppMode($iPreferredAppMode) ;Windows 10 Build 18362+ Local $aResult = DllCall("UxTheme.dll", "long", 135, "long", $iPreferredAppMode) If @error Then Return SetError(1, 0, False) Return $aResult[0] EndFunc ;==>_WinAPI_SetPreferredAppMode #EndRegion DarkMode API Does anyone know how to switch the date picker to dark mode?2 points
-
SampleControls.au3 in Dark Mode
UEZ and one other reacted to argumentum for a topic
Any of this code ( https://www.autoitscript.com/forum/topic/191058-datetime-pick-coloring ) useful ?2 points -
You're supposed to be able to set #AutoIt3Wrapper_AU3Check_Parameters with the flags you want (which would be -w- 4 for turning off the local in global scope warning) but turns out there's a bug with reading them in for the diagnostics that I'm fixing right now. `2 points
-
Hi everyone, that's exactly right ! I found the solution at work this morning! But I couldn't respond. Like you, I considered adding a variable : $iRet_Value, but I tried to overcomplicate things at the beginning and i lost time ! Case $g_idButton4 ConsoleWrite("GUI2: CANCEL=" & $g_idButton4 & @CRLF) $iRet_Value ="KO" ExitLoop and i put : if $iRet_Value ="KO" then return instead : if gui2()... I didn't know this way : Func Traitement_intermediaire() ; display the listview If gui2() Then Return MsgBox(0, "Suite", "cela continue") ;suite du script ;.... EndFunc ;==>Traitement_intermediair Thank you for your help 🙂2 points
-
Displaying a new GUI (listview) in a traitment - (Moved)
ermar and one other reacted to pixelsearch for a topic
Sure it's enough and better, no need of the optional parameter when calling gui2() Well done !2 points -
@pixelsearch thanks for the clarification, because I didn't think about/understand this case question, isn't that enough? Local $aMsg = 0, $iReturn = 0 While 1 $aMsg = GUIGetMsg($GUI_EVENT_ARRAY) Switch $aMsg[1] ; Switch from GUIs Case $g_hGUI2 Switch $aMsg[0] ; Switch from event ID Case $GUI_EVENT_CLOSE, $g_idButton4 ConsoleWrite("GUI2: $GUI_EVENT_CLOSE=" & $GUI_EVENT_CLOSE & @CRLF) If $aMsg[0] = $g_idButton4 Then ConsoleWrite(" with Cancel" & @CRLF) $iReturn = 1 EndIf ExitLoop Case $g_idButton3 ConsoleWrite("GUI2: $g_idButton3=" & $g_idButton3 & @CRLF) MessageBox(2) EndSwitch EndSwitch WEnd GUIDelete($g_hGUI2) GUICtrlSetState($g_idButton2, $GUI_ENABLE) Opt("GUIOnEventMode", 1) ; when out of $g_hGUI2 - enable <<<<<<<<<<<<<<< Return $iReturn EndFunc ;==>gui2 ... Func Traitement_intermediaire() ; display the listview If gui2() Then Return MsgBox(0, "Suite", "cela continue") ;suite du script ;.... EndFunc ;==>Traitement_intermediaire2 points
-
Hi @Gianni, Sorry for the late reply. First of all thank you for the nice words . Yes i noticed that, that's why my demo downloads an image instead. I'm not currently sure why it does not work. 🤷♂️ I seem to remember some documentation mentioning requirements like maximum response time and file size, but i cannot find that currently. It seems to be the case, when the app is not registered with the system. After adding the registry and registering the COM objects, activationType foreground also works. Again, not sure why, currently. This is a very cool tool for crafting toast UI, thanks Edit: I can see the tool might be available as open source on GitHub, so maybe I'll make an AutoIt version at some point, for fun Ah, thank you2 points
-
See example in helpfile for _GDIPlus_TextureCreate()2 points
-
ByRef parameter cannot have default value. You must to use ByRef something like this $sOut = "" RunCmd("CmdLine", $sOut) ConsoleWrite($sOut & @CRLF) ; changed Func RunCmd($sCmd, ByRef $sOut) $sOut = "changed" EndFunc2 points
-
MouseHoverCallTips [10/18/2025]
ioa747 and one other reacted to jaberwacky for a topic
Latest update! Check it out!2 points -
Issues with "_CloseForm"
Musashi and one other reacted to pixelsearch for a topic
No big deal, just make it simple : use a single underscore, check the help file (while scripting) to make sure the name with underscore doesn't already exists. And if you don't check the help file, then you'll always got one of these 2 errors, for example with this silly script ! #include <Array.au3> Func _ArrayDisplay($aArray) EndFunc * Au3Check (when saving your script) => error: _ArrayDisplay() already defined. * Then if you run the script => Duplicate function name : _ArrayDisplay() No, the loop While...WEnd is provided so the script doesn't end immediately ! Try to comment out the While...WEnd loop and see what happens : $Form1 will be displayed a couple of ms then the script ends. This While...WEnd loop is an endless loop and you're "stuck" inside it while the script is running (when no event is triggered, for example clicking a button etc...) . Just add a counter inside it to see how it goes : Local $iCount = 0 While 1 $iCount +=1 ConsoleWrite($iCount & @CRLF) Sleep(10) ; prevents hogging all the CPU (+++) WEnd See how the counter constantly increases in the Console ? It shows that you're stuck inside this loop (as ConsoleWrite is constantly called) until you choose to exit the script. What do you expect that could happen between functions ? Nothing. When a function ends (EndFunc) then as showed before, you're stuck in the While...WEnd loop, waiting for another event to occur (user closes a GUI, presses a button etc...) $Form2 is hidden because of this line which immediately follows your "9e" comment : GUISetState(@SW_HIDE, $Form2) You don't have to "exit" a window to hide it, you can simply apply a line of code, anywhere in your script, to hide it : that's the purpose of GUISetState(@SW_HIDE, $Form2) In this script (unfortunately) clicking buttons in Form2 and Form3 have the same effect than clicking the {X] button to close their GUI's . It would be better to add some "real action" that will happen when you click the buttons, instead of simply mimicking a Windows Close when you click the buttons. But you'll certainly do this in your final project. GUISetState(@SW_HIDE, $Form2) has nothing to do with the fact that $Form1 is displayed because GUISetState(@SW_HIDE, $Form2) simply hides $Form2, no more, no less. In this script, $Form1 is never hidden but it may be covered by other windows and we probably would like, when needed, to make $Form1 not only "current" (GUISwitch) but also "active" (on top, with focus) using WinActivate (as correctly stated in the help file, topic GUISwitch) To achieve this, I suggest these modifications in functions _ColRow and _CloseForm : Func _ColRow() Switch @GUI_CtrlId Case $sGUI2Button GUISetState(@SW_HIDE, $Form2) GUICtrlSetState($sCol1Row1, $GUI_ENABLE) Case $sGUI3Button GUISetState(@SW_HIDE, $Form3) GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch GUISwitch($Form1) If Not WinActive($Form1) Then WinActivate($Form1) EndFunc ;==>_ColRow Func _CloseForm() Switch @GUI_WinHandle Case $Form1 MsgBox($MB_OK, "Exit Main Form", "Exiting...", 1) Exit Case $Form2 GUISetState(@SW_HIDE, $Form2) GUICtrlSetState($sCol1Row1, $GUI_ENABLE) Case $Form3 GUISetState(@SW_HIDE, $Form3) GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch GUISwitch($Form1) If Not WinActive($Form1) Then WinActivate($Form1) EndFunc ;==>_CloseForm This will activate $Form1 if it was covered by another window, when you click on buttons or close Form2 / Form3 Of course, if you intentionally minimized $Form1 then it won't have any effect. In this case ($Form1 minimized by the user) then it requires an additional line of code. Hope I answered all your questions, time to rest...2 points -
some observations #include <WinAPIGdi.au3> ;Coded by WildByDesign 1st post Local $sFontFile = "C:\Windows\Fonts\Rubik-VariableFont_wght.ttf" ConsoleWrite("Title: " & _WinAPI_GetFontResourceInfo($sFontFile, True) & @CRLF) ConsoleWrite(@CRLF) ;Coded by UEZ build 2025-10-07 ;~ Local $sFontFile = FileOpenDialog("Select a font", "", "Fonts (*.ttf)") If $sFontFile = "" Or @error Then Exit ConsoleWrite("Title: " & _WinAPI_GetFontTitle($sFontFile) & @CRLF) Func _WinAPI_GetFontTitle($sFont) If Not _WinAPI_AddFontResourceEx($sFontFile, $FR_PRIVATE) Then Return SetError(1, 0, 0) Local $tFont = DllStructCreate("wchar title[4096]") Local $aRet = DllCall("gdi32.dll", "bool", "GetFontResourceInfoW", "wstr", $sFontFile, "dword*", DllStructGetSize($tFont), "struct*", $tFont, "dword", 1) If @error Or Not $aRet[0] Then _WinAPI_RemoveFontResourceEx($sFontFile, $FR_PRIVATE) Return SetError(2, 0, 0) EndIf _WinAPI_RemoveFontResourceEx($sFontFile, $FR_PRIVATE) Return $tFont.title EndFunc From what I understand, Parsix is looking for this, which WildByDesign already published in the 1st post ;Coded by WildByDesign 1st post #include <WinAPIGdi.au3> Local $sFontFile = "C:\Windows\Fonts\Rubik-VariableFont_wght.ttf" FontGetInfoFromFile($sFontFile, 1, "Font Family name") FontGetInfoFromFile($sFontFile, 4, "Font full name") Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) EndFunc ;==>FontGetInfoFromFile WildByDesign the only thing that confused me is the 256 FontGetInfoFromFile($sFile, 256, "Font-specific names") since _WinAPI_GetFontMemoryResourceInfo only shows up to 20 (maybe undocumented)?2 points
-
Does this work? ;Coded by UEZ build 2025-10-07 #include <WinAPIGdi.au3> Local $sFontFile = FileOpenDialog("Select a font", "", "Fonts (*.ttf)") If $sFontFile = "" Or @error Then Exit ConsoleWrite("Title: " & _WinAPI_GetFontTitle($sFontFile) & @CRLF) Func _WinAPI_GetFontTitle($sFont) If Not _WinAPI_AddFontResourceEx($sFontFile, $FR_PRIVATE) Then Return SetError(1, 0, 0) Local $tFont = DllStructCreate("wchar title[4096]") Local $aRet = DllCall("gdi32.dll", "bool", "GetFontResourceInfoW", "wstr", $sFontFile, "dword*", DllStructGetSize($tFont), "struct*", $tFont, "dword", 1) If @error Or Not $aRet[0] Then _WinAPI_RemoveFontResourceEx($sFontFile, $FR_PRIVATE) Return SetError(2, 0, 0) EndIf _WinAPI_RemoveFontResourceEx($sFontFile, $FR_PRIVATE) Return $tFont.title EndFunc2 points
-
How to Read Font Title from File Property
ioa747 and one other reacted to WildByDesign for a topic
I only had to use this once before but you need _WinAPI_GetFontResourceInfo() to read font name directly from a font file properties. Example: #include <WinAPIGdi.au3> Example() Func Example() Local $sFile = "C:\Windows\Fonts\segoeui.ttf" ConsoleWrite(_WinAPI_GetFontResourceInfo($sFile, True) & @CRLF) ConsoleWrite(@CRLF) FontGetInfoFromFile($sFile, 0, "Copyright") FontGetInfoFromFile($sFile, 1, "Font Family name") FontGetInfoFromFile($sFile, 2, "Font SubFamily name") FontGetInfoFromFile($sFile, 3, "Unique font identifier") FontGetInfoFromFile($sFile, 4, "Font full name") FontGetInfoFromFile($sFile, 5, "Version string") FontGetInfoFromFile($sFile, 6, "Postscript name") FontGetInfoFromFile($sFile, 7, "Trademark") FontGetInfoFromFile($sFile, 8, "Manufacturer Name") FontGetInfoFromFile($sFile, 9, "Designer") FontGetInfoFromFile($sFile, 10, "Description") FontGetInfoFromFile($sFile, 11, "URL Vendor") FontGetInfoFromFile($sFile, 16, "Preferred Family (Windows only)") FontGetInfoFromFile($sFile, 17, "Preferred SubFamily (Windows only)") FontGetInfoFromFile($sFile, 18, "Compatible Full (Mac OS only)") FontGetInfoFromFile($sFile, 19, "Sample text") FontGetInfoFromFile($sFile, 20, "PostScript CID findfont name") FontGetInfoFromFile($sFile, 256, "Font-specific names") EndFunc ;==>Example Func FontGetInfoFromFile($sFile, $n, $sElement) Local $s = _WinAPI_GetFontResourceInfo($sFile, Default, $n) If Not @error And $s Then ConsoleWrite($sElement & " = " & $s & @CRLF) EndFunc ;==>FontGetInfoFromFile2 points -
StringReplace... mirrored ?
argumentum and one other reacted to jchd for a topic
Regexes can save your a$$ everyday!2 points -
Func test3() Local $sStr = "a ''' 123 ''' b ''' 234 ''' c" ConsoleWrite(StringRegExpReplace($sStr, "'''([^']+)'''", "*'$1'*") & @CRLF) EndFunc2 points
-
AutoIt Extension for Visual Studio Code
donnyh13 and one other reacted to SOLVE-SMART for a topic
Fair enough, understood, thanks. Thanks 👌 . 😂 Maybe you should rename yourself to Philosoph'tum 😆 . Best regards Sven2 points -
BETA: SciTE v5x & lua Dynamic_include and "Smart" AutoComplete for Vars/UDFs/Abbrevs
SOLVE-SMART and one other reacted to donnyh13 for a topic
Hi Jos, Not sure if you are wishing for a fix to the comments. But if so: I added to ~Line 105: if string.find(editor:GetLine(Parent_line), "^%s*;") then self:DebugPrint('! Parent Line is a Comment, finding real parent.', "Old Parent line: " .. Parent_line, "New Parent Line: " .. editor.FoldParent[Parent_line]) Parent_line = editor.FoldParent[Parent_line] end And to ~line 228, after: elseif Curr_firstword == "" and Curr_lastword == "" and Parent_line ~= -1 and string.find(',if,do,while,with,for,select,switch,func,volatile,', ',' .. fold_firstword .. ',', nil, true) ~= nil then -- Empty line in a fold, update indent to appropriate parent fold level. editor.LineIndentation[line + 1] = editor.LineIndentation[Parent_line] + editor.Indent self:DebugPrint('- Empty line in a keyword, update indent to Parent + 1 --', editor.LineIndentation[line + 1]) Added the following: elseif (string.find(Curr_firstword, "^;") ~= nil) and Curr_lastword == "" then -- Correct Indent after a comment which may be in the wrong indentation position. if (Parent_line ~= -1) and string.find(',if,do,while,with,for,select,switch,func,volatile,', ',' .. fold_firstword .. ',', nil, true) ~= nil then editor.LineIndentation[line + 1] = editor.LineIndentation[Parent_line] + editor.Indent self:DebugPrint('- New line after a comment, update indent to Parent + 1 --', "New Indent Level: " .. editor.LineIndentation[line + 1]) else editor.LineIndentation[line + 1] = 0 self:DebugPrint('- New line after a comment outside of a fold, update indent to 0 --', "New Indent Level: " .. editor.LineIndentation[line + 1]) end If you're not concerned. You can ignore this. Best regards,2 points -
Text in GDI+ images loses transparency
argumentum and one other reacted to ioa747 for a topic
; https://www.autoitscript.com/forum/topic/213213-text-in-gdi-images-loses-transparency/#findComment-1546336 #include <WinAPIConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPISysWin.au3> _GDIPlus_Startup() Global $iW, $iH, $hImage, $hGUI $hImage = _GDIPlus_BitmapCreateFromFile(@ScriptDir & "\cart.png") $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $hGUI = GUICreate("", $iW, $iH, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_LAYERED)) GUISetState() _add_TEXT_to_IMG($hImage, String(5), 58, 5) ; Convert the MODIFIED GDI+ image to HBITMAP Local $hBitmapToDisplay = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) ; Display the new HBITMAP transparently _WinAPI_BitmapDisplayTransparentInGUI($hBitmapToDisplay, $hGUI) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; Cleanup ; _WinAPI_BitmapDisplayTransparentInGUI already deleted $hBitmapToDisplay _GDIPlus_BitmapDispose($hImage) _GDIPlus_Shutdown() GUIDelete() Func _add_TEXT_to_IMG(ByRef $hImage, $sText, $iX = 5, $iY = 70, $sFontName = "Arial", $fSize = 5, $fStyle = 1, $iColor = 0xFFFFFFFF) Local Const $hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage) _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 4) _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, 3) Local Const $hBrush = _GDIPlus_BrushCreateSolid($iColor) Local Const $hFormat = _GDIPlus_StringFormatCreate() ;~ _GDIPlus_StringFormatSetAlign($hFormat, 1) ; Center text horizontally _GDIPlus_StringFormatSetAlign($hFormat, 0) ; Left Align for better text control Local Const $hFamily = _GDIPlus_FontFamilyCreate($sFontName) Local Const $hFont = _GDIPlus_FontCreate($hFamily, $fSize, $fStyle) Local Const $aDim = _GDIPlus_ImageGetDimension($hImage) ;~ Local Const $tLayout = _GDIPlus_RectFCreate($iX, $iY, $aDim[0], $aDim[1]) Local Const $tLayout = _GDIPlus_RectFCreate($iX, $iY, $aDim[0] - $iX, $aDim[1] - $iY) ; Adjusted layout for better text control _GDIPlus_GraphicsDrawStringEx($hGraphic, $sText, $hFont, $tLayout, $hFormat, $hBrush) _GDIPlus_FontDispose($hFont) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphic) EndFunc ;==>_add_TEXT_to_IMG Func _WinAPI_BitmapDisplayTransparentInGUI(ByRef $hHBitmap, ByRef $hGUI, $iOpacity = 0xFF, $bReleaseGDI = True) ; (by @UEZ) If Not BitAND(GUIGetStyle($hGUI)[1], $WS_EX_LAYERED) = $WS_EX_LAYERED Then Return SetError(1, 0, 0) Local $tDim = DllStructCreate($tagBITMAP) If Not _WinAPI_GetObject($hHBitmap, DllStructGetSize($tDim), DllStructGetPtr($tDim)) Then Return SetError(2, 0, 0) Local $tSize = DllStructCreate($tagSIZE), $tSource = DllStructCreate($tagPOINT), $tBlend = DllStructCreate($tagBLENDFUNCTION) Local Const $hScrDC = _WinAPI_GetDC(0), $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC), $hOld = _WinAPI_SelectObject($hMemDC, $hHBitmap) $tSize.X = $tDim.bmWidth $tSize.Y = $tDim.bmHeight $tBlend.Alpha = $iOpacity $tBlend.Format = 1 _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, DllStructGetPtr($tSize), $hMemDC, DllStructGetPtr($tSource), 0, DllStructGetPtr($tBlend), $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteDC($hMemDC) If $bReleaseGDI Then _WinAPI_DeleteObject($hHBitmap) Return True EndFunc ;==>_WinAPI_BitmapDisplayTransparentInGUI2 points -
https://github.com/BiatuAutMiahn/DriverMgr2/blob/main/CPP/7zip/UI/Client7z/Client7z.cpp I franeknstein'd Igor's Client7z implementation so that I could read DriverPack archives, and make a driver database. Cleaned that mess up a bit into this: https://github.com/BiatuAutMiahn/7zip/blob/DriverMgr/CPP/7zip/Common/DriverPackMgr.cpp Then I exported the ddb functionality into a standalone utility for the DriverPackDB creation and hardware matching. https://github.com/BiatuAutMiahn/dpdbutil This is part of a driver framework in my WinPE project for work. Figured this was perfect for adding drivers to WinPE instead of mounting the image and injecting drivers, just look for the DDBs and load them.2 points
-
Tested with AutoIt 3.3.18.0 on a german W11 24H2 system. Works perfektly!2 points
-
Smooth Color Transistions
mlibre2 and one other reacted to argumentum for a topic
2 points -
Hour AM/PM ( yes, one more of these )
Musashi and one other reacted to argumentum for a topic
#include <Date.au3> #include <SQLite.au3> #include <Debug.au3> ; Show current date/time in the pc's format Exit _DateTimeFormat_Compare() Func _DateTimeFormat_Compare() Local $aArray[10][8] $aArray[0][0] = " | 0 - date and/or time." $aArray[0][1] = " | 1 - long date, regional settings." $aArray[0][2] = " | 2 - short date, regional settings." $aArray[0][3] = " | 3 - time, regional settings." $aArray[0][4] = " | 4 - time 24-hour (hh:mm)." $aArray[0][5] = " | 5 - time 24-hour (hh:mm:ss)." $aArray[0][6] = " | 6 - time AM/PM (hh:mm tt)." $aArray[0][7] = " | 7 - time AM/PM (hh:mm:ss tt)." _DateTimeFormat_Test($aArray, _NowCalc(), @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 23:59:59", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 AM", @extended) _DateTimeFormat_Test($aArray, "2025/12/31 11:59:59 PM", @extended) ReDim $aArray[@extended + 1][8] Local $sArray = _SQLite_Display2DResult($aArray, 0, True) ConsoleWrite($sArray) ClipPut($sArray) ; to share in the forum if there is an error _DebugArrayDisplay($aArray, "_DateTimeFormat()") EndFunc ;==>_DateTimeFormat_Compare Func _DateTimeFormat_Test(ByRef $aArray, $sNowCalc, $iRow = 0) For $n = 0 To 7 $aArray[$iRow + 1][$n] = " | " & _DateTimeFormat($sNowCalc, $n) Next Return SetError(0, $iRow + 1, "Testing, testing. 1, 2, 3.") EndFunc ;==>_DateTimeFormat_Test Lets call this script "the golden test", so that we can share results. Makes sense to report failures only as otherwise we would be spamming the living out of the forum. If it all worked well, ... add a like/thanks to the post with the patch to show you tested it and worked as expected. | 0 - date and/or time. | 1 - long date, regional settings. | 2 - short date, regional settings. | 3 - time, regional settings. | 4 - time 24-hour (hh:mm). | 5 - time 24-hour (hh:mm:ss). | 6 - time AM/PM (hh:mm tt). | 7 - time AM/PM (hh:mm:ss tt). | 9/25/2025 12:19:48 PM | Thursday, September 25, 2025 | 9/25/2025 | 12:19:48 PM | 12:19 | 12:19:48 | 12:19 PM | 12:19:48 PM | 12/31/2025 11:59:59 AM | Wednesday, December 31, 2025 | 12/31/2025 | 11:59:59 AM | 11:59 | 11:59:59 | 11:59 AM | 11:59:59 AM | 12/31/2025 11:59:59 PM | Wednesday, December 31, 2025 | 12/31/2025 | 11:59:59 PM | 23:59 | 23:59:59 | 11:59 PM | 11:59:59 PM | 12/31/2025 11:59:59 AM | Wednesday, December 31, 2025 | 12/31/2025 | 11:59:59 AM | 11:59 | 11:59:59 | 11:59 AM | 11:59:59 AM | 12/31/2025 11:59:59 PM | Wednesday, December 31, 2025 | 12/31/2025 | 11:59:59 PM | 23:59 | 23:59:59 | 11:59 PM | 11:59:59 PM This report may look ugly in the browser but you can copy it and paste it to an editor and it'll look as intended. It looks good to me. If after peer review there are no complains ( say: a month ), it'll go into beta. Thanks @ioa747 Also, it'll need the help file adjustments to explain it's functionality ( important )2 points -
Smooth Color Transistions
argumentum and one other reacted to ioa747 for a topic
experimentally: #include <GUIConstantsEx.au3> #include <WinAPIGdi.au3> #include <WindowsConstants.au3> #include <WinAPIEx.au3> #include <Timers.au3> Global $hGUI, $idColor1, $idColor2, $idColor3 Example() Func Example() ; Create a GUI. $hGUI = GUICreate("HLS Rainbow Controls Example", 500, 300, -1, -1, $WS_POPUP) $idColor1 = GUICtrlCreateLabel("", 0, 0, 500, 30, -1, $GUI_WS_EX_PARENTDRAG) $idColor2 = GUICtrlCreateLabel("", 0, 100, 500, 30) $idColor3 = GUICtrlCreateLabel("", 0, 200, 500, 30) Local $idBtn = GUICtrlCreateButton("CLOSE", 400, 250, 85, 30) ; Display the GUI. GUISetState(@SW_SHOW, $hGUI) ; set timer to check every nnn Local $i_TimerInterval = 40 _Timer_SetTimer($hGUI, $i_TimerInterval, "_TimerCheck") ; Register the time-based color update function. AdlibRegister("RandomColorViaTimer", 40) ; Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idBtn ExitLoop EndSwitch DoBorder() WEnd ; Cleanup ConsoleWrite("Killed All Timers? " & _Timer_KillAllTimers($hGUI) & @CRLF) AdlibUnRegister("RandomColorViaTimer") GUIDelete($hGUI) EndFunc ;==>Example Func RandomColorViaTimer() Local Const $iHueSpeed = 3 Local Const $iMaxHLS = 240 Local Const $iLuminance = 120 Local Const $iSaturation = 240 Local Static $iHue = 0 Local Static $hTimer = TimerInit() ; Calculate Hue $iHue = Mod($iHue + $iHueSpeed, $iMaxHLS) ; Time for a full Hue cycle If $iHue = 0 Then ConsoleWrite("<< << << Adlib: Time for a full Hue cycle: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds >> >> >>" & @LF) $hTimer = TimerInit() EndIf ; Convert HLS (0-240) to RGB Local $iColorRef = _WinAPI_ColorHLSToRGB($iHue, $iLuminance, $iSaturation) Local $sRGB = '0x' & Hex(_WinAPI_ColorHLSToRGB($iHue, $iLuminance, $iSaturation), 6) ; Apply Colors GUICtrlSetBkColor($idColor1, $sRGB) Local $sRef = _ColorRef($sRGB) ConsoleWrite("Adlib: " & $sRef & @CRLF) EndFunc ;==>RandomColorViaTimer ; Timer call back function Func _TimerCheck($hWnd, $iMsg, $iIDTimer, $iTime) #forceref $hWnd, $iMsg, $iIDTimer, $iTime Local Const $iHueSpeed = 3 Local Const $iMaxHLS = 240 Local Const $iLuminance = 120 Local Const $iSaturation = 240 Local Static $iHue = 160 Local Static $hTimer = TimerInit() ; Calculate Hue (reverse to fit with DoBorder) $iHue -= $iHueSpeed If $iHue < 0 Then $iHue = $iMaxHLS ; Time for a full Hue cycle If $iHue = $iMaxHLS Then ConsoleWrite("<< << << Timer: Time for a full Hue cycle: " & Round(TimerDiff($hTimer) / 1000, 3) & " seconds >> >> >>" & @LF) $hTimer = TimerInit() EndIf ; Convert HLS (0-240) to RGB Local $iColorRef = _WinAPI_ColorHLSToRGB($iHue, $iLuminance, $iSaturation) Local $sRGB = '0x' & Hex(_WinAPI_ColorHLSToRGB($iHue, $iLuminance, $iSaturation), 6) ; Apply Colors GUICtrlSetBkColor($idColor2, $sRGB) Local $sRef = _ColorRef($sRGB) ConsoleWrite("Timer: " & $sRef & @CRLF) EndFunc ;==>_TimerCheck Func DoBorder() Local Const $fSpeed = 4 Local Const $fInverseSpeed = 1 / $fSpeed Local Static $fHue ;the border col will be calculated based on the time elapsed from a single timer. Local Static $hTimer = TimerInit() Local Static $hTimer1 = TimerInit() Local Static $fLastTime Local $fCurTime = TimerDiff($hTimer) Local $fTimerSec = ($fCurTime - $fLastTime) / 1000 If $fTimerSec < 1 / 25 Then Return ;Slow down processing (do not needlessly refresh faster than 25hz) $fLastTime = $fCurTime ;Hue is a value between 0 and 1. ;Its value is based on the internal timer.. $fHue += ($fTimerSec * $fInverseSpeed) If $fHue >= 1 Then $fHue -= Int($fHue) ConsoleWrite("<< << << Bordr: Time for a full Hue cycle: " & Round(TimerDiff($hTimer1) / 1000, 3) & " seconds >> >> >>" & @LF) $hTimer1 = TimerInit() EndIf ;T = transition value. So RGB values are all based on this. ;We want RGB values to be between 0 and 1. Local $fT = 6 * $fHue Local $fR = Abs($fT - 3) - 1 Local $fG = 2 - Abs($fT - 2) Local $fB = 2 - Abs($fT - 4) ;Max values out at 0 and 1. $fR = ($fR < 0) ? 0 : ($fR > 1) ? 1 : $fR $fG = ($fG < 0) ? 0 : ($fG > 1) ? 1 : $fG $fB = ($fB < 0) ? 0 : ($fB > 1) ? 1 : $fB ;RGB is now a percentage of max values $fR *= 255 $fG *= 255 $fB *= 255 ;Construct RGB Value. (reverse order due to endianness!) Local $iRGB = BitOR(BitShift(Int($fB), -16), BitShift(Int($fG), -8), Int($fR)) GUICtrlSetBkColor($idColor3, $iRGB) Local $sRef = _ColorRef($iRGB) ConsoleWrite("Bordr: " & $sRef & @CRLF) EndFunc ;==>DoBorder Func _ColorRef($sRGB) ; Optionaly RGB analysis Local $iHue, $iLuminance, $iSaturation _WinAPI_ColorRGBToHLS($sRGB, $iHue, $iLuminance, $iSaturation) Local $R = _WinAPI_GetRValue($sRGB) Local $G = _WinAPI_GetGValue($sRGB) Local $B = _WinAPI_GetBValue($sRGB) Local $iAutoItColor = _WinAPI_RGB($R, $G, $B) Local $sHexColor = "0x" & Hex($iAutoItColor, 6) Local $sRef = "HLS(" & $iHue & "," & $iLuminance & "," & $iSaturation & ") => RGB(" & $R & "," & $G & "," & $B & ") => " & $sHexColor Return $sRef EndFunc ;==>_ColorRef2 points -
Smooth Color Transistions
WildByDesign and one other reacted to MattyD for a topic
My pleasure mate Ok fair enough. Just as an eye test, we probably on need to refresh this every 100ms or so to keep the animation relatively smooth. At that pace I wouldn't think we'd run into responsiveness issues caused by too much border-ing. But yes, if the process is too busy to call DoBorder() then the animation would obviously pause. That function shouldn't really do anything until that "1/25" seconds has elapsed.. so would adlib a bit slower and save some resources Try 100ms to start, and if it looks janky you can speed it up a little bit from there. Adlibing super fast can also cause issues, this is because the adlib gap could be smaller than the available idle time.. In that case you'll just endup with a backlog of adlib tasks that can't be processed, and you'll probably ramp the cpu. To give you an idea, even doing a Sleep(1) will take around 10 - 15ms by the time the process goes to sleep and wakes up again.2 points -
Smooth Color Transistions
argumentum and one other reacted to Werty for a topic
f in C# means float, but you are treating them as Hex. So it's just $t =$Hue * 6 in AU3, removing the f.2 points -
Help File/Documentation Issues. (Discussion Only)
pixelsearch and one other reacted to jpm for a topic
it is fix for the next delivery2 points