Jump to content

Click On Something In The Sys Tray?


Recommended Posts

I'm trying to pop up an app that's on the system tray, when I run the exe for the app, it just puts the systray icon in place, running it again doesn't launch the gui, apparently the only way to do that is to click the systray icon.

I've searched here for anything related, but couldn't find anything.

:iamstupid:

the spy only shows the classname of the tray (Shell_TrayWnd) but doesn't seem to change by which icon is under the mouse. Manually clicking the icon brings up the screen I want to see, but doesn't help me script it.

I can't garuntee that the propper tray icon will always be the rightmost icon, or that the clock might not have a different font sixe than my machine's... so sending a click to a coord doesn't make sense...

It doesn't seem like an odd request, to be able to click a specific tray icon... almost like it's something that could be built into autoit (if I'm just not finding it already)...

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

  • Developers

Do you know the window title for that program?

You probably can do something with WinGetState ( "title" [, "text"] ) and WinSetState ( "title", "text", flag )

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Tray icons are hard to work with. :D

What is the particular app? If you are lucky, there are special command line parameters to make the app pop up--it's unlikely, though.

Otherwise.... you can get the position of the taskbar (on windows xp at least) with On WinGetPos("","Notification Area"). You could try a pixel search if the icon has certain distinguishing colors; but resolution and color depth might be different on other computers.

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

JdeB: WinGetState returns 0 when it's minimized

CyberSlug: I agree, tray icons suck. So do apps with lame help files. It's checkpoint secure remote. As far as I can tell, there's no command line switches for it, certainly not detailed by a /? or looking in the help file.

I'm thinking I'll do a wingetstate to see if it's open and if it's not then try to click the icon as you suggested with a pixel search... hopefully the symantec shield isn't a similar enough yellow to the secure point key yellow (or any other damned icon it might have on the tray)

I'll let ya'all know what I come up with.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

easier way might be to check to see if process is loaded.

Checks to see if a specified process exists.

if ProcessExists ( "checkpoint.exe" ) then

then if so, do a pixel search I guess, and maybe when the gui is out you can check for that window first perhapse.

AutoIt3, the MACGYVER Pocket Knife for computers.

Link to comment
Share on other sites

  • Developers

JdeB:  WinGetState returns 0 when it's minimized

That would mean that the windows doesn exist..

What i was looking for is someting like this..

I run Eprompter in the taskbar and with this script i can show it:

$state=WinGetState("ePrompter")
If Not BitAnd($state, 2) Then
   MsgBox(0, "Example", "Window is Hidden")
   WinSetState("ePrompter",'',@SW_SHOW)
EndIf

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

gotta run to a meeting, will try what you suggested, here's what I wrote and the error I'm getting:

do
   $getgui = WinGetState("VPN-1 SecureClient", 'For Help, press F1')

   if $getgui < 7 then
      $tray = WinGetPos("", "Notification Area" )
   msgbox(0, "tray","coords " & $tray[0] & @LF & $tray[1] & @LF  & $tray[2] & @LF  & $tray[3])
      $yellow = PixelSearch($tray[2], $tray[3], $tray[0], $tray[1], 0x00FFFF)
      If Not @error Then
          MsgBox(0, "X and Y are:", $yellow[0] & "," & $yellow[1])
      EndIf
      MouseClick("left", $yellow[0] , $yellow[1] ,1) 
   endif

until $getgui = 7

---------------------------
AutoIt Error
---------------------------
Line 43  (File "\\spseprt1\windist\ITProcedures\autoit\checkpoint\configsite.au3"):

MouseClick("left", $yellow[0] , $yellow[1] ,1)
MouseClick("left", $yellow^ ERROR

Error: Subscript used with non-Array variable.
---------------------------
OK   
---------------------------

so, it's not finding the yellow pixel, but when I mouseover it, the spy tells me it's there.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

  • Developers

changed you pixelsearch and mouseclick statements...

do
  $getgui = WinGetState("VPN-1 SecureClient", 'For Help, press F1')

  if $getgui < 7 then
     $tray = WinGetPos("", "Notification Area" )
      msgbox(0, "tray","coords " & $tray[0] & @LF & $tray[1] & @LF  & $tray[2] & @LF  & $tray[3])
     $yellow = PixelSearch($tray[0], $tray[1], $tray[0]+$tray[2], $tray[1]+$tray[3], 0x00FFFF)
     If Not @error Then
         MsgBox(0, "X and Y are:", $yellow[0] & "," & $yellow[1])
     else
         MouseClick("left", $yellow[0] , $yellow[1] ,1) 
     EndIf
  endif

until $getgui = 7
Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

There HAS to be a Window somewhere for the tray icon to call back to. It may be a child Window, though, so open that window by clicking the tray icon, then get the title of it. Use Opt("WinSearchChildren", 1) at the top of the script, then try a WinActivate or WinSetState with @SW_SHOW on that window.

Link to comment
Share on other sites

ok, thanks for the correction to my pixel search/mouse click (had a fun moment there where it worked, but just kept finding the textpad window and clicking it over and over)

I'm going to try @sw_show now. I'm hoping that works, since the pixel search obviously has some 'quirks'

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

ok, here's to doing it the hard way first. :)

messy with my old code

do
   $getgui = WinGetState("VPN-1 SecureClient", 'For Help, press F1')

   if $getgui < 7 then
;kludged method using pixel search
;      $tray = WinGetPos("", "Notification Area" )
;  ;msgbox(0, "tray","coords " & $tray[0] & @LF & $tray[1] & @LF  & $tray[2] & @LF  & $tray[3])
;      $yellow = PixelSearch($tray[0], $tray[1], $tray[0]+$tray[2], $tray[1]+$tray[3], 0x00FFFF)
;      If Not @error Then
;      MouseClick("left", $yellow[0] , $yellow[1] ,1) 
;    ;else MsgBox(0, "Error", "Script can't find checkpoint tray icon. please click the tray icon or otherwise get the secure client window up.  then click ok")
;      EndIf
;

WinSetState ("VPN-1 SecureClient","",@SW_SHOW)
WinActivate("VPN-1 SecureClient","")
   endif

until $getgui = 7

Cleaned up

do
   $getgui = WinGetState("VPN-1 SecureClient", 'For Help, press F1')

   if $getgui < 7 then

   WinSetState ("VPN-1 SecureClient","",@SW_SHOW)
   WinActivate("VPN-1 SecureClient","")
   endif
until $getgui = 7


;ControlClick("VPN-1 SecureClient", "", "AfxControlBar421", "Left",1); that didn't work, non standard control
WinMenuSelectItem("VPN-1 SecureClient", "", "&Sites" , "Create &New")
WinWait("Create New Site")
WinActivate("Create New Site")
ControlClick("Create New Site","","Button4")
ControlSend("Create New Site", "", "Edit2", "PSE NG")
ControlSend("Create New Site", "", "Edit1", "IP.Address")
ControlClick("Create New Site","","Button5")
MsgBox(0, "PSE VPN", "The script is done.  Enter your username and password and confirm the thumbprint")

this was my first time in v3 sending text with controlsend, I gotta say that's freaking cool. so much better than the old tab around the form method... :D

:huh2:

thanks to all for your help.

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

That code looks dangerous to me. You're checking for the Window state to be something but you are also changing the state inside the script. I smell potential for infinite loop. The top part would probably be safer as:

While Not BitAND(WinGetState("VPN-1 SecureClient", 'For Help, press F1'), 1)
    Sleep(50)
Wend

WinSetState ("VPN-1 SecureClient","",@SW_SHOW)
WinActivate("VPN-1 SecureClient","")

; Rest of the script
Link to comment
Share on other sites

yeah, I put a pause in there after it took forever to get the machine to boot... thanks for the suggestion, I'll look at how I did it again.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

That code looks dangerous to me.  You're checking for the Window state to be something but you are also changing the state inside the script.  I smell potential for infinite loop.  The top part would probably be safer as:

While Not BitAND(WinGetState("VPN-1 SecureClient", 'For Help, press F1'), 1)
    Sleep(50)
Wend

WinSetState ("VPN-1 SecureClient","",@SW_SHOW)
WinActivate("VPN-1 SecureClient","")

; Rest of the script
I noticed the machines taking forever to boot even with my sleep line inserted, so I pasted in your method, recompiled the exe and am now watching the machine take forever to boot... (did I mention this is going into the runonce key?) this'd be another case where it'd be handy to know when windows is fully loaded.

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

so, while it's hidden, the WinGetState returns a 0... shouldn't the script read:

While Not BitAND(WinGetState("VPN-1 SecureClient", 'For Help, press F1'), 0)
   Sleep(250)
Wend

WinSetState ("VPN-1 SecureClient","",@SW_SHOW)
WinActivate("VPN-1 SecureClient","")

???

even bigger question, why am I still here? it's quitting time....

thanks for all the help all! Have a great weekend!

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

daaayum, it's always the little things... when it's hidded it doesn't have window text... fixed that, it works after boot, will test other monday.

peace

"I'm not even supposed to be here today!" -Dante (Hicks)

Link to comment
Share on other sites

I only cared about whether it existed or not. I was only testing the existence bit and if it was NOT set, then it looped. The return value for WinGetState should really be tested with bitwise operators, not whole numbers.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...