Search the Community
Showing results for tags 'taskbar'.
-
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 as well as the link ITaskbarList4 interface Please, every comment is appreciated! leave your comments and experiences here! Thank you very much
-
Cannot find example how to locate taskbar icon coordinates or position by window handle. I want to use PixelChecksum to check only rectangle area over specified taskbar item. Please help. What I already have found and succesfully run for whole taskbar area: $taskbar = WinGetHandle("[Class:Shell_TrayWnd]") $taskbarPos = WinGetPos($taskbar) $tasklistPos = ControlGetPos($taskbar, "", "[CLASS:MSTaskListWClass; INSTANCE:1]") $iOldCheckSum = PixelChecksum($taskbarPos[0] + $tasklistPos[0], $taskbarPos[1] + $tasklistPos[1], $taskbarPos[0] + $tasklistPos[2], $taskbarPos[1] + $tasklistPos[3]); I know also that I can pass window handle as parameter to PixelChecksum, but don't know how to do this with taskbar icon. Also I was able to find something similar but seems outdated: WatchWindows __ thanks in advance
- 21 replies
-
- taskbar icons
- taskbar
-
(and 2 more)
Tagged with:
-
Hello guys. I have a little issue and I can't find any answer sadly so I'm opening this post. I created a tool with AutoIt, but sadly on Windows 8.1 I can't pin it to my taskbar, I have no idea why. If I take any other program for example Firefox, when it's started and I do a right click on the icon in the taskbar I can have a nice menu and just below "Exit window" I have an option "Pin this program to the TaskBar" (or Unpin if already clicked), but with my AutoIt script (compiled) I have only the Exit button. Do you know if there is a Windows option to add to GuiCtrlCreateGui() or anything I can do to be able to pin my program to the windows 8.1 taskbar? Thank you very much, Tim
-
I have the following code. You can see there are $color_normal and $color_trans In my case normal is too dark . And color trans is to much violet. If you run it you will see how its looks. I want gui with listView have the same color like taskbar in windows 10. How to achieve that? #include <Date.au3> #include <MsgBoxConstants.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> HotKeySet("{ESC}", "Terminate") $color_normal = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) $color_trans = "0x" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) $trans = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") ConsoleWrite("Transpart = " & $trans & @CRLF) ConsoleWrite("Color normal = " & $color_normal & @CRLF) ConsoleWrite("Color trans = " & $color_trans & @CRLF) ConsoleWrite(_Get_taskbar_color()); It return AARRGGBB $taskbarColor = _Get_taskbar_color() Global $gui = GUICreate("Test", 150, 58,@DesktopWidth-300,@DesktopHeight-58,$WS_POPUP,BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Global $idListview = GUICtrlCreateListView("", 0, 0, 150, 58,BitOR($LBS_NOTIFY,$LBS_SORT), 0) ;_GuiCtrlMakeTrans(-1,100) ; Add column _GUICtrlListView_AddColumn($idListview, "Msgs", 100) GUICtrlSetFont(-1, 7, 400, 0, "Segoe UI") GUICtrlSetColor(-1, 0x470C4F) GUICtrlSetBkColor($idListview, 0x310638) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func Terminate() Exit EndFunc Func _Get_taskbar_color() If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "ColorPrevalence") Then If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 16), 6) Else Return "0xFF" & StringLeft(StringRight(RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Accent", "AccentPalette"), 24), 6) EndIf Else If RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize", "EnableTransparency") Then Return "0xD9000000" Else Return "0xFF000000" EndIf EndIf EndFunc
-
Hello, is it possible to use an autoit script to show a live preview from a minimized program? I searched for this and found many different little tools but none of them offered this Option so far. You may ask why someone should use this, for me it should be a live preview from different clients of a game, when minimized the game itself is not using much resources but with multiple clients running its to heavy for my rig so i try to find a way to still observe what is happening ingame on this minimized clients. Would be nice if somebody leads me into the right direction where i can / should begin with, cause i am not sure how this script should look like but maybe someone already tried this (my forum search was not successfull)? Regards
- 1 reply
-
- live preview
- minimized window
-
(and 1 more)
Tagged with:
-
HI. I was needing to add a program to Tarkbar(an easy way without using objectcreateinterface ) so I found this. So then I deduced how to add to the StartMenu while I see the shell32 in hex editor search for taskbarunpin|taskbarpin string. I found another two interesting string (startpin|startunpin) So I try out and they work too but to add to StartMenu. This is not an official way to do this, however it works. $sFileLnk parameter must be Link(.lnk) to our program. ;~ Success: True. ;~ Failure: False. Func DeleteFromTaskBar($sFileLnk) Return _WinAPI_ShellExecute($sFileLnk,"","", "taskbarunpin") EndFunc Func AddToTaskBar($sFileLnk) Return _WinAPI_ShellExecute($sFileLnk,"","", "taskbarpin") EndFunc Func AddToStartMenu($sFileLnk) Return _WinAPI_ShellExecute($sFileLnk,"","", "startpin") EndFunc Func DeleteFromStartMenu($sFileLnk) Return _WinAPI_ShellExecute($sFileLnk,"","", "startunpin") EndFunc Saludos
-
Hi All, I wrote an app a few years ago and have revisited it to improve it, one thing I can't sort it to not show it on the taskbar, but show it in the system tray, the point of the app is to allow users easy access to info that tech support may ask, like username, pc name & IP address. I've searched the forums but not found a answer, can anyone point me in the right direction. Thanks in advance# RichE
-
Hi all, I need to get the list of windows which are resting in taskar. That means, windows which i can toggle through ALT TAB. I use "WinList" function. But it gives me all the windows. Then i tried to filter it like this; Local $lst = WinList() Local $Row = 0 For $i = 1 To $lst[0][0] If $lst[$i][0] = "" And Not BitAND(WinGetState($lst[$i][1]), 1) Then _ArrayDelete($lst,$Row) EndIf $Row +=1 Next _ArrayDisplay($lst) But this code doesn't delete the 2nd column. I have read the help file and saw an example which deletes an entire row from a 2 dimensional array. I have used the same method but please look this image. This is what i have got.
-
List applications open on the TaskBar?
AmbientMike posted a topic in AutoIt General Help and Support
Hi, I am trying to find a way to detect if two applications are running (and visible in the GUI). One sits in the system tray (which I've got sorted) but another launches (so is easily visible as a running process) but seems to delay until showing in the GUI but the "WinExists" command seems to pick it up a few seconds before it's actually visible! The bit of script that detects the system tray app is modified from somewhere on these forums that finds the text labels from all of the tray icons... Func Get_Systray_IconText($sToolTipTitle) Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) Local $iSystray_ButtonNumber For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 Local $sText = _GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber) If StringInStr($sText, $sToolTipTitle) = 1 Then Return $sText EndIf Next Return SetError(1, 0, "") EndFunc So I was hoping that there was something nearly identical that detects icons in the Taskbar in a near-identical way as ProcessExists and WinExists commands seem to detect it too early and I really need to detect the time that the window is visible to the user which seems to be when it spawns it's taskbar icon. Any ideas? -
Hi friends, Is there any way to show a taskbar icon for a script that has no GUI? The script has a tray icon, but I like to have a taskbar icon also. Thank you, Pooja.
-
Everytime when you start a program, its icon shows up in the taskbar, like in the picture: The 'Paint' and 'Excel' programs are running, so appears their icons in the Taskbar. If they aren't running,the taskbar is clean. How can I hide or make to dissapear the icon from another program that shows there ? I would appreciate any help !