MattyD Posted October 10 Posted October 10 well, to be fair the win8 part is based on nothing - I doubt we even had dark mode back then... but yep, certainly it could just be a busted func. Especially if the others work as expected.
ioa747 Posted October 15 Posted October 15 (edited) 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 expandcollapse popup; 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 Edited October 15 by ioa747 prettify robertocm and Dan_555 2 I know that I know nothing
wakillon Posted October 28 Posted October 28 (edited) Trick for display your favorite directories in FileSaveDialog and FileOpenDialog with Win 11 The favorite directories are set in registry to : HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32\Placesbar Example of Placesbar Reg File Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\comdlg32\Placesbar] "Place1"="C:\\" "Place2"="C:\\Program Files (x86)\\AutoIt3\\Include" "Place4"="D:\\" "Place0"=dword:00000011 "Place3"=dword:00000010 11 is "My Computer" and 10 the Desktop #Region ;************ Includes ************ #Include <WinAPITheme.au3> #EndRegion ;************ Includes ************ $hGui = GUICreate('', 500, 500) GUISetState() ; Default display FileSaveDialog('Save file', @WorkingDir, 'Scripts (*.au3)', $FD_PATHMUSTEXIST, '', $hGui) ; ; Display with PlacesBar _WinAPI_SetThemeAppProperties($STAP_ALLOW_NONCLIENT) FileSaveDialog('Save file', @WorkingDir, 'Scripts (*.au3)', $FD_PATHMUSTEXIST, '', $hGui) FileOpenDialog('Select a file', @WorkingDir & '\', 'Images (*.jpg;*.bmp)', $FD_FILEMUSTEXIST, '', $hGui) ; ; Reset default display _WinAPI_SetThemeAppProperties(-1) FileSaveDialog('Save file', @WorkingDir, 'Scripts (*.au3)', $FD_PATHMUSTEXIST, '', $hGui) GUIDelete($hGui) Exit Edited October 28 by wakillon argumentum and ioa747 2 AutoIt 3.3.18.0 X86 - SciTE 5.5.7 - WIN 11 24H2 X64 - Other Examples Scripts
FadeSoft Posted Tuesday at 05:11 AM Posted Tuesday at 05:11 AM (edited) Windows Efficiency Killer, makes every attempt to try and stop it from activating again! #RequireAdmin #include <MsgBoxConstants.au3> Local $sPSCmd = "Get-Process | ForEach-Object {" & _ " try {" & _ " $_.PriorityClass = 'Normal';" & _ " Write-Host ('Set normal priority for ' + $_.ProcessName)" & _ " } catch {" & _ " Write-Host ('Failed to change ' + $_.ProcessName + ': ' + $_.Exception.Message)" & _ " }" & _ " }" Local $sCmd = 'powershell -NoProfile -ExecutionPolicy Bypass -Command "' & StringReplace($sPSCmd, '"', '\"') & '"' RunWait('powercfg /setactive SCHEME_MIN', "", @SW_HIDE) RunWait(@ComSpec & " /c " & $sCmd, "", @SW_HIDE) RegWrite("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power", "PowerThrottlingOff", "REG_DWORD", 1) MsgBox($MB_ICONINFORMATION, "Efficiency Mode", "All processes set to Normal priority (Efficiency Mode disabled).") Edited Tuesday at 05:12 AM by FadeSoft
WildByDesign Posted yesterday at 04:46 PM Posted yesterday at 04:46 PM System Tray Menu Auto-Light/Dark Mode: If your system theme is a light mode theme, it will make the system tray menu light. Dark theme will show dark tray menu. I used to apply dark mode to the system tray menu before by creating a GUI that was never shown. But now I realized that I don't have to create that GUI and simply get the handle for the hidden AutoIt window and apply to that handle. expandcollapse popup#NoTrayIcon #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <TrayConstants.au3> #include <SendMessage.au3> #include <WindowsNotifsConstants.au3> Global $hTray = _GetHwndFromPID(@AutoItPID) Global $bIsDarkMode = _WinAPI_ShouldAppsUseDarkMode() ; DPI Awareness DllCall("User32.dll", "bool", "SetProcessDpiAwarenessContext" , "HWND", "DPI_AWARENESS_CONTEXT" -2) Opt("TrayMenuMode", 3) Example() Func Example() ; Create a tray item with the radio item parameter selected. TrayCreateItem("Radio 1", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetState(-1, $TRAY_CHECKED) TrayCreateItem("Radio 2", -1, -1, $TRAY_ITEM_RADIO) TrayCreateItem("Radio 3", -1, -1, $TRAY_ITEM_RADIO) TrayCreateItem("") ; Create a separator line. Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. If $bIsDarkMode Then DarkMode($hTray, True) While 1 Switch TrayGetMsg() Case $idExit ; Exit the loop. ExitLoop EndSwitch WEnd EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- ; https://www.autoitscript.com/forum/topic/211475-darkmode-udf-for-autoits-win32guis/#comment-1530103 ;-------------------------------------------------------------------------------------------------------------------------------- Func DarkMode($hWnd, $bDarkMode = True) ; DarkMode Local Enum $DWMWA_USE_IMMERSIVE_DARK_MODE = (@OSBuild <= 18985) ? 19 : 20 Local $iRet = _WinAPI_DwmSetWindowAttribute_unr($hWnd, $DWMWA_USE_IMMERSIVE_DARK_MODE, $bDarkMode) If Not $iRet Then Return SetError(1, 0, -1) _SetCtrlColorMode($hWnd, $bDarkMode) EndFunc ;==>DarkMode ;-------------------------------------------------------------------------------------------------------------------------------- Func _SetCtrlColorMode($hWnd, $bDarkMode = True, $sName = Default) ; 'Explorer', 'CFD', 'DarkMode_ItemsView', etc. If $sName = Default Then $sName = $bDarkMode ? 'DarkMode_Explorer' : 'Explorer' $bDarkMode = Not Not $bDarkMode ; https://www.vbforums.com/showthread.php?900444-Windows-10-Dark-Mode-amp-VB6-apps If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local Enum $eDefault, $eAllowDark, $eForceDark, $eForceLight, $eMax ; enum PreferredAppMode DllCall('uxtheme.dll', 'bool', 133, 'hwnd', $hWnd, 'bool', $bDarkMode) ; fnAllowDarkModeForWindow = 133 DllCall('uxtheme.dll', 'int', 135, 'int', ($bDarkMode ? $eForceDark : $eForceLight)) ; fnAllowDarkModeForApp = 135 _WinAPI_SetWindowTheme_unr($hWnd, $sName) ; https://www.autoitscript.com/forum/index.php?showtopic=211475&view=findpost&p=1530103 DllCall('uxtheme.dll', 'none', 104) ; fnRefreshImmersiveColorPolicyState = 104 ; not needed ? _SendMessage($hWnd, $WM_THEMECHANGED, 0, 0) ; not needed ? EndFunc ;==>_SetCtrlColorMode ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_SetWindowTheme_unr($hWnd, $sName = Null, $sList = Null) ; #include <WinAPITheme.au3> ; unthoughtful unrestricting mod. ;Causes a window to use a different set of visual style information than its class normally uses Local $sResult = DllCall('UxTheme.dll', 'long', 'SetWindowTheme', 'hwnd', $hWnd, 'wstr', $sName, 'wstr', $sList) If @error Then Return SetError(@error, @extended, 0) If $sResult[0] Then Return SetError(10, $sResult[0], 0) Return 1 EndFunc ;==>_WinAPI_SetWindowTheme_unr ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_DwmSetWindowAttribute_unr($hWnd, $iAttribute, $iData) ; #include <WinAPIGdi.au3> ; unthoughtful unrestricting mod. ;Sets the value of the specified attributes for non-client rendering to apply to the window Local $aCall = DllCall('dwmapi.dll', 'long', 'DwmSetWindowAttribute', 'hwnd', $hWnd, 'dword', $iAttribute, _ 'dword*', $iData, 'dword', 4) If @error Then Return SetError(@error, @extended, 0) If $aCall[0] Then Return SetError(10, $aCall[0], 0) Return 1 EndFunc ;==>_WinAPI_DwmSetWindowAttribute_unr ;-------------------------------------------------------------------------------------------------------------------------------- Func _WinAPI_ShouldAppsUseDarkMode() Local $fnShouldAppsUseDarkMode = 132 Local $aResult = DllCall('UxTheme.dll', 'bool', $fnShouldAppsUseDarkMode) If @error Then Return SetError(@error, @extended, False) Return $aResult[0] EndFunc ;==>_WinAPI_ShouldAppsUseDarkMode ;-------------------------------------------------------------------------------------------------------------------------------- ; Function for getting HWND from PID Func _GetHwndFromPID($PID) $hWnd = 0 $winlist = WinList() For $i = 1 To $winlist[0][0] If $winlist[$i][0] <> "" Then $iPID2 = WinGetProcess($winlist[$i][1]) If $iPID2 = $PID Then $hWnd = $winlist[$i][1] ExitLoop EndIf EndIf Next Return $hWnd EndFunc ;==>_GetHwndFromPID ioa747 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now