Search the Community
Showing results for tags 'tray'.
-
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, "", "ToolbarWindow323") 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
-
; https://www.autoitscript.com/forum/topic/209550-tray-example/ #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w 7 #include <StringConstants.au3> #include <TrayConstants.au3> Opt("TrayMenuMode", 3) ; These are options 1 and 2 for TrayMenuMode. Opt("TrayOnEventMode", 1) ; Enable TrayOnEventMode. Local $bPaused = False TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") #Region === Tray_Menu === TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE, "TogglePause") Local $idPaused = TrayCreateItem("Pause", -1, -1, $TRAY_ITEM_RADIO) TrayItemSetOnEvent(-1, "TogglePause") TrayItemSetState(-1, $TRAY_UNCHECKED) TrayCreateItem("") ; Create a separator line. Local $idExit = TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "GoToExit") #EndRegion === Tray_Menu === ToolTip(@ScriptName & @CRLF & " ", @DesktopWidth / 2, @DesktopHeight / 5, "Started", 1) Sleep(3000) ToolTip("") While 1 _GetTrayStatus() Sleep(10) WEnd GoToExit() ;---------------------------------------------------------------------------------------- Func GoToExit() ; exit Exit EndFunc ;==>GoToExit ;---------------------------------------------------------------------------------------- Func _GetTrayStatus() While 1 ;~ ConsoleWrite("-loop" & @CRLF) If $bPaused = False Then ExitLoop Else ; calm down and stay Sleep(500) EndIf WEnd EndFunc ;==>_GetTrayStatus ;---------------------------------------------------------------------------------------- Func TogglePause() If $bPaused = False Then $bPaused = True TrayItemSetState($idPaused, $TRAY_CHECKED) ; $TRAY_UNCHECKED, $TRAY_CHECKED TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Red.ico") Else $bPaused = False TrayItemSetState($idPaused, $TRAY_UNCHECKED) ; $TRAY_UNCHECKED, $TRAY_CHECKED TraySetIcon(StringLeft(@AutoItExe, StringInStr(@AutoItExe, "\", $STR_NOCASESENSEBASIC, -1) - 1) & "\Icons\MyAutoIt3_Blue.ico") EndIf EndFunc ;==>TogglePause ;----------------------------------------------------------------------------------------
-
Opt('TrayAutoPause', 0) $iTray1 = TrayCreateItem('Tray 1') TrayItemSetState(-1, 1) TrayCreateItem('') $iTrayMenu1 = TrayCreateMenu('Tray Menu 1') $iTray2 = TrayCreateItem('Tray 2', $iTrayMenu1, -1, 1) TrayItemSetState(-1, 1) $iTray3 = TrayCreateItem('Tray 3', $iTrayMenu1, -1, 1) $iTray4 = TrayCreateItem('Tray 4', $iTrayMenu1, -1, 1) TrayCreateItem('') $iTrayMenu2= TrayCreateMenu('Tray Menu 2') $iTray5 = TrayCreateItem('Tray 5', $iTrayMenu2, -1, 1) TrayItemSetState(-1, 1) $iTray6 = TrayCreateItem('Tray 6', $iTrayMenu2, -1, 1) $iTray7 = TrayCreateItem('Tray 7', $iTrayMenu2, -1, 1) TrayCreateItem('') $iTray8 = TrayCreateItem('Tray 8') $iTray9 = TrayCreateItem('Tray 9') $iTray10 = TrayCreateItem('Tray 10') TrayItemSetState(-1, 1) While True Sleep(1000*5) WEnd When I click on Tray 3 / Tray 4 / Tray 6 / Tray 7 nothing happens. Only Tray 2 and Tray 5 stay checked. I have tried setting Opt("TrayMenuMode", 8) In this case radio menuitems act like normal menuitems only looks different. I'm using AutoIt v3.3.14.5. Tested on Windows 10 LTSC 2019 (1809) x64 version: 10.0.17763 build 17763.475 and Windows Server 2008 R2. Tried run script x64 and x86 same result. Is this kind a bug or something?
-
So I'm coding in win 10, ..every thing looks nice but then I think, what about XP, ...ugly, but I make it pretty again, no problem. Lets check in Win 7 and here is my conundrum. Win 10, DRM is on, XP is off ( well, non-existant ), so far so good. I decide to make it the "switch" to enable or disable the checkbox in the context menu. Win 7 ... I try to apply the same logic and: DRM on: DRM off: now, "Windows 7 Basic": DRM is off Question: how should I determine if to hide the check-mark or not?, Is there a way to know that this theme is ? or better yet, how can I know that the theme is classic ? Thanks PS: I know that the code is not here but I think that my trend of thought would make it irrelevant anyway.
-
LAST VERSION - 1.0 19-May-12 I think many of you would like to perform some action (for example, to call the dialog box) when a user clicks on the tray tip. Here is a simple way to do it. Unfortunately, without .dll do not seem possible. Note, only AutoIt window can be registered as a source window, see example. AITray.dll (x86 and x64) Previous downloads: 74 AITray.zip Example #Include <WindowsConstants.au3> Opt('TrayAutoPause', 0) Opt('WinTitleMatchMode', 3) Opt('WinWaitDelay', 0) Global Const $NIN_BALLOONSHOW = $WM_USER + 2 Global Const $NIN_BALLOONHIDE = $WM_USER + 3 Global Const $NIN_BALLOONUSERCLICK = $WM_USER + 5 Global Const $NIN_BALLOONTIMEOUT = $WM_USER + 4 $hForm = GUICreate('') If @AutoItX64 Then $hDll = DllOpen(@ScriptDir & '\AITray_x64.dll') Else $hDll = DllOpen(@ScriptDir & '\AITray.dll') EndIf If $hDll <> -1 Then $Ret = DllCall($hDll, 'int', 'AISetTrayRedirection', 'hwnd', WinGetHandle(AutoItWinGetTitle()), 'hwnd', $hForm) If (@Error) Or (Not $Ret[0]) Then DllClose($hDll) Exit EndIf Else Exit EndIf GUIRegisterMsg($WM_USER + 1, 'WM_TRAYNOTIFY') TrayTip('Tip', 'This is a tray tip, click here.', 10, 1) While 1 Sleep(1000) WEnd DllCall($hDll, 'int', 'AIRemoveTrayRedirection') DllClose($hDll) Func WM_TRAYNOTIFY($hWnd, $iMsg, $wParam, $lParam) Switch $hWnd Case $hForm Switch $lParam Case $NIN_BALLOONSHOW ConsoleWrite('Balloon tip show.' & @CR) Case $NIN_BALLOONHIDE ConsoleWrite('Balloon tip hide.' & @CR) Case $NIN_BALLOONUSERCLICK ConsoleWrite('Balloon tip click.' & @CR) Case $NIN_BALLOONTIMEOUT ConsoleWrite('Balloon tip close.' & @CR) EndSwitch EndSwitch EndFunc ;==>WM_TRAYNOTIFY
-
I need to read the status of OneDrive icon running in the taskbar and update the status in a log file. 2nd part I can complete But the first part, how to read the status of tray menu icon. I need the text above from the tray icon. I looked into , but not that helpful.
- 4 replies
-
- tray
- system tray
-
(and 1 more)
Tagged with:
-
Hello Guys, Is there a way to have Auto it Exe messages/line number when you hover over the tray icon just at it shows when you run Au3.? For an example, if I the script has paused due to WinWait or Sleep I could hover over the icon and it shows the line where it's at. Is there a way to achieve the same with the compiled exe? Many thanks for the help!
-
I have a script that gets a list of visible windows and makes a tray item of each in the tray menu. I'd also want it to update every time I want to access that menu again, in case new windows have appeared or some would have been closed. I'm using TrayOnEventMode option and trying to get the update going with TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN...) as in the snippet below. However, the list doesn't update until after the tray menu has been closed again. I think I could work around this by having the script update the list constantly in the background, but that feels like it'd take up unnecessary amount of resources since the script might be used rarely by the user anyway. I tried using TraySetOnEvent($TRAY_EVENT_MOUSEOVER...), and that kind of does it, but it actually still calls my function many times (since the mouse cursor moves quite a bit on the icon) before the tray menu is opened. I could put another menuitem to call the update function, but I'd much rather have just the minimal amount of user actions. Similarly I could have tray menu open with a double click (with TraySetClick()) and have the first click just call the update function, but can anyone tell me if there's a way to call the update once and then have the menu open without these gimmicks? Opt("TrayOnEventMode", 1) TraySetOnEvent($TRAY_EVENT_PRIMARYDOWN, "UpdateWindowsList")
-
Hi All, I have a custom icon for the tray menu icon, which was working until I copied in the example code for a custom menu when clicking on the tray icon, now it just displays the default AutoIt tray icon. The menu works fine, but the tray icon initiates as the AutoIt default icon and the icon won't change on event. Can anyone advise what I need to do to use my custom icon while retaining the tray custom menu? Thanks! Also, the While 1 ... WEnd makes me nervous, how does this not lock up the system? If anyone would like to comment on that - thanks. Opt("TrayMenuMode", 3) #include <TrayConstants.au3> Local $idAbout = TrayCreateItem("About") Local $idExit = TrayCreateItem("Exit") TraySetState($TRAY_ICONSTATE_SHOW) While 1 Switch TrayGetMsg() Case $idAbout MsgBox(1,"test","test msg") Case $idExit Exit EndSwitch WEnd If Not FileExists (@TempDir & "\MyIcons") Then DirCreate(@TempDir & "\MyIcons") FileInstall(".\Grey-1.ico", @TempDir & "\MyIcons\Grey-1.ico", 1) FileInstall(".\Yellow-1.ico", @TempDir & "\MyIcons\Yellow-1.ico", 1) TraySetIcon(@TempDir & "\MyIcons\Grey-1.ico");Change icon to grey initially ; If X happens then change tray icon to yellow ; If Y happens then change tray icon to grey
-
I have a working code here. #include <GUIConstants.au3> #include <Constants.au3> Opt("GUIOnEventMode",1) $title = "WINDOW" $text="" $fullTest = WinExistsExact($title, $text) $PASSWORD = "PASS" $retryCount = 0 $stop = 1 ;<<<<<<<<<<<<<<<<<<<<<<<<< While 1 if $retryCount > 0 then Exit $input = InputBox("Password Protected", "Enter the password to continue", "", "*") If @error Or $input <> $PASSWORD Then MsgBox(4096,"Error", "Incorrect Password") $retryCount = $retryCount + 1 Else ;MsgBox(4096,"Success", "Password Accepted") ExitLoop EndIf Wend If $fullTest = 1 Then ;MsgBox(0, "WINDOW", "Press Ok to continue") GUICreate("WINDOW", 241, 78) ;$label = GUICtrlCreateInput ("test", 10, 10, 50, 20) GuiSetOnEvent($GUI_EVENT_CLOSE,"Quit") $button = GUICtrlCreateButton ("Start", 18, 31, 100, 25) $button1 = GUICtrlCreateButton ("Hide", 128, 31, 91, 25) ; <----- THIS IS THE BUTTON GuiCtrlSetOnEvent($button,"DoScript") GUISetState (@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") ;<<<<<<<<<<<<<<<<<<<<< Else MsgBox(0, "WINDOW", "You need to run WINDOW client first.") EndIf While 1 Sleep(10) Wend Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) If BitAND($wParam, 0x0000FFFF) = $button Then $stop = not $stop If $stop = 0 Then GUICtrlSetData($button, "Stop") If $stop = 1 Then GUICtrlSetData($button, "Start") EndIf Return $GUI_RUNDEFMSG EndFunc Func WinExistsExact($title, $text) AutoItSetOption( "WinTitleMatchMode", $OPT_MATCHEXACT ) $res = WinExists($title, $text) AutoItSetOption( "WinTitleMatchMode", $OPT_MATCHSTART ) Return $res EndFunc Func DoScript() While 1 For $i = 1 to 300 Sleep (10) If $stop = 1 Then Return ; GuiCtrlSetData($label, $i) Next ControlSend ( $title, "", 0, "{F12}") $a = Random(300, 900, 1) For $i = 1 to $a Sleep (10) If $stop = 1 Then Return Next ControlSend ( $title, "", 0, "{Del}") $a = Random(100, 500, 1) For $i = 1 to $a Sleep (10) If $stop = 1 Then Return Next WEnd EndFunc Func Quit() Exit EndFuncWhat I wanted to do is to make the 'Hide' button minimized the entire window when clicked and while it is on tray, there will be a menu if a user right clicked on it. Exactly what the code below should do. #NoTrayIcon #include <guiconstantsex.au3> #include <constants.au3> Opt("TrayOnEventMode", 1) Opt("TrayMenuMode", 3) ; Create tray menu items and set the events $About = TrayCreateItem("About") TrayItemSetOnEvent($About, "_About") TrayCreateItem("") ; Create a separator line. $Exit = TrayCreateItem("Exit") TrayItemSetOnEvent($Exit, "_Exit") ; Set the action if you left click on the tray icon TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "SpecialEvent") ; Show the menu if the icon is right clicked TraySetClick(8) Global $MainGui = GUICreate("TestGUI", 392, 316, -1, -1) GUISetState() ;Test() While 1 Switch GUIGetMsg() Case $GUI_EVENT_MINIMIZE ; Hide the GUI GUISetState(@SW_HIDE) ; Show the icon TraySetState(1) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func SpecialEvent() ; Show the GUI GUISetState(@SW_SHOW) GUISetState(@SW_RESTORE) ; Hide the icon TraySetState(2) EndFunc ;==>SpecialEvent Func _About() MsgBox(0,0,"Test") EndFunc Func _Exit() Exit EndFuncMy problem is I cannot integrate this code to the one I have. Can anyone help me with this? I would be very much thankful as I am just starting to learn.
-
Hi, Here is an UDF to create, delete, set the icon and state, tooltip and tip for your notify icons. The main advantage is that you can handle mouse events as you want, there is no default events. You can create fully customised notifyicons/tooltips. Thanks to Holger Kotsch for his ModernMenu UDF. Note : Breaking changes ! Please use the 1.2+ version. Functions : Attachments : Example + UDF : AutoIt v3.3.10.0+ NotifyIcon_1.2.zip TrayIconEx_1.1.zip AutoIt v3.3.8.0+ TrayIconEx.zip & Requirements : >WinAPIEx UDF. As usual, enjoy !
-
I was helping another user the other day And decided To make a UDF so here it is. Let me know what ya think. #include-once #include <GuiListView.au3> Global Const $SW_HIDENA = 2, $SW_HIDENOACTIVE = 2 ; Examples are below. ; #FUNCTION# ==================================================================================================================== ; Name ..........: _ToggleSystemTrayState ; Description ...: Hide/Show System Tray Icons by Name or Set the State for all Icons ; Syntax ........: _ToggleSystemTrayState([$vTrayItems = ""[, $iStartSearchIndex = 0[, $iSystemTrayState = 0[, $iDebug = 0]]]]) ; Parameters ....: $vTrayItems - [optional] A variant value. Default is "". ; $iStartSearchIndex - [optional] An integer value. Default is 0. Set this to -1 to search from end to start. ; $iSystemTrayState - [optional] An integer value. Default is 0. ; $iDebug - [optional] An integer value. Default is 0. Set this to either @SW_SHOW or 1 to see dialogs and debug information. ; Return values .: None ; Author ........: Decipher ; Modified ......: ; Remarks .......: Tested only on XP ; ; $iSystemTrayState can be one of the following: ; @SW_SHOW == ALWAYS_SHOW == 5 ; @SW_HIDE == ALWAYS_HIDE == 0 ; $SW_HIDENA == HIDE WHEN INACTIVE == 2 ; ; $vTrayItems can be a string for a specific icon or an array for multiple icons ; There is no error checking implemented but feel free to change it to your needs. ; ; Related .......: ; Link ..........: ; Example .......: Yes, The examples need to be uncommented to run. Remove the ( ;- ) prefix on the example to be ran. ; =============================================================================================================================== ;;;; Set all icons to hide when inactive. ;;;; ;- _ToggleSystemTrayState($SW_HIDENA) ; Example #1 ;;;; Hide all system tray icons. ;;;; ;- _ToggleSystemTrayState(@SW_HIDE) ; Example #2 ;;;; Show two specific icons. ;;;; ;- Local $aIcons[2] = ["Local Area Connection", "Volume"] ; Example #3 ;- _ToggleSystemTrayState($aIcons, 0, @SW_SHOW) ;;;; Hide a specific icon. ;;;; ;- _ToggleSystemTrayState("Volume", 0, @SW_HIDE) ; Example #4 ;;;; Show all system tray icons. ;;;; ;- _ToggleSystemTrayState(@SW_SHOW) ; Example #5 ;;;; Hide all system tray icons but show the dialogs aka debug mode and log the names of the icons hidden. ;;;; ;- _ToggleSystemTrayState("", 0, @SW_HIDE, 1) ; Example #6 Func _ToggleSystemTrayState($vTrayItems = "", $iStartSearchIndex = 0, $iSystemTrayState = 0, $iDebug = 0) If IsInt($vTrayItems) Then $iSystemTrayState = $vTrayItems $vTrayItems = "" EndIf Local Const $sOPTIONS_DIALOG_PROCESS = "rundll32.exe shell32.dll, Options_RunDLL 1" Local Const $sTASKBAR_PROPERTIES_TITLE = "[TITLE:Taskbar and Start Menu Properties; CLASS:#32770; INSTANCE:1]" Local Const $sCUSTOMIZE_BUTTON = "[ClassnameNN:Button10]", $sSENDKEYS = "!c" Local Const $sTASKBAR_CUSTOMIZE_TITLE = "[TITLE:Customize Notifications; CLASS:#32770; INSTANCE:1]" Local Const $sTRAYICONS_LISTVIEW = "[CLASS:SysListView32; INSTANCE:1]" Local Const $sLISTVIEW_COMBOX_CONTROL = "[CLASS:ComboBox; INSTANCE:1]" Local Const $sTASKBAR_CHILD_OK_BUTTON = "[CLASS:Button; INSTANCE:2]" Local Const $iRUNDLL32 = Run($sOPTIONS_DIALOG_PROCESS) WinWait($sTASKBAR_PROPERTIES_TITLE, "", 2000) Local Const $hTASKBAR_DIALOG = WinGetHandle($sTASKBAR_PROPERTIES_TITLE) WinSetState($hTASKBAR_DIALOG, "", $iDebug) ControlSend($hTASKBAR_DIALOG, "", ControlGetHandle($hTASKBAR_DIALOG, "", $sCUSTOMIZE_BUTTON), $sSENDKEYS) WinWait($sTASKBAR_CUSTOMIZE_TITLE, "", 2000) $hTASKBAR_CHILD_DIALOG = WinGetHandle($sTASKBAR_CUSTOMIZE_TITLE) WinSetState($hTASKBAR_CHILD_DIALOG, "", $iDebug) Local Const $hDIALOG_LISTVIEW = ControlGetHandle($hTASKBAR_CHILD_DIALOG, "", $sTRAYICONS_LISTVIEW) Local $iListViewItem = 0, $hComboBox_Instance = 0, $aTrayIcon[1], $iTrayIcon, $iSkipTask = False, $sTrayItemText If IsArray($vTrayItems) Or $vTrayItems <> "" Then If Not IsArray($vTrayItems) Then $aTrayIcon[0] = $vTrayItems Else $aTrayIcon = $vTrayItems EndIf For $i = 0 To UBound($aTrayIcon, 1) - 1 Step 1 $iTrayIcon = _GUICtrlListView_FindInText($hDIALOG_LISTVIEW, $aTrayIcon[$i], $iStartSearchIndex) If $iDebug Then ConsoleWrite("Tray Icon: " & @TAB & _GUICtrlListView_GetItemText($hDIALOG_LISTVIEW, $iTrayIcon) & @CRLF) EndIf _GUICtrlListView_SetItemFocused($hDIALOG_LISTVIEW, $iTrayIcon) $hComboBox_Instance = ControlGetHandle($hTASKBAR_CHILD_DIALOG, "", $sLISTVIEW_COMBOX_CONTROL) ControlSend($hTASKBAR_CHILD_DIALOG, "", $hDIALOG_LISTVIEW, "{SPACE}") For $iLoopIndex = 1 To 3 Step 1 ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{DOWN}") Next If $iSystemTrayState <> 5 Then ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{UP}") If $iSystemTrayState = 2 Then ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{UP}") EndIf EndIf Next $iSkipTask = True EndIf While WinExists($hTASKBAR_CHILD_DIALOG) If $iSkipTask Then ExitLoop EndIf If $iListViewItem >= _GUICtrlListView_GetItemCount($hDIALOG_LISTVIEW) + 1 Then ExitLoop EndIf $iListViewItem += 1 ControlFocus($hTASKBAR_CHILD_DIALOG, "", $hDIALOG_LISTVIEW) If $iDebug Then $sTrayItemText = _GUICtrlListView_GetItemText($hDIALOG_LISTVIEW, $iListViewItem) If $sTrayItemText <> "" Then ConsoleWrite("Tray Icon: " & @TAB & $sTrayItemText & @CRLF) EndIf EndIf $hComboBox_Instance = ControlGetHandle($hTASKBAR_CHILD_DIALOG, "", $sLISTVIEW_COMBOX_CONTROL) For $i = 1 To 3 Step 1 ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{DOWN}") Next If $iSystemTrayState <> 5 Then ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{UP}") If $iSystemTrayState = 2 Then ControlSend($hTASKBAR_CHILD_DIALOG, "", $hComboBox_Instance, "{UP}") EndIf EndIf ControlSend($hTASKBAR_CHILD_DIALOG, "", $hDIALOG_LISTVIEW, "{DOWN}") WEnd ControlSend($hTASKBAR_CHILD_DIALOG, "", $sTASKBAR_CHILD_OK_BUTTON, "{ENTER}") WinClose($hTASKBAR_DIALOG) If ProcessExists($iRUNDLL32) Then ProcessClose($iRUNDLL32) EndIf EndFunc ;==>_ToggleSystemTrayState
-
Sorry for such a general question, I asked a more in depth one a week ago and was unable to get the answer I needed. I have a tray item and one of them is nested 2 deep, and its set to display that its selected and all that. I have two questions about this: 1. How once the tray item is selected with the dot next to it, how do i know its selected? Where would I look in the script? 2. Is there a way to make the tray not close after selecting the tray item? Thanks guys!
-
Searched and found one thread but it wasn't very helpful. I was wondering how to do this, I have a UI and I would like it when you hit minimize it will go to the tray. Not the start bar. Then the tray will have options to just run from there, or restoring to the UI the saw before. I am sure its a common thing, just cant figure it out so far.
-
I have 2 guis both of which minimize to the system tray like I want, however the first GUI when it is "restored" pops right up, and yet the second GUI, when it "restores", looks like it is flying in. On the second GUI I have and want to have the minimize and Close butttons but how do I get is so that when the GUI is restored from the taskbar it does not fly in. Code for the first GUI #NoTrayIcon #include <File.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent") GUICreate("HelpDesk App", 300, 620, Default, Default, BitAND($WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_CONTEXTHELP) GUISetState() Func SpecialEvent() GUISetState(@SW_SHOW) TraySetState(2) ; hide EndFunc ;==> SpecialEvent Code for the second GUI #include <File.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GUIConstants.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Process.au3> #include <WinAPI.au3> #include <GUIComboBox.au3> #Include <String.au3> #include <Icons.au3> #include <GuiTab.au3> #include <GUIButton.au3> #Include <TabConstants.au3> #NoTrayIcon Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP,"SpecialEvent") GUICreate("Utility v3.0", 315, 750) GUISetState() Func SpecialEvent() GUISetState(@SW_SHOW) TraySetState(2) ; hide EndFunc ;==> SpecialEvent Note* I have tried adding the same styles to the second GUI but it removes the Minimize and close buttons Thanks, Grimm
-
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 !
-
I'm making a Traymenu in systray to initiate a certain function automatically based on changes in @ipaddress. The While loop uses about 2-4 cpu constantly. Example: While 1 $msg = TrayGetMsg() Select Case $msg = 0 If $ipstring <> @IPAddress1 & @IPAddress2 & @IPAddress3 & @IPAddress4 Then _CheckIPs() ContinueLoop Case $msg = $connect _Connect() TrayItemSetState($connect, $tray_unchecked) Case $msg = $disconnect _Disconnect() EndIf ;Case $msg = $exititem ; ExitLoop EndSelect WEnd $ipstring = @IPAddress1 & @IPAddress2 & @IPAddress3 & @IPAddress4 is set inside _CheckIPs(). I've tried different solutins, but it seems that everything I try will utilize 2-4% CPU. I've also tried _DateDiff() before the $ipstring check, but _NowCalc() also uses CPU. Anyone got any ideas on how to solve this without utilizing the CPU?
-
I'm writing a tray based program, and for every different option the user selects, the icon changes... I add the #include"icon.ico" where icon.ico would be the icon name obviously... But when I compile the program with the offical autoit compiler it doesn't seem to include the icons... Any clue what I'm doing wrong?