Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation since 10/09/2025 in Posts

  1. V1.0.0 released! 🎊 Event on toast interaction now works! πŸŽ‰
    5 points
  2. 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 GitHub
    5 points
  3. 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
  4. 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 ;==>_GetDesktopWorkerW
    3 points
  5. 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
  6. wakillon

    SlidingToolbar

    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.7z
    3 points
  7. UEZ

    AutoIt Snippets

    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
  8. 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
  9. 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
  10. Sure it's enough and better, no need of the optional parameter when calling gui2() Well done !
    2 points
  11. wakillon

    enumicons.au3

    Last week I came across enumicons.au3 in the folder C:\Program Files (x86)\AutoIt3\Examples\GUI\Advanced and while testing it, I thought that a small update wouldn't hurt enumicons.au3
    2 points
  12. @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_intermediaire
    2 points
  13. @ioa747 hello Maybe ermar asks for this : when he clicks on button "Traitement" in GUI1, then the function Traitement_intermediaire() is called, which calls gui2() and creates the listview. Now he starts to modify the listview, but suddenly he would like to cancel everything. Unfortunately, when he clicks the button "Cancel" in GUI2, the function Traitement_intermediaire() continues with this line in Traitement_intermediaire() MsgBox(0, "Suite", "cela continue") ;suite du script So we should indicate a way so the Cancel button in GUI2 reacts differently, depending on the part of the script which called gui2() 1) If gui2() was called from the function On_Button() => Case $g_idButton2 => gui2() , then no change is required 2) If gui2() was called from the function Traitement_intermediaire() => gui2() , then some code is required in case the user clicks on button Cancel in GUI2 . The change could be like this : Func Traitement_intermediaire() ; gui2() If gui2(1) Then Return MsgBox(0, "Suite", "cela continue") ;suite du script ;.... EndFunc ; Func gui2() Func gui2($iCancelStopsAll = 0) Local $iReturn = 0 ... Case $GUI_EVENT_CLOSE, $g_idButton4 If $iCancelStopsAll Then $iReturn = 1 ... Return $iReturn ; 0 or 1 EndFunc Note : if the GUI2 Close button [X] should react differently than the GUI2 Cancel button, then the Case should be splitted in 2 (one Case for $GUI_EVENT_CLOSE, another Case for $g_idButton4) Hope it makes sense... if this is what ermar asked for !
    2 points
  14. ioa747

    AutoIt Snippets

    trick for ToolTip with timer Func _ToolTip($sText, $iX = Default, $iY = Default, $sTitle = "", $iIcon = 0, $iTimeout = 1500, $iOptions = 0) AdlibUnRegister("_ToolTipKiller") ; This prevents the previous timer from closing the new tooltip. ToolTip($sText, $iX, $iY, $sTitle, $iIcon, $iOptions) AdlibRegister("_ToolTipKiller", $iTimeout) EndFunc ;==>_ToolTip Func _ToolTipKiller() ToolTip("") ; Hide the tooltip AdlibUnRegister("_ToolTipKiller") ; unregister itself. EndFunc ;==>_ToolTipKiller Example ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/28/#findComment-1546696 ;---------------------------------------------------------------------------------------- ; Title...........: Trick for ToolTip with timer ; Description.....: Displays a native tooltip with timer. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 0.1 ; Note............: Testet in Win10 22H2 Date:16/10/2025 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> Forms() Func Forms() Local $hGui = GUICreate(@ScriptName, 250, 150, -1, -1) Local $idBtn1 = GUICtrlCreateButton("Button 1", 10, 10, 100, 25) Local $idBtn2 = GUICtrlCreateButton("Button 2", 10, 40, 100, 25) Local $idBtn3 = GUICtrlCreateButton("Button 3", 10, 70, 100, 25) Local $idBtn4 = GUICtrlCreateButton("Button 4", 10, 100, 100, 25) GUISetState(@SW_SHOW, $hGui) While 1 Local $aWPos = WinGetPos($hGui) Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtn1 _ToolTip("...is clicked", $aWPos[0], $aWPos[1] - 15, "Button 1", 1) Case $idBtn2 _ToolTip("...is clicked", $aWPos[0], $aWPos[1] - 15, "Button 2", 1) Case $idBtn3 _ToolTip("...is clicked", $aWPos[0], $aWPos[1] - 15, "Button 3", 1) Case $idBtn4 _ToolTip("...is clicked", $aWPos[0], $aWPos[1] - 15, "Button 4", 1) EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>Forms Func _ToolTip($sText, $iX = Default, $iY = Default, $sTitle = "", $iIcon = 0, $iTimeout = 1500, $iOptions = 0) AdlibUnRegister("_ToolTipKiller") ; This prevents the previous timer from closing the new tooltip. ToolTip($sText, $iX, $iY, $sTitle, $iIcon, $iOptions) AdlibRegister("_ToolTipKiller", $iTimeout) EndFunc ;==>_ToolTip Func _ToolTipKiller() ToolTip("") ; Hide the tooltip AdlibUnRegister("_ToolTipKiller") ; unregister itself. EndFunc ;==>_ToolTipKiller
    2 points
  15. I added some resize code this morning that seems to work well. There are still going to be some differences depending on what DPI scaling the user has set on their system. So I still have to factor DPI into the code at some point. Example with resize:
    2 points
  16. I was able to test this new event functionality this morning and it works great. Excellent job! Without a doubt, this is the most fully featured toast notification UDF for AutoIt specifically for utilizing native toast functionality. There are some other UDFs which create their own toast-like notifications. But using built-in Windows functionality is generally the best way to go. Your UDF already does everything that I personally would ever need as far as toast notifications go. One of the best toast notification apps that I've ever used on Windows 11 is actually from KDE, of all things. Snoretoast (https://github.com/KDE/snoretoast). But I didn't like the idea of having to drop yet another binary on disk for my users. So I will likely switch those apps over to your UDF and keep it all AutoIt. By the way, you can always browse their source code (C++) to see if there is anything that they do that might be beneficial for your UDF. I don't understand some of the more complex parts of toast notification functionality, so I'm not even sure if they have anything extra or not. Cheers (or toast!) 🍷
    2 points
  17. ... Local $sFile = StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", 0, -1) -1 ) & "\Examples\GUI\logo4.gif" Local $hImage = _GDIPlus_ImageLoadFromFile($sFile) ;create an image object based on a file Global $hWorkerW = _WinAPI_FindWindowEx($hProgman, 0, "WorkerW", "") If Not $hWorkerW Then ; dah Local $aEnumWindows = _WinAPI_EnumWindows(False) For $n = 1 To UBound($aEnumWindows) - 1 If $aEnumWindows[$n][1] <> "WorkerW" Then ContinueLoop If _WinAPI_GetParent($aEnumWindows[$n][0]) = $hProgman Then $hWorkerW = $aEnumWindows[$n][0] ExitLoop ; but is likely one at the end of the Z-order EndIf Next EndIf If $hWorkerW = 0 Then Exit MsgBox(16, "ERROR", "Couldn't find WorkerW under Progman", 30) ... OnAutoItExitRegister(CleanupResources) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd CleanupResources() Func CleanupResources() Local Static $iRunOnce = 0 If $iRunOnce Then Return ConsoleWrite('+ Func CleanupResources() - WinExists: ' & WinExists($hGUI) & ' - ' & (IsInt(Execute("@exitCode")) ? 'TrayExit' : 'GuiClosed') & @CRLF) ;cleanup resources _GDIPlus_BrushDispose($hTexture) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hGraphics) _GDIPlus_Shutdown() GUIDelete($hGUI) $iRunOnce = 1 EndFunc ... ...be mindful of everyone and everything ?
    2 points
  18. See example in helpfile for _GDIPlus_TextureCreate()
    2 points
  19. InnI

    autoit error

    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" EndFunc
    2 points
  20. ioa747

    autoit error

    From what I understand from the above, something is wrong on line 11, and it has to do with $sOut (probably has no value) Here it would help if you could show us your code so we can understand more.
    2 points
  21. Latest version! Works on AutoItObject methods now! A big shoutout to ioa747 too!
    2 points
  22. I tried to apply dark mode to the SampleControls.au3 example. What I did so far: ; Coded by UEZ build 2025-10-16 beta ;not DPI aware! #include <APIConstants.au3> #include <AVIConstants.au3> #include <GUIConstantsEx.au3> #include <TreeViewConstants.au3> #include <ListViewConstants.au3> #include <GuiMenu.au3> #include <GuiScrollBars.au3> #include <GuiTab.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 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_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 Local $idDate = GUICtrlCreateDate("", 5, 280, 200, 20) _AddControlForSubclass($idDate) GUICtrlSetBkColor($idDate, $COLOR_EDIT_BG) GUICtrlSetColor($idDate, $COLOR_TEXT_LIGHT) GUICtrlSetTip(-1, '#Region DATE') GUICtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20) GUICtrlSetColor(-1, $COLOR_TEXT_LIGHT) #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() ;under menu bar Local $hDC = _WinAPI_GetWindowDC($g_hGUI) If Not $hDC Then Return Local $tWndRect = _WinAPI_GetWindowRect($g_hGUI) Local $iWndWidth = $tWndRect.right - $tWndRect.left ; Übermale die weiße Linie bei Y=45 Local $tRect = DllStructCreate($tagRECT) With $tRect .left = 0 .top = 45 .right = $iWndWidth .bottom = 46 EndWith Local $hBrush = _WinAPI_CreateSolidBrush(_ColorToCOLORREF($COLOR_BG_DARK)) _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 "sysdatetimepick32" ; Parent DTP dark theme _WinAPI_SetWindowTheme($hCtrl, "DarkMode_Explorer", 0) _WinAPI_AllowDarkModeForWindow($hCtrl, True) ; Child Edit (the visible text part) Local $hEditChild = _WinAPI_FindWindowEx($hCtrl, 0, "Edit", "") If $hEditChild Then _WinAPI_SetWindowTheme($hEditChild, "DarkMode_CFD", 0) _WinAPI_AllowDarkModeForWindow($hEditChild, True) EndIf ; UpDown / Spinner Local $hUpDown = _WinAPI_FindWindowEx($hCtrl, 0, "msctls_updown32", "") If $hUpDown Then _WinAPI_SetWindowTheme($hUpDown, "DarkMode_Explorer", 0) _WinAPI_AllowDarkModeForWindow($hUpDown, True) EndIf 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 _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) DllStructSetData($tTabRect, "Left", $iLeft) DllStructSetData($tTabRect, "Top", $iTop) DllStructSetData($tTabRect, "Right", $iRight) DllStructSetData($tTabRect, "Bottom", $iBottom) _WinAPI_FillRect($hMemDC, $tTabRect, $hTabBrush) _WinAPI_DeleteObject($hTabBrush) ; 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 menu bar and date picker to dark mode?
    1 point
  23. Updated the code -> see 1st post. To do: date picker
    1 point
  24. Absolutely. Thank you so much for confirming.
    1 point
  25. 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 πŸ™‚
    1 point
  26. You're very welcome. You will probably also notice that any scripts that you run may also be fuzzy as well. In that case, you can do the same method with AutoIt3.exe and AutoIt3_x64.exe.
    1 point
  27. AM NOT A DOG ! ( didn't see your post until now ) this is in full screen on 100% this is full screen in 200% Hope this helps. I know that helping would be getting more involved. Ain't got much attention surplus these days.
    1 point
  28. Hi @WildByDesign, Thank you for the feedback and nice words I'm glad to hear it will be put to good use Thanks for the information about KDE/snoretoast, i will differently look at the codebase later, and see if there is anything I'm missing Edit: And thank you for the star on GitHub
    1 point
  29. Thanks to @ioa747 for help with the WM_ACTIVATE function, part of this problem is solved. Coordinates are still going to be an issue for different DPI scaling settings which I will try to figure out later. But the issue with the painted line disappearing anytime the GUI loses and/or gains focus is fixed now. For what it's worth, I had my own solution to this earlier but my method made the line flicker which was not great. This WM_ACTIVATE function seems to be much faster and I haven't noticed any flicker at all. #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WinAPITheme.au3> #include "GUIDarkMode_v0.02mod.au3" #include "ModernMenuRaw.au3" #include <GuiMenu.au3> #include <Array.au3> #include <WinAPIDiag.au3> #include <WinAPIConv.au3> #include <WinAPIGdiDC.au3> ; WA_ACTIVATE constants Global Const $WA_INACTIVE = 0x0000 Global Const $WA_ACTIVE = 0x0001 Global Const $WA_CLICKACTIVE = 0x0002 Global $hGUI ;~ DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext", "HWND", "DPI_AWARENESS_CONTEXT" - 4) _SetMenuBkColor(0x202020) _SetMenuIconBkColor(0x202020) _SetMenuIconBkGrdColor(0x202020) _SetMenuSelectBkColor(0x202020) _SetMenuSelectRectColor(0x202020) _SetMenuSelectTextColor(0xFFFFFF) _SetMenuTextColor(0xFFFFFF) Example() Func Example() $hGUI = GUICreate("My GUI", 300, 200) ;Local $idFileMenu = GUICtrlCreateMenu("&File") Local $idFileMenu = _GUICtrlCreateODTopMenu("&File", $hGUI) GUICtrlCreateMenuItem("&Open", $idFileMenu) GUICtrlCreateMenuItem("&Save", $idFileMenu) GUICtrlCreateMenuItem("", $idFileMenu) Local $idOptionsMenu = GUICtrlCreateMenu("O&ptions", $idFileMenu) GUICtrlCreateMenuItem("View", $idOptionsMenu) GUICtrlCreateMenuItem("", $idOptionsMenu) GUICtrlCreateMenuItem("Tools", $idOptionsMenu) GUICtrlCreateMenuItem("", $idFileMenu) Local $idExitItem = GUICtrlCreateMenuItem("&Exit", $idFileMenu) ;Local $idHelpMenu = GUICtrlCreateMenu("&?") Local $idHelpMenu = _GUICtrlCreateODTopMenu("&?", $hGUI) Local $idAboutItem = GUICtrlCreateMenuItem("&About", $idHelpMenu) Local $idEndBtn = GUICtrlCreateButton("End", 110, 140, 70, 20) Global $hSolidBrush = _WinAPI_CreateBrushIndirect($BS_SOLID, 0xFF00FF) GUIRegisterMsg($WM_NCPAINT, "WM_NCPAINT") GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE_Handler") ;~ GUIRegisterMsg($WM_ERASEBKGND,WM_ERASEBKGND) ;~ GUIRegisterMsg($WM_PAINT,WM_PAINT) ;~ GUIRegisterMsg($WM_DRAWITEM, WM_DRAWITEM2) GuiDarkmodeApply($hGUI) GUISetState(@SW_SHOW) ;_drawUAHMenuNCBottomLine($hGUI) Local $idMsg ; Loop until the user exits. While 1 ;Sleep(20) ;If Not WinActive($hGUI) Then _drawUAHMenuNCBottomLine($hGUI) ;_drawUAHMenuNCBottomLine($hGUI) $idMsg = GUIGetMsg() Switch $idMsg Case $idExitItem, $idEndBtn, $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hSolidBrush) ExitLoop Case $idAboutItem MsgBox($MB_SYSTEMMODAL, "About...", "Colored menu sample") EndSwitch WEnd EndFunc ;==>Example Func WM_DRAWITEM2($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite("WM_DRAWITEM" & @CRLF) ConsoleWrite("$hwnd=" & $hWnd & @CRLF) ;~ ConsoleWrite("$hDC=" & $wParam & @CRLF) WM_DRAWITEM($hWnd, $iMsg, $wParam, $lParam) ;~ _WinAPI_DefSubclassProc($hWnd, $iMsg, $wParam, $lParam) ;~ _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) ;~ _drawUAHMenuNCBottomLine($hWnd) Return True EndFunc ;==>WM_DRAWITEM2 Func WM_PAINT($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite("WM_PAINT" & @CRLF) ConsoleWrite("$hwnd=" & $hWnd & @CRLF) ;~ ConsoleWrite("$hDC=" & $wParam & @CRLF) _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) _drawUAHMenuNCBottomLine($hWnd) Return 0 EndFunc ;==>WM_PAINT Func WM_ERASEBKGND($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite("WM_ERASEBKGND" & @CRLF) ConsoleWrite("$hwnd=" & $hWnd & @CRLF) ConsoleWrite("$hDC=" & $wParam & @CRLF) ;_WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) _drawUAHMenuNCBottomLine($hWnd) Return 1 EndFunc ;==>WM_ERASEBKGND Func WM_NCPAINT($hWnd, $iMsg, $wParam, $lParam) ConsoleWrite("$hwnd=" & $hWnd & @CRLF) ConsoleWrite("$wParam=" & $wParam & @CRLF) _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) _drawUAHMenuNCBottomLine($hWnd) Return 0 EndFunc ;==>WM_NCPAINT Func _drawUAHMenuNCBottomLine($hWnd) $aMenuBarInfo = _GUICtrlMenu_GetMenuBarInfo($hWnd, 0, 1) ;_ArrayDisplay($aMenuBarInfo) $rcClient = _WinAPI_GetClientRect($hWnd) ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet before") ;CHAT GPT Local $aCall = DllCall("user32.dll", "int", "MapWindowPoints", _ "hwnd", $hWnd, _ ; hWndFrom "hwnd", 0, _ ; hWndTo "ptr", DllStructGetPtr($rcClient), _ "uint", 2) ;number of points - 2 for RECT structure If @error Then ;MsgBox($MB_ICONERROR, "Error", @error) Exit EndIf ;_WinAPI_DisplayStruct($rcClient, $tagRECT, "rcClinet after") $rcWindow = _WinAPI_GetWindowRect($hWnd) _WinAPI_OffsetRect($rcClient, -$rcWindow.left, -$rcWindow.top) $rcAnnoyingLine = DllStructCreate($tagRECT) $rcAnnoyingLine.left = $rcClient.left $rcAnnoyingLine.top = $rcClient.top $rcAnnoyingLine.right = $rcClient.right $rcAnnoyingLine.bottom = $rcClient.bottom ;~ _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT) $rcAnnoyingLine.bottom = $rcAnnoyingLine.top $rcAnnoyingLine.top = $rcAnnoyingLine.top - 1 ;~ _WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT,"annoying line") ;~ $rcAnnoyingLine.left = 0 ;~ $rcAnnoyingLine.top = 0 ;~ $rcAnnoyingLine.right = 100 ;~ $rcAnnoyingLine.bottom = 200 $hRgn=_WinAPI_CreateRectRgn(0,0,1000,500) ;~ $hDC = _WinAPI_GetDC($hWnd) $hDC=_WinAPI_GetDCEx($hWnd,$hRgn, BitOR($DCX_WINDOW,$DCX_INTERSECTRGN)) If $hDC=0 Then ConsoleWrite("hDC=0" & @CRLF) EndIf _WinAPI_FillRect($hDC, $rcAnnoyingLine, $hSolidBrush) _WinAPI_ReleaseDC($hWnd, $hDC) ;_WinAPI_DisplayStruct($rcAnnoyingLine, $tagRECT, "annoying line") EndFunc ;==>_drawUAHMenuNCBottomLine ; ioa747 Func WM_ACTIVATE_Handler($hWnd, $MsgID, $wParam, $lParam) _drawUAHMenuNCBottomLine($hGUI) #cs #forceref $MsgID, $wParam, $lParam Switch $WParam Case $WA_INACTIVE ; 0x0000 _drawUAHMenuNCBottomLine($hGUI) Case $WA_ACTIVE ; 0x0001 _drawUAHMenuNCBottomLine($hGUI) Case $WA_CLICKACTIVE ; 0x0002 _drawUAHMenuNCBottomLine($hGUI) Case Else _drawUAHMenuNCBottomLine($hGUI) EndSwitch #ce Return $GUI_RUNDEFMSG EndFunc
    1 point
  30. @ioa747 That is absolutely perfect. The function is fast which I was hoping it would be as well which is a nice bonus. I was not familiar at all with any of the $WA_* values. Your solution was very helpful and I'm also learning a lot from it. Thank you. I appreciate it.
    1 point
  31. Check Scale and layout in Display settings, apparently it's not common to all. try putting at the beginning of your script DllCall("user32.dll", "bool", "SetProcessDpiAwarenessContext", "int", -4) ; -4=PerMonitorAwareV2 (the script must run in 32 bit)
    1 point
  32. it is conflicting with workbench perhaps a autoi:!Toogle comment line is needed Thanks
    1 point
  33. Dan_555

    "Toggled" HotKey Script

    #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 370, 128, 192, 114) $Button1 = GUICtrlCreateButton("Enable Hotkey", 121, 37, 113, 40) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $HotkeKeyState=0, $HotkeKeyStateNotification=0, $HotkeKeyTimer=-1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If $HotkeKeyState=0 Then $HotkeKeyStateNotification=1 $HotkeKeyTimer=TimerInit() $HotkeKeyState=1 GUICtrlSetData ($Button1,"Disable Hotkey") Else Exit EndIf EndSwitch If $HotkeKeyStateNotification=1 Then IF TimerDiff($HotkeKeyTimer)<=5000 Then $MP=MouseGetPos() ToolTip ("Hotkey is enabled",$MP[0]-30,$mp[1]-50) Else $HotkeKeyStateNotification=0 ToolTip("") EndIf EndIf WEnd
    1 point
  34. Always no good, 100%. I am just weirdly curious about doing a desktop sized GUI like this, below the desktop icons but just above the wallpaper, and experiment with adding blur to it to blur the wallpaper or possibly shades of colors. I might end up reinstalling Windows though because nothing seems to be able to successfully create a WorkerW window under Progman on my system. I even tried a few C++ programs that do some neat things that also involve creating a WorkerW under Progman and they fail too on my system. It's an up-to-date 24H2 Win11 Pro but for whatever reason this consistently fails for me.
    1 point
  35. Good day, The three samplings... Sample image of the end results [Click_Me]
    1 point
  36. WildByDesign

    AutoIt Snippets

    I agree. I think that it's either this, or as you also mentioned that it may have been something in win8 but has since changed or no longer works. All of the other related functions return 0 or 1. So in that regard, I am going to avoid using IsDarkModeAllowedForWindow but I will definitely make good use of the other dark mode functions.
    1 point
  37. MattyD

    AutoIt Snippets

    Yeah, totally understand where you're coming from, but I don't think that's what we're seeing here. If I'm a MS developer writing a func that returns BOOL, then I'm returning TRUE or FALSE. Or supervisors are throwing style guides at me... I would hope that's the case anyway! BOOL can only mean "true" or "false" regardless of the actual value - so a different datatype should be used if we're returning something with more meaning than that. But that aside - Assuming our fn definition is correct, and by going by the logic: everything <> 0 = true , then I would expect a bad window handle must return 0. But it doesn't... 100% agree to this. But more to the point - we also can't verify the number and type of params, or even the function name.. I suspect the definition doing the rounds on the internet is incorrect, but I'm more than happy to proven wrong!.
    1 point
  38. first of all thank you very much for your offer (as a tool, and as a code)
    1 point
  39. And the reason is ( drum roll ): is an interpreted language. Otherwise the stub that loads the script would have to be changed and have a stub for every feature to be included or not. Share the source in GitHub and have a free service ( for open source ) sign the compiled script. That should lessen the impact. If is private code, then pay for signing the exe ? I too would love to have no issues with my scripts. And is not just us, this guy from notepad++ went Self-signed. πŸ€·β€β™‚οΈ
    1 point
  40. MattyD

    AutoIt Snippets

    yeah. not sure what ordinal #137 does - but it clearly doesn't return bool. So I'd say if it ever was IsDarkModeAllowedForWindow in win8 or something, it probably isn't now. - well, at least it doesn't work in the way people on the interweb think it does. FWIW if you do a DllCall("UxTheme.dll", "int", 135) beforehand you get something other than 0xFFFFFF00 (-256) when calling #137...
    1 point
  41. Thank you! You gave me the inspiration to get it working again. Regular calltips work but the ones for AutoItObject methods don't at the moment for all use cases.
    1 point
  42. I am so glad to hear that. The majority of the Defender "cloud" detections are done via machine learning anyway and they literally tag every compiled AutoIt script as malicious. So it's good to know that the one single setting is enough to resolve this type of issue for AutoIt users.
    1 point
  43. GUICtrlCreateMenu() is part of AutoIt _GUICtrlMenu_CreateMenu() is part of a UDF You would use the UDF implementation if you could use the features from the UDF.
    1 point
  44. I was able to compile an example script and Defender promptly deleted the compiled script. πŸ™„ Then I had an epiphany about the resource. It was the icon! I took that out and it compile fine. Of course, Defender did its due diligence. Any suggestions for how to work around that? Is there a thread here I should read that covers it? I obviously haven't looked yet. Regardless, thanks for the help!
    1 point
  45. I didn't know if to "Like", "Haha" or "Thanks" your post But this I know: is thanks to people like you, going at it ( whatever it is ), that we have so many features in AutoIt. And for that, I thank you πŸ’―
    1 point
  46. "OrdoWebview2 is an ActiveX control (32bits ocx) developed to replace the aging VB6 webview control based on a deprecated Internet Explorer !" You'd have to take the complain to the coder of the OCX πŸ€·β€β™‚οΈ
    1 point
  47. 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&amp;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 Forums
    1 point
  48. different approach, for 'exclusive mode' #AutoIt3Wrapper_UseX64=Y #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include "GUIListViewEx.au3" #include <MsgBoxConstants.au3> #include <Array.au3> #include <GuiMenu.au3> #include <GuiListView.au3> #include <EditConstants.au3> Opt("GUIOnEventMode", 1) Global $g_hGUI1, $g_hGUI2, $g_idButton1, $g_idButton2, $g_idButton3 Global $hListViewDatascope, $hDatabaseScope, $Button1, $Button2 ;a utiliser pour l'affichage de la 2eme fenetre Global $iEditMode = 0 gui1() Func gui1() $g_hGUI1 = GUICreate("GUI 1", 200, 200, 100, 100) GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function $g_idButton1 = GUICtrlCreateButton("Msgbox 1", 10, 10, 80, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton2 = GUICtrlCreateButton("Show GUI 2", 10, 60, 80, 30) GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton3 = GUICtrlCreateButton("Traitement", 10, 100, 80, 30) GUICtrlSetOnEvent(-1, "Traitement_intermediaire") ; Call a traitement GUISetState() While 1 Sleep(10) WEnd EndFunc ;==>gui1 Func gui2() ; exclusive mode GUICtrlSetState($g_idButton2, $GUI_DISABLE) Opt("GUIOnEventMode", 0) ; when in $g_hGUI2 - disable <<<<<<<<<<<<<<< $g_hGUI2 = GUICreate("GUI 2", 500, 500) ;~ GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ; Call a common GUI close function $g_idButton3 = GUICtrlCreateButton("GoOn", 10, 450, 100, 30) ;~ GUICtrlSetOnEvent(-1, "On_Button") ; Call a common button function $g_idButton4 = GUICtrlCreateButton("Cancel", 250, 450, 100, 30) ;~ GUICtrlSetOnEvent(-1, "On_Close") ; Call a common button function $hListViewDatascope = GUICtrlCreateListView("Tom|Dick|Harry", 10, 10, 400, 400, $LVS_SHOWSELALWAYS) _GUICtrlListView_SetExtendedListViewStyle($hListViewDatascope, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_CHECKBOXES)) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 0, 93) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 1, 93) _GUICtrlListView_SetColumnWidth($hListViewDatascope, 2, 93) ; Set font GUICtrlSetFont($hListViewDatascope, 12, Default, Default, "Courier New") ; Note edit control will use same font ; Create array and fill listview Global $aLV_List[20] For $i = 0 To UBound($aLV_List) - 1 If Mod($i, 5) Then $aLV_List[$i] = "Tom " & $i & "|Dick " & $i & "|Harry " & $i Else $aLV_List[$i] = "Tom " & $i & "||Harry " & $i EndIf GUICtrlCreateListViewItem($aLV_List[$i], $hListViewDatascope) Next ;_GUIListViewEx_Init($hLV, $aArray = "", $iStart = 0, $iColour = 0, $fImage = False, $iAdded = 0) $iLVIndex_1 = _GUIListViewEx_Init($hListViewDatascope, $aLV_List, 0, 0, True, +1 + 4) ; Tri & modification possible ;_GUIListViewEx_SetEditStatus($iLV_Index, $vCol, $iMode = 1, $vParam1 = Default, $vParam2 = Default) _GUIListViewEx_SetEditStatus($iLVIndex_1, "1;2") ;modification des colonnes 1 & 2 _GUIListViewEx_SetActive($iLVIndex_1) ; Enregistrement des messages Windows _GUIListViewEx_MsgRegister(Default) GUIRegisterMsg($WM_NOTIFY, "_Events_WM_NOTIFY") GUISetState() Local $aMsg = 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) 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 <<<<<<<<<<<<<<< EndFunc ;==>gui2 Func On_Close() Switch @GUI_WinHandle ; See which GUI sent the CLOSE message Case $g_hGUI1 Exit ; If it was this GUI - we exit <<<<<<<<<<<<<<< ;~ Case $g_hGUI2 ;~ GUIDelete($g_hGUI2) ; If it was this GUI - we just delete the GUI <<<<<<<<<<<<<<< EndSwitch EndFunc ;==>On_Close ;~ Func Off_Button() ;~ On_Close() ;~ EndFunc ;==>Off_Button Func On_Button() Switch @GUI_CtrlId ; See which button sent the message Case $g_idButton1 MessageBox(1) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<< Case $g_idButton2 gui2() ;~ Case $g_idButton3 ;~ MessageBox(2) ; We can call a function with parameters here <<<<<<<<<<<<<<<<<<< EndSwitch EndFunc ;==>On_Button Func MessageBox($iIndex) MsgBox($MB_OK, "MsgBox " & $iIndex, "Test from Gui " & $iIndex) EndFunc ;==>MessageBox Func Traitement_intermediaire() gui2() ; display the listview MsgBox(0, "Suite", "cela continue") ;suite du script ;.... EndFunc ;==>Traitement_intermediaire Func _Events_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) #forceref $hWnd, $Msg, $wParam, $lParam _GUIListViewEx_WM_NOTIFY_Handler($hWnd, $Msg, $wParam, $lParam) Local $tInfo, $Code $tInfo = DllStructCreate($tagNMHDR, $lParam) $hWnd = HWnd(DllStructGetData($tInfo, "hWndFrom")) $Code = DllStructGetData($tInfo, "Code") $hWnd_ListViewDatascope = GUICtrlGetHandle($hListViewDatascope) If $hWnd = $hWnd_ListViewDatascope Then Switch $Code Case $NM_DBLCLK ; Double-clic sur un 鬩ment de la ListView Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $lParam) Local $iIndex = DllStructGetData($tInfo, "Index") ; indique le numero de ligne Local $iSubItem = DllStructGetData($tInfo, "SubItem") ;indique le numero de colonne Local $sText = _GUICtrlListView_GetItemText($hListViewDatascope, $iIndex, $iSubItem) $vRet = _GUIListViewEx_EventMonitor($iEditMode) MsgBox(0, "valeur click", "$iSubItem :" & $iSubItem & @CRLF & "$iIndex:" & $iIndex & @CRLF & "$sText:" & $sText & @CRLF & $vRet & @CRLF & "ret:&$ret") ;&@CRLF&"$hEdit:"&$hEdit) Case $NM_RCLICK ; right button Local $aSelected = _GUICtrlListView_GetSelectedIndices($hWnd, True) If $aSelected[0] > 0 Then MsgBox(0, "test", "Right Button") EndIf EndSwitch Return $GUI_RUNDEFMSG ; EndIf ; Must be LAST line of the handler Return (_GUIListViewEx_WM_NOTIFY_Handler($hWnd, $Msg, $wParam, $lParam)) EndFunc ;==>_Events_WM_NOTIFY
    1 point
  49. After few hours on TinyMp3Player study, i have add music bar with success After Mp3SearchEngine, TinyMp3Player help me a lot. U have my eternal gratitude for that ^^ my unfinished dev version looks like that now :
    1 point
  50. #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include <StaticConstants.au3> #include <WindowsConstants.au3> Global $UserNameInputGUI Global $Answer = _MsgBox() ; Or $Answer = _MsgBox($UserNameInputGUI) MsgBox(0, "What was Returned!", $Answer) Func _MsgBox($Handle = $UserNameInputGUI) ; <<<<< $UserNameInputGUI can be a Global Variable or you can pass it to the Function when it's called! Local $GUI, $ButtonNo, $ButtonYes $GUI = GUICreate("PLEASE VERIFY", 600, 270, -1, -1, 0, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE)) GUICtrlCreateLabel("Is the User Info typed correctly?", 80, 16, 468, 33, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlCreateLabel("User Name:", 80, 65, 196, 33, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlCreateLabel("", 283, 65, 284, 33, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateLabel("AD Logon Account:", 80, 108, 196, 33, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x000000) GUICtrlCreateLabel("", 283, 108, 284, 33, $SS_CENTERIMAGE) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) $ButtonYes = GUICtrlCreateButton("Yes", 136, 168, 123, 41, $WS_GROUP) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") $ButtonNo = GUICtrlCreateButton("No", 311, 167, 123, 41, $WS_GROUP) GUICtrlSetFont(-1, 14, 800, 0, "MS Sans Serif") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $ButtonYes GUIDelete($GUI) Return 1 Case $ButtonNo GUIDelete($GUI) GUISetState(@SW_SHOW, $Handle) Return 0 EndSwitch WEnd EndFunc ;==>_MsgBox But I would recommend looking at Melba23's post again, because he has a brilliant MsgBox UDF which has many custom options!
    1 point
×
×
  • Create New...