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 Dan_555 and robertocm 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 November 11 Posted November 11 (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 November 11 by FadeSoft
WildByDesign Posted November 13 Posted November 13 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
argumentum Posted December 2 Posted December 2 How do you translate "Desktop" to the user's language ? #include <WinAPIRes.au3> Exit ConsoleWrite(@CRLF & '>' & _LoadString_shell32(4162) & '<' & @CRLF & @CRLF) Func _LoadString_shell32($iID) ; 4162 = "Desktop" Local $sText = "", $hInstance = _WinAPI_LoadLibraryEx("shell32.dll", $LOAD_LIBRARY_AS_DATAFILE) If $hInstance Then $sText = _WinAPI_LoadString($hInstance, $iID) _WinAPI_FreeLibrary($hInstance) EndIf Return SetError(@error, @extended, $sText) EndFunc ;==>_LoadString_shell32 If your GUI is simple, you may just find all the strings you use in shell32.dll ioa747, CYCho and TheDcoder 2 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Nine Posted Monday at 05:49 PM Posted Monday at 05:49 PM (edited) Here a generic reader of any WMI class : expandcollapse popup;#RequireAdmin ;#AutoIt3Wrapper_UseX64=y #include <Constants.au3> #include <Array.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> ; #GenericRead# ==================================================================================================================== ; Name ..........: GenericRead.AU3 ; Description ...: Lists properties and objects generically from any WMI Class ; Author ........: Nine ; Created .......: 2025-12-08 ; Modified ......: ; Remarks .......: if MsgBox is too large to fit the screen, you can use mouse wheel to scroll up/down, left to top, right to bottom ; ================================================================================================================================== Opt("MustDeclareVars", True) Global Const $tagMOUSEHOOKSTRUCT = $tagPOINT & ";hwnd hwnd;uint wHitTestCode;ulong_ptr dwExtraInfo;dword mouseData;" Global $oHandler = ObjEvent("AutoIt.Error", ErrFunc) Global $hHook ;ReadClass ("Win32_Service") ;ReadClass("MSFT_PhysicalDisk", Default, Default, "\root\Microsoft\Windows\Storage") ReadClass("WMIMonitorID", Default, Default, "\root\wmi") Func ReadClass($sClass, $sProp = "*", $sWhere = "", $sNameSpace = "\root\CIMV2") If $sProp = Default Then $sProp = "*" If $sWhere = Default Then $sWhere = "" If $sNameSpace = Default Then $sNameSpace = "\root\CIMV2" Local $oWMIService = ObjGet("winmgmts:\\" & @ComputerName & $sNameSpace) Local $oItems = $oWMIService.ExecQuery('SELECT ' & $sProp & ' FROM ' & $sClass & ($sWhere <> "" ? ' WHERE ' & $sWhere : "")) If Not IsObj($oItems) Then Exit MsgBox($MB_OK, "Error", "Not an object") If Not $oItems.count Then Exit MsgBox($MB_OK, "Error", "Not found") Local $hStub = DllCallbackRegister(WH_MOUSE, "LRESULT", "int;wparam;lparam") $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE, DllCallbackGetPtr($hStub), 0, _WinAPI_GetCurrentThreadId()) Local $sList, $sProperty, $bFirst, $aTmp, $iCount = 0 For $oItem In $oItems $iCount += 1 $bFirst = True For $oProperty In $oItem.Properties_ If $bFirst Then $sList = "Origin = " & $oProperty.origin & @CRLF $bFirst = False EndIf If IsArray($oProperty.Value) Then $aTmp = $oProperty.Value $sProperty = _ArrayToString($aTmp) Else $sProperty = $oProperty.Value EndIf $sList &= $oProperty.Name & " = " & $sProperty & @CRLF Next If MsgBox($MB_OKCANCEL, $iCount & "/" & $oItems.count, $sList) = $IDCANCEL Then ExitLoop Next _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hStub) EndFunc ;==>ReadClass Func WH_MOUSE($iMsg, $wParam, $lParam) If $iMsg Then Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam) Local $tMouse = DllStructCreate($tagMOUSEHOOKSTRUCT, $lParam) Local $hWnd = _WinAPI_GetAncestor($tMouse.hwnd, $GA_ROOT) If $wParam = $WM_MOUSEWHEEL Then Local $iDir = _WinAPI_HiWord($tMouse.mouseData) WinMove($hWnd, "", WinGetPos($hWnd)[0], WinGetPos($hWnd)[1] + ($iDir / 3)) ElseIf $wParam = $WM_LBUTTONDOWN Then If $tMouse.hwnd = $hWnd Then WinMove($hWnd, "", WinGetPos($hWnd)[0], 0) ElseIf $wParam = $WM_RBUTTONDOWN Then WinMove($hWnd, "", WinGetPos($hWnd)[0], @DesktopHeight - WinGetPos($hWnd)[3] - 50) EndIf Return _WinAPI_CallNextHookEx($hHook, $iMsg, $wParam, $lParam) EndFunc ;==>WH_MOUSE Func ErrFunc($oError) ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> Global COM error handler - COM Error intercepted !" & @CRLF & _ @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & "/" & $oError.number & @CRLF & _ @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _ @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _ @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _ @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _ @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _ @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _ @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _ @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF) EndFunc ;==>ErrFunc Edited Monday at 07:10 PM by Nine ioa747 and WildByDesign 2 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
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