erbailey Posted February 2, 2007 Share Posted February 2, 2007 Is there any way to check the System tray to see if a program is running or not? Link to comment Share on other sites More sharing options...
Helge Posted February 2, 2007 Share Posted February 2, 2007 System-tray ? Ehmm... try using ProcessExists instead. Link to comment Share on other sites More sharing options...
erbailey Posted February 6, 2007 Author Share Posted February 6, 2007 Well... the reason being is that there is two states. Its a Cisco VPN device. In the process list it shows up as vpngui.exe which is fine, however I want to know if its running or not. When it is not running, it shows up as a yellow padlock in the systray thats unlocked. When Its connected it shows up as a green lock. If you mouseover, the following text is shown respectfully "RSVPN Dialer - Disconnected" or "RSVPN Dialer - Connected" I was just curious if there was any way at all, to check whether its connected or disconnected I hope this explains well enough... if not let me know Link to comment Share on other sites More sharing options...
/dev/null Posted February 6, 2007 Share Posted February 6, 2007 Well... the reason being is that there is two states. Its a Cisco VPN device. In the process list it shows up as vpngui.exe which is fine, however I want to know if its running or not. When it is not running, it shows up as a yellow padlock in the systray thats unlocked. When Its connected it shows up as a green lock. If you mouseover, the following text is shown respectfully "RSVPN Dialer - Disconnected" or "RSVPN Dialer - Connected"I was just curious if there was any way at all, to check whether its connected or disconnected I hope this explains well enough... if not let me knowCisco VPN Client has commandline parameters. I bet there is one to get the connection state! __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
PhyrePhoX Posted March 15, 2007 Share Posted March 15, 2007 hm, i also stumbled about a similar problem: in our office we use cardreaders and cards with our pgp keys on them. in order to encrypt/decrypt mails, we have to put our ID cards into the cardreader. when it's time to go home or go out for lunch we often forget to take back the ID cards - thus we cannot enter the building anymore because we need them to open the door so i thought i'd write a script that activates the systemspeaker with a loud beep - whenever you either lock your workstation and leave the card in the reader or shutdown and leave the card in the reader. now here's the problem: there is no commandline tool or program to figure out the state of the cardreader - or is there? otherwise i'd have to write a script that reads the color of the icon of "cardreader application" in the systray (yellow for "card in" and grey for "not present"). i hope you can follow me same problem as the threadcreator. thanks in advance Link to comment Share on other sites More sharing options...
war59312 Posted June 16, 2011 Share Posted June 16, 2011 (edited) Hi,I'd like to do something similar.I need to known if Ultra VNC's icon is in fact in the system tray.I know the process (WinVNC.exe) is already running so that lets me know if I need to even check. But how to check if the icon is there or not?The issue is that it runs itself twice:"C:\Program Files\UltraVNC\WinVNC.exe" -service"C:\Program Files\UltraVNC\WinVNC.exe" -service_runSo a way to detect if both are running would work too? At the moment I only know how to check if WinVNC.exe is running. Which of course it already is before it loads the icon.Thanks,Will Edited June 16, 2011 by war59312 Link to comment Share on other sites More sharing options...
Joon Posted June 16, 2011 Share Posted June 16, 2011 Cisco VPN creates a virtual network adapter. You can check on this network status to find out if you have VPN connection or not. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 16, 2011 Moderators Share Posted June 16, 2011 war59312, If the systray icon has a tooltip attached, you can find it using this: expandcollapse popup#Include <GuiToolBar.au3> Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here Global $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then MsgBox(16, "Error", "Icon not found in system tray") Else MsgBox(64, "Found", "Icon found in system tray") EndIf Exit ;............ Func Get_Systray_Index($sToolTipTitle) ; Find systray handle Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit 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 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc I hope it helps. M23 Deye 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
war59312 Posted June 16, 2011 Share Posted June 16, 2011 (edited) Hey,Indeed it does. Now to only figure out how to run:C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd" UltraVNC.cmdWhen the icon is found.I tried:$PID = Run(C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd" & "\UltraVNC.cmd", "", @SW_SHOW)But get a script error.Thanks again,Will Edited June 16, 2011 by war59312 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 16, 2011 Moderators Share Posted June 16, 2011 war59312, Try this - using single quotes to define the first parameter: $PID = Run('C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd" \UltraVNC.cmd', "", @SW_SHOW) M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
war59312 Posted June 16, 2011 Share Posted June 16, 2011 Whooooo! You the man, thanks a lot. I though I had tried that, guess not. Will post full script when I am done.. Thanks again.. Link to comment Share on other sites More sharing options...
war59312 Posted June 17, 2011 Share Posted June 17, 2011 Hey,Well, after a bit of learning curve here Is what I am currently using to fit my need of automating my Windows start-up routine. expandcollapse popup#Include <GuiToolBar.au3> AutoItSetOption("TrayIconHide", 1) Global $sToolTipTitle = "WinVNC" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here Global $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) Global $isWinvncRunning = "" ; Global $isHamachiRunning = "" ; If $iSystray_ButtonNumber = 0 Then $isWinvncRunning = "False" ;MsgBox(16, "Error", "winvnc is not running") $sToolTipTitle = "Hamachi" ; $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then $isHamachiRunning = "False" ;MsgBox(16, "Error", "Hamachi is not running") Else $isHamachiRunning = "True" ;MsgBox(16, "Error", "Hamachi is running") EndIf Else $isWinvncRunning = "True" ;MsgBox(16, "Error", "winvnc is running") $sToolTipTitle = "Hamachi" ; $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then $isHamachiRunning = "False" ;MsgBox(16, "Error", "Hamachi is not running") Else $isHamachiRunning = "True" ;MsgBox(16, "Error", "Hamachi is running") EndIf EndIf Select Case $isHamachiRunning = "True" And $isWinvncRunning = "True" ;MsgBox(0, "", "Both Are True") RunWait('C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd\scripts" ProcessExplorerTrueTrue.ahk', "", @SW_HIDE) Case $isHamachiRunning = "False" And $isWinvncRunning = "False" ;MsgBox(0, "", "Both Are False") RunWait('C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd\scripts" ProcessExplorerFalseFalse.ahk', "", @SW_HIDE) Case $isHamachiRunning = "True" And $isWinvncRunning = "False" ;MsgBox(0, "", "Hamachi is Is True And WinVNC Is False") RunWait('C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd\scripts" ProcessExplorerTrueFalse.ahk', "", @SW_HIDE) Case $isHamachiRunning = "False" And $isWinvncRunning = "True" ;MsgBox(0, "", "Hamachi Is False And WinVNC Is True") RunWait('C:\Windows\System32\HIDE.EXE /w c:\windows\syswow64\cmd.exe /c c:\windows\sysnative\cmd.exe /c start /b /w /D"C:\StartAndEnd\scripts" ProcessExplorerFalseTrue.ahk', "", @SW_HIDE) Case Else MsgBox(0, "", "Bug") EndSelect Exit ;............ Func Get_Systray_Index($sToolTipTitle) ; Find systray handle Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit 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 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFuncSo pretty simple really. It is checking to see if two products are running, Hamachi and WinVNC. Then running the correct AutoHotkey script to do a few things to Process Explorer when I boot up my computer.I'm also making use of Easy Macro Recorder @ http://www.flashplayerpro.com/MacroRecorder/ to do a few things. So using AutoIt, AutoHotkey, and Easy Macro Recorder. I'm sure AutoIt can probably do everything I need but don't know how, yet.I left a lot of extra stuff in there for my debugging needs. I'm just glad Windows finally (with Win7) remembers placement of system tray icons.Thanks for all the help.Will Link to comment Share on other sites More sharing options...
masCh Posted September 14, 2017 Share Posted September 14, 2017 (edited) On 16/06/2011 at 7:15 PM, Melba23 said: war59312, If the systray icon has a tooltip attached, you can find it using this: expandcollapse popup#Include <GuiToolBar.au3> Global $sToolTipTitle = "" ; <<<<<<<<<<<<<<<< Enter some tooltip text for the icon you want here Global $iSystray_ButtonNumber = Get_Systray_Index($sToolTipTitle) If $iSystray_ButtonNumber = 0 Then MsgBox(16, "Error", "Icon not found in system tray") Else MsgBox(64, "Found", "Icon found in system tray") EndIf Exit ;............ Func Get_Systray_Index($sToolTipTitle) ; Find systray handle Local $hSysTray_Handle = ControlGetHandle('[Class:Shell_TrayWnd]', '', '[Class:ToolbarWindow32;Instance:1]') If @error Then MsgBox(16, "Error", "System tray not found") Exit EndIf ; Get systray item count Local $iSystray_ButCount = _GUICtrlToolbar_ButtonCount($hSysTray_Handle) If $iSystray_ButCount = 0 Then MsgBox(16, "Error", "No items found in system tray") Exit 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 ; Not found Else Return $iSystray_ButtonNumber ; Found EndIf EndFunc I hope it helps. M23 Hi M23, this doesn't seem to work at all. It keeps saying Icon not found in system tray, regardless of what I changed the sToolTipTitle to. (I changed it to "Steam" because that's on the system tray and not in the overflow section). I have to use a right-click-close rather than processClose on this certain program (MSI Dragon Center). Edited September 14, 2017 by masCh -itisallinthemind- Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 15, 2017 Moderators Share Posted September 15, 2017 masCh, As I posted that code in 2011, I would have developed it on Win7 - later OSes significantly changed the way they deal with the systray (or notification area as it is now called) so I am not surprised that the code does not work nowadays. If I find time I might look into updating it, but I do not have a lot of spare time at present so do not hold your breath! M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
junkew Posted September 16, 2017 Share Posted September 16, 2017 Try faq 31 with uiautomation FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now