Search the Community
Showing results for tags 'systray'.
Found 2 results
One of my GUI applications requires that a particular third-party application not only be running, but be present in the "sys tray" (aka Taskbar). When this 3p app is active but not in the systray/taskbar, it is not ready for proper use, and I must inform the user about this. Here is a code snippet that used to work fine under Windows 7: ; ; #FUNCTION# ========================================================================================================= ; Name...........: _Get_Systray_BtnIndex ; Description ...: Determines if an appllication with the specified title is running in the Systen Tray ; and if so, returns the relative index number of it's button on the tray. ; Syntax.........: _Get_Systray_BtnIndex($iTitleText) ; Parameters ....: $iTitleText -> The (tool-tip) title of the desired application ; Return values .: Success - Returns the index number of the desired appliction button, 1 being the first ; Failure - Returns 0 if desired application is not found in the System Tray ; Sets @error as follows: ; 0: Normal return ; -1: System Tray was empty (i.e., no appllications running the tray) ; -2: No System Tray was found ; Remarks .......; Setting any parameter to -1 leaves the current value unchanged ; Setting the $iStyle parameter to 'Default' resets ALL parameters to default values <<<<<<<<<<<<<<<<<<<<<<< ; Setting any other parameter to "Default" only resets that parameter ; Author ........: Poster "war59312", and code was found at URL: ; http://www.autoitscript.com/forum/topic/40550-check-if-program-is-running-under-system-tray/#entry902746 ; Modified by mjb on 26-June-2014 to return @extended error code rather than using MsgBox() to report errors. ; Func _Get_Systray_BtnIndex($sToolTipTitle) ; Find systray handle Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then Return SetError( -2, 0, 0 ) EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then Return SetError( -1, 0 , 0 ) EndIf ; Look for wanted tooltip For $iSystray_ButtonNumber = 0 To $iSystray_ButCount - 1 If StringInStr(_GUICtrlToolbar_GetButtonText($hSysTray_Handle, $iSystray_ButtonNumber), $sToolTipTitle) > 0 Then ExitLoop Next If $iSystray_ButtonNumber = $iSystray_ButCount Then Return 0 ; Desired application is NOT running in the System Tray Else Return $iSystray_ButtonNumber ; Application was found in the SysTray EndIf EndFunc ;==> _Get_Systray_BtnIndex ; But what's happening under Windows 10 is that the "_GUICtrlToolbar_ButtonCount()" always returns 1, even though there are 10-14 items visible in the Task Bar. Unsurprisingly, the single item returned has nothing to do with the 3'rd party application in question. As you probably know, Microsoft made significant changes to the systray/taskbar since Windows 7 (or at least by Windows 10). I spent quite a while searching MSDN for some other way to accomplish what I need, but I must be too stupid to figure it out. Please help. Thanks!
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?