Leaderboard
Popular Content
Showing content with the highest reputation on 07/15/2025 in all areas
-
It provides one of the WorkerW handles, not the WorkerW handle under Progman. 😉 This works for me: ;Code by UEZ build 2025-07-16 beta #include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hProgman = WinGetHandle("[CLASS:Progman]"), $hWorkerW, $i $i = 1 While True $h = WinGetHandle("[CLASS:WorkerW;INSTANCE:" & $i & "]") $hWorkerW = _WinAPI_FindWindowEx($hProgman, $h, "WorkerW", "") If $hWorkerW Then ExitLoop $i += 1 If $i = 100 Then Exit MsgBox(16, "ERROR", "Couldn't find WorkerW under Progman", 30) WEnd Global $SWP = BitOR($SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE) $hGUI = GUICreate("Overlay", 400, 300, 10, 10, $WS_POPUP, $WS_EX_TOOLWINDOW) GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 400, 300) _WinAPI_SetParent($hGUI, $hWorkerW) _WinAPI_SetWindowPos($hGUI, $HWND_BOTTOM, 0,0,0,0, $SWP) _WinAPI_SetWindowLong($hGUI, $GWL_EXSTYLE, BitOR(_WinAPI_GetWindowLong($hGUI, $GWL_EXSTYLE), $WS_EX_LAYERED, $WS_EX_TRANSPARENT)) _WinAPI_SetLayeredWindowAttributes($hGUI, 0, 220, $LWA_ALPHA) GUISetState(@SW_SHOWNOACTIVATE, $hGUI) While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd 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] EndFunc2 points
-
Move window behind desktop icons
argumentum and one other reacted to Parsix for a topic
Programming is a problem-solving challenge. Exactly as in the example, I need to display an image under the desktop icons, unfortunately the icons are placed under the application and cause user objections. This image could be a local calendar display. The idea of producing a unified background as suggested by "KaFu" was my first alternative solution, but I am looking for a solution to the problem as much as possible. For example, until some time ago, the code sample that "Nine" shared with the title "Create an Application Bar recognized by the system" was perhaps impossible. Nine, that code sample was very usefull, thank you very much for that code. 🥰 I did not even see a standard function or solution for sending the application to the lowest display layer, such as the functions that keep the application in the highest display layer. I'm just wondering why UEZ hasn't commented yet ?! He usually comes in with something magical like Superman.🤩😁2 points -
Move window behind desktop icons
WildByDesign reacted to argumentum for a topic
1 point -
I've come this far, I'm struggling to figure out how to set the transparency. Testet in Win10 22H2 #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WinAPISysInternals.au3> #include <WindowsConstants.au3> ; Getting the right WorkerW window Global $hWorkerW = _FindWorkerW_WithStyles() ConsoleWrite("$hWorkerW=" & $hWorkerW & @CRLF) If Not $hWorkerW Then Exit ConsoleWrite("! Error Could not find WorkerW window." & @CRLF) Main() Func Main() Local $this = GUICreate("", 400, 400, @DesktopWidth - (400) - 20, 100, $WS_POPUP, $WS_EX_NOACTIVATE) ;~ WinSetTrans($this, "", 200) ; not working GUISetBkColor(0x000000) Local $iPic = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 0, 0) GUISetState(@SW_SHOW) ; Changes the parent window _WinAPI_SetParent($this, $hWorkerW) WinSetTrans($this, "", 100) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($this) EndFunc ;==>Main Func _FindWorkerW_WithStyles($iWidth = @DesktopWidth, $iHeight = @DesktopHeight) ; Getting the right WorkerW window with criteria ; size: 1920, 1080 ; visible: Yes ; style: Popup,Tool Window,Transparent Local $aList = WinList("[CLASS:WorkerW]") For $i = 1 To $aList[0][0] Local $hWnd = $aList[$i][1] If Not IsHWnd($hWnd) Then ContinueLoop ; Get visibility If Not BitAND(WinGetState($hWnd), 2) Then ContinueLoop ; Get position and size Local $aPos = WinGetPos($hWnd) If @error Then ContinueLoop If $aPos[2] <> $iWidth Or $aPos[3] <> $iHeight Then ContinueLoop ; Get styles Local $nStyle = _WinAPI_GetWindowLong($hWnd, $GWL_STYLE) ; $GWL_STYLE Local $nExStyle = _WinAPI_GetWindowLong($hWnd, $GWL_EXSTYLE) ; $GWL_EXSTYLE ; Check for required style flags If BitAND($nStyle, $WS_POPUP) = $WS_POPUP _ And BitAND($nExStyle, $WS_EX_TOOLWINDOW) = $WS_EX_TOOLWINDOW _ And BitAND($nExStyle, $WS_EX_TRANSPARENT) = $WS_EX_TRANSPARENT Then Return $hWnd EndIf Next Return 0 ; Not found EndFunc ;==>_FindWorkerW_WithStyles1 point
-
Suggested modification to ArrayDisplayInternals.au3
argumentum reacted to Tippex for a topic
I agree, thank you. Your patch was necessary to facilitate an easy way to close multiple ArrayDisplays in bulk, should the need arise. Attached are the patched replacements. beta_v3.3.17.1_ArrayDisplayInternals.au3 ArrayDisplayInternals.au31 point -
Move window behind desktop icons
Parsix reacted to WildByDesign for a topic
This script is awesome. Especially the WinGetDesktopHandle function. Magical!1 point -
Move window behind desktop icons
Parsix reacted to argumentum for a topic
@Parsix, what @Nine said is what programs that show PC info do. What do you wanna do ?. The more explicit the better ( interact with it ?, just show info ? ).1 point -
The code I posted above makes the GUI a child of the desktop (sticky) and even allows a click-through on the Icons (tested on Win10 and Win11). Maybe make it 99% transparent and additionally use a wall paper for the background design?1 point
-
DwmColorBlurMica
argumentum reacted to WildByDesign for a topic
I just updated the first post with version 1.0.4. I've finally got the GUI included in this release. This release requires a new configuration file because I added a new Enabled boolean option for each custom rule. Now custom rules can simply be enabled/disabled without having to delete them from the configuration completely. Changes are applied immediately after clicking the Save button so that you can see the changes right away. I still have a few minor DPI control fixes to do. I haven't added the process exclusions or class exclusions to the GUI yet and I'm not 100% sure if I will or not. Those can still be modified in the config file. Important: All custom rules are included but are not enabled by default. Some people don't like surprises and some of those custom rules may not work for all environments. So users can enable/disable custom rules depending on what suits them. By default, the configuration only enables global dark titlebar and global border color. Screenshot (background reacts depending on wallpaper):1 point -
AFAIK, only way to put something behind the desktop icons is called wall paper. You could assemble the wall paper that you wish to (with GDI+, containing multiple images), save it to file, set it as WallPaper.1 point
-
Move window behind desktop icons
Parsix reacted to argumentum for a topic
...back in the day, when I was young, ... I remember been able to make my GUI a child GUI of the desktop. Like embedding it into the desktop. It was interesting. But, bye-bye win32, hello ...something else. Hence the "why, oh why" of the OP.🤷♂️1 point -
I think it's technically impossible to move a program window behind the desktop icons: The Windows desktop, including the icons placed on it, is the "most-background-layer" of the Windows GUI. If you want to just see the desktop icons, make the program window transparent. Help File: "WinSetTrans"1 point
-
Running script at startup on Windows 11?
argumentum reacted to rudi for a topic
Just an idea: Put a CMD script to the startup folder, launching your AU3 script, followed by a "pause" to see, if the CMD script is launched correcly from startup (or common startup)1 point -
Suggested modification to ArrayDisplayInternals.au3
argumentum reacted to Tippex for a topic
I agree, thank you. Your patch is necessary to automatically remove left over "AutoIt v3 Script (32 bit)" remnants (visible in Task Manager) if an AutoIT script is closed from the system tray. The problem exists in the unmodified ArrayDisplayInternals.au3 even in AutoIT v3.3.17.1 (beta). Attached are the patched replacements.1 point -
Move window behind desktop icons
WildByDesign reacted to KaFu for a topic
This works on my Win10 machine. #include <GUIConstantsEx.au3> #include <WinApi.au3> #include <WindowsConstants.au3> Global $hDeskWin = _WinGetDesktopHandle() Global $h_Desktop_SysListView32 = HWnd(@extended) Main() Func Main() Local $this = GUICreate("", 400, 400, @DesktopWidth - (400) - 20, 100, $WS_POPUP, $WS_EX_NOACTIVATE + $WS_EX_TRANSPARENT) _WinAPI_SetParent($this, $h_Desktop_SysListView32) Local $iPic = GUICtrlCreatePic("C:\Program Files (x86)\AutoIt3\Examples\GUI\msoobe.jpg", 0, 0, 400, 400) ;GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) WinSetTrans($this, "", 200) _GuiRoundCorners($this, 16, 16) _WinAPI_SetWindowLong($this, $GWL_HWNDPARENT, ControlGetHandle("[CLASS:Progman]", "", "SysListView321")) ;hide in taskbar GUISetState(@SW_SHOWNOACTIVATE, $this) ;_WinAPI_SetWindowPos($this, $HWND_BOTTOM, Default, Default, Default, Default, BitOR($SWP_NOACTIVATE, $SWP_SHOWWINDOW, $SWP_NOMOVE, $SWP_NOSIZE )) ;not worked While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($this) EndFunc ;==>Main Func _GuiRoundCorners($h_win, $ixR, $iyR) Local $aPos = WinGetPos($h_win) If @error Then Return 0 Local $iW = $aPos[2] Local $iH = $aPos[3] Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $iW, $iH, $ixR, $iyR) _WinAPI_SetWindowRgn($h_win, $hRgn) EndFunc ;==>_GuiRoundCorners ; http://www.autoitscript.com/forum/topic/119783-desktop-class-workerw/page__view__findpost__p__903081 ; =============================================================================================================================== ; <_WinGetDesktopHandle.au3> ; ; Function to get the Windows' Desktop Handle. ; Since this is no longer a simple '[CLASS:Progman]' on Aero-enabled desktops, this method uses a slightly ; more involved method to find the correct Desktop Handle. ; ; Author: Ascend4nt, credits to Valik for pointing out the Parent->Child relationship: Desktop->'SHELLDLL_DefView' ; =============================================================================================================================== ; Example use: #cs #include <GuiListView.au3> $iTimer = TimerInit() $hDeskWin = _WinGetDesktopHandle() $hListView = HWnd(@extended) ConsoleWrite("Time elapsed:" & TimerDiff($iTimer) & " ms" & @CRLF) $iDeskItems = _GUICtrlListView_GetItemCount($hListView) ConsoleWrite("Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "', Handle to Listview: " & $hListView & ", # Items:" & $iDeskItems & ", Title: " & WinGetTitle($hListView) & @CRLF) MsgBox(0, "Desktop handle (with ListView) found", "Handle to desktop: " & $hDeskWin & ", Title: '" & WinGetTitle($hDeskWin) & "'," & @CRLF & "Handle to Listview: " & $hListView & @CRLF & "# Desktop Items:" & $iDeskItems) #ce Func _WinGetDesktopHandle() Local $i, $hDeskWin, $hSHELLDLL_DefView, $hListView ; The traditional Windows Classname for the Desktop, not always so on newer O/S's $hDeskWin = WinGetHandle("[CLASS:Progman]") ; Parent->Child relationship: Desktop->SHELLDLL_DefView $hSHELLDLL_DefView = ControlGetHandle($hDeskWin, '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') ; No luck with finding the Desktop and/or child? If $hDeskWin = '' Or $hSHELLDLL_DefView = '' Then ; Look through a list of WorkerW windows - one will be the Desktop on Windows 7+ O/S's $aWinList = WinList("[CLASS:WorkerW]") For $i = 1 To $aWinList[0][0] $hSHELLDLL_DefView = ControlGetHandle($aWinList[$i][1], '', '[CLASS:SHELLDLL_DefView; INSTANCE:1]') If $hSHELLDLL_DefView <> '' Then $hDeskWin = $aWinList[$i][1] ExitLoop EndIf Next EndIf ; Parent->Child relationship: Desktop->SHELDLL_DefView->SysListView32 $hListView = ControlGetHandle($hSHELLDLL_DefView, '', '[CLASS:SysListView32; INSTANCE:1]') If $hListView = '' Then Return SetError(-1, 0, '') Return SetExtended($hListView, $hDeskWin) EndFunc ;==>_WinGetDesktopHandle1 point -
Thanks for that Gianni I've amended the instructions. Its interesting that x86 is broken, I'll have to have a look at that at some stage! A new test script is now up there, "WindowTest.au3" should be the only modified file. There's just some initial attempts at handling window messages for the main window.1 point
-
@argumentum It’s not easy to learn something new. It sound like when you say, “go learn something else” — AutoIt was primarily designed for automation tasks like mouse clicking, and nothing more. Maybe @trancexx, @ProgAndy, @LarsJ, @Ward, and the rest who tried to take AutoIt beyond simple mouse clicks have wasted their time. So, Is there any real value in using AutoIt for someone who already knows C, C++, Python......?1 point
-
the script uses CUIAutomation2.au3 UDF from https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/ Functions to interact with the taskbar. ; https://www.autoitscript.com/forum/topic/212266-functions-to-interact-with-the-taskbar/ ;---------------------------------------------------------------------------------------- ; Title...........: _TaskBar.au3 ; Description.....: Function to interact with the taskbar. ; AutoIt Version..: 3.3.16.1 Author: ioa747 Script Version: 2.0 ; Note............: Testet in Win10 22H2 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #NoTrayIcon #include ".Includes\CUIAutomation2.au3" ; * <- "https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/" #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WindowsConstants.au3> #include <Array.au3> Example() ;-------------------------------------------------------------------------------------------------------------------------------- Func Example() Local $aTBPos, $sTxt, $a ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from NotifyArea $sTxt &= "let's take the Everything program for example" & @CRLF $sTxt &= 'first we find the tray icon in NotifyArea' & @CRLF $sTxt &= '(NotifyArea = $iAreaId 2 )' & @CRLF & @CRLF $sTxt &= ' _TaskBar(2, "something not exist")' & @CRLF & @CRLF $sTxt &= '$sSearchString = "something not exist"' & @CRLF $sTxt &= 'to show us all the results' & @CRLF & @CRLF $sTxt &= 'the console only shows results when it doesn''t match' & @CRLF _Msg($sTxt) _TaskBar(2, "something not exist") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Double-click in NotifyArea $sTxt &= "now we know that the target icon " & @CRLF $sTxt &= "starts with the word 'Everything'" & @CRLF & @CRLF $sTxt &= "Now we can send Click, Right-click, or Double-click" & @CRLF & @CRLF $sTxt &= "send Double-click to tray icon" & @CRLF $sTxt &= "(Double-click = $iActionId 4 )" & @CRLF & @CRLF $sTxt &= ' _TaskBar(2, "Everything", 4)' & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(2, "Everything", 4) $a = $aTBPos[0][1] ConsoleWrite($aTBPos[0][1] & ", Rect: " & $a[0] & ", " & $a[1] & ", " & $a[2] & ", " & $a[3] & @CRLF) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= "now that the window has opened it created a new" & @CRLF $sTxt &= "icon down in the task bar to RunningApps area" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Right-click = $iActionId 3 )" & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Everything", 3, "{UP}{ENTER}")' & @CRLF & @CRLF $sTxt &= '$sOption = "{UP}{ENTER}"' & @CRLF $sTxt &= 'Right-click and Send' & @CRLF _Msg($sTxt) _TaskBar(1, "Everything", 3, "{UP}{ENTER}") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Everything' icon from NotifyArea" & @CRLF $sTxt &= "to OverflowNotifyArea" & @CRLF & @CRLF $sTxt &= '(NotifyArea = $iAreaId 2 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "OverflowButton" )' & @CRLF & @CRLF $sTxt &= '_TaskBar(2, "Everything", 5, "OverflowButton")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(2, "Everything", 5, "OverflowButton") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Everything' icon from OverflowNotifyArea" & @CRLF $sTxt &= "back to NotifyArea at old position" & @CRLF & @CRLF $sTxt &= '(OverflowNotifyArea = $iAreaId 3 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "X:" & $a[2] )' & @CRLF & @CRLF $sTxt &= '_TaskBar(3, "Everything", 5, "X:" & $a[2])' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(3, "Everything", 5, "X:" & $a[2]) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= 'Next step open Notepad' & @CRLF $sTxt &= 'Right-click on tray icon and Pin to taskbar' & @CRLF & @CRLF $sTxt &= 'Right-click and Send 2 UP && ENTER' & @CRLF $sTxt &= ' _TaskBar("Notepad -", 1, 3, "{UP 2}{ENTER}")' & @CRLF _Msg($sTxt) ShellExecute("notepad") WinWaitActive("[CLASS:Notepad]", "") _TaskBar(1, "Notepad -", 3, "{UP 2}{ENTER}") WinClose("[CLASS:Notepad]", "") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon 3 positions to the Left" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = -3 )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, -3)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, -3) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon 3 positions to the Right" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = 3 )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, 3)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, 3) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon at positions 0" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "index:0" )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, "index:0")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, "index:0") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Click&Drag operation $sTxt &= "now we move 'Notepad' icon at last positions" & @CRLF $sTxt &= "by using $sOption = X:n" & @CRLF & @CRLF $sTxt &= '(RunningAppsArea = $iAreaId 1 )' & @CRLF $sTxt &= "(Click&Drag = $iActionId 5 )" & @CRLF $sTxt &= '($sOption = "X:" & @DesktopWidth )' & @CRLF & @CRLF $sTxt &= '_TaskBar(1, "Notepad", 5, "X:" & @DesktopWidth)' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 5, "X:" & @DesktopWidth) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from RunningAppsArea $sTxt &= "at this step" & @CRLF $sTxt &= "we trap the Notepad pin with" & @CRLF $sTxt &= "($iActionId 1 = Get the button positions and label.)" & @CRLF & @CRLF $sTxt &= "move the mouse over the Notepad pin" & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(1, "Notepad", 1) $a = $aTBPos[0][1] Local $iMsgBoxAnswer, $bLoop = True While $bLoop If IsMouseOverRect($a) Then $iMsgBoxAnswer = MsgBox(292, "Rect: " & $a[0] & ", " & $a[1] & ", " & $a[2] & ", " & $a[3], "do you want to get out of the loop?") Select Case $iMsgBoxAnswer = 6 ;Yes $bLoop = False EndSelect EndIf Sleep(300) WEnd ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in RunningAppsArea $sTxt &= 'Now UnPin Notepad pin' & @CRLF $sTxt &= 'Right-click and Send UP & ENTER' & @CRLF $sTxt &= 'UnPin from taskbar' & @CRLF & @CRLF $sTxt &= ' _TaskBar(1, "Notepad -", 3, "{UP}{ENTER}")' & @CRLF & @CRLF $sTxt &= 'here attention if there is notepad++ taskpin, it unpin this' & @CRLF $sTxt &= 'because it is more forward and starts with word notepad' & @CRLF _Msg($sTxt) _TaskBar(1, "Notepad", 3, "{UP}{ENTER}") ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ; Right-click & send in OverflowNotifyArea $sTxt &= 'Now for (OverflowNotifyArea = $iAreaId 3 ) ' & @CRLF & @CRLF $sTxt &= ' Right-click and Send 5 UP on bluetooth' & @CRLF & @CRLF $sTxt &= ' _TaskBar(3, "bluetooth", 3, "{UP 5}")' & @CRLF & @CRLF _Msg($sTxt) _TaskBar(3, "bluetooth", 3, "{UP 5}") Sleep(5000) ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ $sTxt = "" ;Get information from RunningAppsArea $sTxt &= "or you can call only with the $iAreaId parameter," & @CRLF $sTxt &= "1 - Get the button positions and labels" & @CRLF $sTxt &= "and take the whole table for any use" & @CRLF & @CRLF $sTxt &= '$aTBPos = _TaskBar(1)' & @CRLF & @CRLF _Msg($sTxt) $aTBPos = _TaskBar(1) _ArrayDisplay($aTBPos) _Msg("Exit") EndFunc ;==>Example ;-------------------------------------------------------------------------------------------------------------------------------- Func _Msg($sMsg) Local $hGui = GUICreate("Msg", 395, 237, @DesktopWidth * 0.1, @DesktopHeight * 0.5, -1, BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) GUISetFont(11, 400, 0, "DejaVu Sans Condensed") GUICtrlCreateLabel($sMsg, 5, 10, 376, 181) Local $Button_OK = GUICtrlCreateButton("OK", 160, 200, 75, 25) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $Button_OK ExitLoop EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>_Msg ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: _TaskBar ; Description....: Function to interact with the taskbar. ; Syntax.........: _TaskBar ( $iAreaId = 1, $sSearchString = "@All", $iActionId = 1, $sOption = "", $sUserToolBarPar = "index:1" ) ; Parameters.....: $iAreaId - The ID of Area to interact with. Can be one of the following values: ; 1 - RunningAppsArea - Running applications. (Default) ; 2 - NotifyArea - Notification area. ; 3 - OverflowNotifyArea - Overflow Notification Area. ; $sSearchString - The string to search for in the button labels. Matches partial string from the start. (Default = "@All") ; $iActionId - The action to perform. Can be one of the following values: ; 1 - Get the button positions and labels. (Default) ; 2 - Click on a button with the specified label. ; 3 - Right-click on a button with the specified label. ; 4 - Double-click on a button with the specified label. ; 5 - Click&Drag a button with the specified label to specify X axis place ; $sOption - [optional] Additional parameter required by some commands. (Default = "") ; if $iActionId = 2, $sOption = "SendKeys" - Extra string to send after click. ; "{UP 2}{ENTER}" send 2 UP and ENTER to elect the specify menu ; if $iActionId = 3, $sOption = "SendKeys" - Extra string to send after click. ; "o" send o to select the open menu ; if $iActionId = 5, $sOption = "NumberToMove" - number of place to move, posive = Right, negative = Left ; "3" move button, 3 positions to the Right ; "-3" move button, 3 positions to the Left ; "index:3" move button, to positions 3 ; "X:300" move button, to X coordinate ; "OverflowButton" move button from NotifyArea, to OverflowNotifyArea and vice versa ; Return values..: Success - An 2D Array containing the rect positions of the button that match the search string. ; $a[i][0]=Label, $a[i][1]=$aRect Array | $aRect[0]=Left, $aRect[1]=Top, $aRect[2]=Right, $aRect[3]=Bottom. ; - if $sSearchString does not match, it returns 2D Array of all items. ; Failure - return error message if there is an error. ; Author.........: ioa747 ; Modified.......: ; Related .......: This function uses the CUIAutomation2.au3 "https://www.autoitscript.com/forum/topic/201683-ui-automation-udfs/" ; Link ..........: ;-------------------------------------------------------------------------------------------------------------------------------- Func _TaskBar($iAreaId = 1, $sSearchString = "@All", $iActionId = 1, $sOption = "") Local $hWndTray = WinGetHandle("[CLASS:Shell_TrayWnd]") ; Taskbar Local $hOverflowButton = ControlGetHandle($hWndTray, "", "Button2") Local $hToolbar Switch $iAreaId Case 1 ;RunningAppsArea Local $hRebar = ControlGetHandle($hWndTray, "", "[CLASS:ReBarWindow32]") Local $hMSTaskSwWClass = ControlGetHandle($hRebar, "", "[CLASS:MSTaskSwWClass]") $hToolbar = ControlGetHandle($hMSTaskSwWClass, "", "[CLASS:MSTaskListWClass]") Case 2 ;NotifyArea Local $hTrayNotify = ControlGetHandle($hWndTray, "", "[CLASS:TrayNotifyWnd]") Local $hSysPager = ControlGetHandle($hTrayNotify, "", "[CLASS:SysPager]") $hToolbar = ControlGetHandle($hSysPager, "", "ToolbarWindow321") Case 3 ;OverflowNotifyArea Local $hWndOverflow = WinGetHandle("[CLASS:NotifyIconOverflowWindow]") $hToolbar = ControlGetHandle($hWndOverflow, "", "ToolbarWindow321") Case Else Return _EW("wrong $iAreaId") EndSwitch ; https://www.autoitscript.com/forum/topic/133222-manipulate-system-tray-program-right-click-choose-option/page/2/#comment-1499538 ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface($sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation) If Not IsObj($oUIAutomation) Then Return _EW("$oUIAutomation ERR") ;ConsoleWrite("$oUIAutomation OK" & @CRLF) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement($pDesktop) $oDesktop = ObjCreateInterface($pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oDesktop) Then Return _EW("$oDesktop ERR") ;ConsoleWrite("$oDesktop OK" & @CRLF) ; Get element by handle Local $pElement, $oElement $oUIAutomation.ElementFromHandle($hToolbar, $pElement) $oElement = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) If Not IsObj($oElement) Then Return _EW("$oElement ERR") ;ConsoleWrite("$oElement OK" & @CRLF) ; Get condition (ControlType = Button) Local $pCondition, $oCondition $oUIAutomation.CreatePropertyCondition($UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition) $oCondition = ObjCreateInterface($pCondition, $sIID_IUIAutomationPropertyCondition, $dtagIUIAutomationPropertyCondition) If Not IsObj($oCondition) Then Return _EW("$oCondition ERR") ;ConsoleWrite("$oCondition OK" & @CRLF) ; Find all buttons Local $pElementArray, $oElementArray, $iElements $oElement.FindAll($TreeScope_Children, $oCondition, $pElementArray) $oElementArray = ObjCreateInterface($pElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray) $oElementArray.Length($iElements) If Not IsObj($oElementArray) Then Return _EW("$oElementArray ERR") ; Get array of buttons Local $aElements[$iElements] For $i = 0 To $iElements - 1 $oElementArray.GetElement($i, $pElement) $aElements[$i] = ObjCreateInterface($pElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement) Next ; Get name and position for each button $UIA_LegacyIAccessibleNamePropertyId Local $sValue, $aPos[4], $aBtnArray[$iElements][2] Local $tRect = DllStructCreate("long Left;long Top;long Right;long Bottom") Local $iChrCnt = StringLen($sSearchString) Local $sHelpTxt, $bMatch = False Local $aExtract, $aResult For $i = 0 To UBound($aElements) - 1 $aElements[$i].GetCurrentPropertyValue($UIA_NamePropertyId, $sValue) $aElements[$i].CurrentBoundingRectangle($tRect) $aPos[0] = $tRect.Left $aPos[1] = $tRect.Top $aPos[2] = $tRect.Right $aPos[3] = $tRect.Bottom $aBtnArray[$i][0] = $sValue $aBtnArray[$i][1] = $aPos $sHelpTxt &= $i & ") " & $aBtnArray[$i][0] & @CRLF If StringLeft($aBtnArray[$i][0], $iChrCnt) = $sSearchString Then $aExtract = _ArrayExtract($aBtnArray, $i, $i) $bMatch = True $sHelpTxt = "" ExitLoop EndIf Next $aResult = ($bMatch ? $aExtract : $aBtnArray) ; only if $sSearchString not match and <> "@No@" If $sSearchString <> "@No@" Then ConsoleWrite($sHelpTxt) Local $aMpos, $iAdjust Switch $iActionId Case 1 ;Get Return $aResult Case 2, 3, 4 ; 2=$MOUSE_CLICK_LEFT ; 3=$MOUSE_CLICK_RIGHT ; 4=$MOUSE_DBL_CLICK_LEFT ; only if $sSearchString match If UBound($aResult) = 1 Then Local $iClick = ($iActionId = 4 ? 2 : 1) Local $iButton = ($iActionId = 3 ? $MOUSE_CLICK_RIGHT : $MOUSE_CLICK_LEFT) $aPos = $aResult[0][1] ;ConsoleWrite("$aPos =" & $aPos[0] & ", " & $aPos[1] & ", " & $aPos[2] & ", " & $aPos[3] & @CRLF) $iAdjust = ($aPos[2] - $aPos[0]) / 2 $aMpos = MouseGetPos() ;Bakup mouse position If $iAreaId = 3 Then ControlClick($hWndTray, "", $hOverflowButton) ;fist click the Overflow Button MouseClick($iButton, $aPos[0] + $iAdjust, $aPos[1] + $iAdjust, $iClick, 1) If $sOption Then WinActivate($hWndTray) Opt("SendKeyDownDelay", 50) ;you may need to raise Opt("SendKeyDelay", 50) ;you may need to raise Send($sOption) Opt("SendKeyDelay", 5) ;5 milliseconds - Default Opt("SendKeyDownDelay", 5) ;5 milliseconds - Default Send("{ESC}") EndIf MouseMove($aMpos[0], $aMpos[1], 1) ;restore mouse position Return $aResult EndIf Case 5 ; 5=Click&Drag ; only if $sSearchString match If UBound($aResult) = 1 Then $aPos = $aResult[0][1] ;ConsoleWrite("$aPos =" & $aPos[0] & ", " & $aPos[1] & ", " & $aPos[2] & ", " & $aPos[3] & @CRLF) $iAdjust = ($aPos[2] - $aPos[0]) / 2 Local $iBtnWidth = $aPos[2] - $aPos[0] Local $iX2 Local $aOption = StringSplit($sOption, ":") If $aOption[0] = 2 Then If $aOption[1] = "X" Then $iX2 = Int($aOption[2]) ConsoleWrite("$iX2=" & $iX2 & @CRLF) ElseIf $aOption[1] = "Index" Then Local $aIdx = $iAreaId = 1 ? _TaskBar(1, "@No@") : _TaskBar(2, "@No@") $aOption[2] = Int($aOption[2]) If $aOption[2] > UBound($aIdx) - 1 Then Return _EW("wrong Click&Drag $sOption Index:ERR") Local $a = $aIdx[$aOption[2]][1] $iX2 = $a[0] Else Return _EW("wrong Click&Drag $sOption") EndIf Else $sOption = Int($sOption) $iX2 = $aPos[0] + $iAdjust + $iBtnWidth * $sOption EndIf If $sOption = "OverflowButton" Then ; RunningAppsArea not suporting If $iAreaId = 1 Then Return _EW("wrong Click&Drag $sOption, RunningAppsArea not suporting OverflowButton") Local $aCtrlPos = ControlGetPos($hWndTray, "", $hOverflowButton) ;Drag Position = OverflowButton $iX2 = $aCtrlPos[0] + $aCtrlPos[2] / 2 EndIf $aMpos = MouseGetPos() ;Bakup mouse position ; if OverflowNotifyArea fist click the Overflow Button If $iAreaId = 3 Then ControlClick($hWndTray, "", $hOverflowButton) MouseClickDrag($MOUSE_CLICK_LEFT, $aPos[0] + $iAdjust, $aPos[1] + $iAdjust, $iX2, @DesktopHeight - $iAdjust, 1) WinActivate($hWndTray) Send("{ESC}") MouseMove($aMpos[0], $aMpos[1], 1) ;restore mouse position Return $aResult EndIf Case Else Return _EW("wrong $iActionId") EndSwitch ;_ArrayDisplay($aBtnArray) EndFunc ;==>_TaskBar ;-------------------------------------------------------------------------------------------------------------------------------- Func IsMouseOverRect($aRect) If Not IsArray($aRect) Then Return _EW("Not array found") Local $Width = $aRect[2] - $aRect[0] Local $Height = $aRect[3] - $aRect[1] $aRect[2] = $Width $aRect[3] = $Height ;$aRect[0]=X ;$aRect[1]=Y ;$aRect[2]=Width ;$aRect[3]=Height Local $aMpos = MouseGetPos() If $aMpos[0] > $aRect[0] And $aMpos[1] > $aRect[1] And $aMpos[0] < $aRect[0] + $aRect[2] And $aMpos[1] < $aRect[1] + $aRect[3] Then Return True EndIf Return False EndFunc ;==>IsMouseOverRect ;-------------------------------------------------------------------------------------------------------------------------------- Func _EW($sString, $iLine = @ScriptLineNumber) ConsoleWrite("! (" & $iLine & ") " & $sString & @CRLF) EndFunc ;==>_EW ;-------------------------------------------------------------------------------------------------------------------------------- And while we're on the subject of TaskBar, here's another related one ;---------------------------------------------------------------------------------------- ; Title...........: ShellTrayRefresh.au3 ; Description.....: Refreshes ShellTray to remove leftover zombie icons ; AutoIt Version..: 3.3.16.1 Author: ioa747 ; Note............: Testet in Win10 22H2 ; https://www.autoitscript.com/forum/topic/139260-autoit-snippets/page/25/#comment-1529091 ;---------------------------------------------------------------------------------------- Func ShellTrayRefresh() Local $aStartPos = MouseGetPos() Local $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]") Local $hTlb = ControlGetHandle($hTrayWnd, "", "ToolbarWindow324") Local $hBtn = ControlGetHandle($hTrayWnd, "", "Button2") Local $aPos = ControlGetPos($hTrayWnd, "", $hBtn) Local $aTPos = ControlGetPos($hTrayWnd, "", $hTlb) For $i = ($aPos[0] - 1) + ($aPos[2] / 2) To $aPos[0] + $aPos[2] + $aTPos[2] Step $aPos[2] MouseMove($i, @DesktopHeight - 3, 1) ;~ ConsoleWrite("$i=" & $i & @CRLF) ;~ Sleep(10) Next MouseMove($aStartPos[0], $aStartPos[1], 1) EndFunc ;==>ShellTrayRefresh here's another related one το set or get the state of the taskbar. from here ; https://www.autoitscript.com/forum/topic/154281-taskbar-problems/?do=findComment&comment=1517375 ; FileVersion:3, Testet on Win10 22H2, with AutoIt Version:3.3.16.1 ;---------------------------------------------------------------------------------------- #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 ;~ #AutoIt3Wrapper_UseX64=y ConsoleWrite("TaskbarState=" & TaskbarState() & @CRLF) ; #FUNCTION# -------------------------------------------------------------------------------------------------------------------- ; Name...........: TaskbarState ; Description....: Sets or gets the state of the taskbar. ; Syntax.........: TaskbarState([$iState]) ; Parameters.....: $iState - [optional] The new state of the taskbar. Can be one of the following values: ; 1 - Auto-hide the taskbar. ; 2 - Always on top. ; 3 - Toggle the current state of the taskbar. ; Return values..: The current state of the taskbar. Can be one of the following values: ; Success: 1 = Auto-hide, 2 = Always on top. ; Failure: 0 and sets the @error flag to non-zero. ; Author ........: sylremo, mod:ioa747 ; Notes .........: if no value in $iState then return the state of the taskbar ; Link ..........: https://www.autoitscript.com/forum/topic/154281-taskbar-problems/#comment-1538596 ;-------------------------------------------------------------------------------------------------------------------------------- Func TaskbarState($iState = "") Local Const $ABM_GETSTATE = 0x00000004 Local Const $ABM_SETSTATE = 0x0000000A Local Const $ABS_AUTOHIDE = 0x00000001 Local Const $ABS_ALWAYSONTOP = 0x00000002 Local $tAPPBARDATA = DllStructCreate('dword;hwnd;dword;dword;int[4];dword') DllStructSetData($tAPPBARDATA, 1, DllStructGetSize($tAPPBARDATA)) Local $iCurrentState = DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA)) If Not @error And IsArray($iCurrentState) Then Local $iNewState = $iCurrentState[0] ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE DllStructSetData($tAPPBARDATA, 6, $iNewState) $iCurrentState = $iCurrentState[0] = 1 ? 1 : 2 If $iState = 1 Or $iState = 2 Then If $iCurrentState <> $iState Then DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_SETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA)) $iCurrentState = $iNewState EndIf ElseIf $iState = 3 Then DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_SETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA)) $iCurrentState = $iNewState EndIf Return $iCurrentState EndIf Return SetError(1, 0, 0) EndFunc ;==>TaskbarState as well as the link ITaskbarList4 interface Please, every comment is appreciated! leave your comments and experiences here! Thank you very much1 point
-
Update to Version: 2.0 I added Mouse Click & Drag operation, to rearrange icons positions1 point
-
ITaskbarList4 interface
Parsix reacted to argumentum for a topic
would you post an example ? Also, instead of declaring them independently, might as well declare them all ? Global Const $sCLSID_TaskbarList = "{56FDF344-FD6D-11D0-958A-006097C9A090}" ; Win2000 Global Const $sIID_ITaskbarList2 = "{602D4995-B13A-429b-A66E-1935E44F4317}" ; WinXP Global Const $sIID_ITaskbarList3 = "{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}" ; Win7 Global Const $sIID_ITaskbarList4 = "{C43DC798-95D1-4BEA-9030-BB99E2983A1A}" ; Win7 Global Const $tagITaskbarList = _ "HrInit hresult();" & _ "AddTab hresult(hwnd);" & _ "DeleteTab hresult(hwnd);" & _ "ActivateTab hresult(hwnd);" & _ "SetActiveAlt hresult(hwnd);" Global Const $tagITaskbarList2 = $tagITaskbarList & _ "MarkFullscreenWindow hresult(hwnd;boolean);" Global Const $tagITaskbarList3 = $tagITaskbarList2 & _ "SetProgressValue hresult(hwnd;uint64;uint64);" & _ "SetProgressState hresult(hwnd;int);" & _ "RegisterTab hresult(hwnd;hwnd);" & _ "UnregisterTab hresult(hwnd);" & _ "SetTabOrder hresult(hwnd;hwnd);" & _ "SetTabActive hresult(hwnd;hwnd;dword);" & _ "ThumbBarAddButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarUpdateButtons hresult(hwnd;uint;ptr);" & _ "ThumbBarSetImageList hresult(hwnd;ptr);" & _ "SetOverlayIcon hresult(hwnd;ptr;wstr);" & _ "SetThumbnailTooltip hresult(hwnd;wstr);" & _ "SetThumbnailClip hresult(hwnd;ptr);" Global Const $tagITaskbarList4 = $tagITaskbarList3 & _ "SetTabProperties hresult(hwnd;int);" to have a chance to use some of it in pre-win7 ?1 point