AutoHotkey Community

It is currently May 27th, 2012, 12:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: December 31st, 2010, 1:48 pm 
Offline

Joined: December 21st, 2007, 9:33 am
Posts: 10
I am looking for a way to automate going to the system tray and double-clicking the OpenVPN tray icon. This seems like a straightforward task, but I can't figure out how to do it with AHK yet :) Any pointers would be appreciated.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 2:03 pm 
Offline

Joined: October 11th, 2010, 6:15 pm
Posts: 1211
Location: Right behind you
There's two ways to do this and I can only hint at one. The first is to write a simple script that moves the mouse to the tray icon, and double clicks. This is a poor method at best as the mouse will always go to the same section of the screen and click whatever happens to be there. The other way you'l have to learn how to access programs in memory, loop through them untill you find your specific program, and make it visible.

The reason I bothered to write this down is this: your either asking for a very simple script or a very advance one.

Try this: go to your search window next to your url address bar (mine is set to google) and type "site:autohotkey.com <text you want to search within that site>" and add something like system tray access or whatever. Most likely something like this has already been thought of, tested, working, and available to the community.

_________________
COM Tutorial for Webpages
COM Tutorial for Excel


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 2:13 pm 
Offline

Joined: December 21st, 2007, 9:33 am
Posts: 10
Yes, I tried searching the forums and googling, and I did find lots of rather advanced stuff related to tray, but not quiet what I was seeking... Also, I didn't think that such a simple task would involve such complexity, but I might have been wrong about that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 2:36 pm 
Offline

Joined: May 12th, 2009, 2:37 pm
Posts: 640
Location: Gloucester UK
You could use the ImageSearch command to find the icon on the screen. This will give you the co-ordinates of the icon so that you can instruct AHK to click on it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 2:41 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
Extract Informations about TrayIcons
http://www.autohotkey.com/forum/topic17314.html

see postmessage example for right click

Won't simply running the exe do automatically the same as a double click on the tray icon?

Edit: Flak's suggestion below takes the prize (come to think of it that is how I do it too with some programs)

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Last edited by SoLong&Thx4AllTheFish on December 31st, 2010, 2:54 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 2:43 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Code:
SetTitleMatchMode, 2
DetectHiddenWindows, On

#z::
IfWinExist OpenVPN
WinActivate
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 10:49 pm 
Offline

Joined: December 21st, 2007, 9:33 am
Posts: 10
flak's suggestion is brilliant, but for some reason doesn't work

Here's what I get from window spy when I double-click on the tray icon:
>>>>>>>>>>( Window Title & Class )<<<<<<<<<<<
OpenVPN Connection (client)
ahk_class #32770
....

Not sure why it's failing to match on OpenVPN...

Running .exe doesn't work -- openvpn says it's already running and barfs.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2010, 10:56 pm 
Offline

Joined: May 1st, 2010, 6:01 pm
Posts: 1020
Location: England
Quote:
You could use the ImageSearch command to find the icon on the screen. This will give you the co-ordinates of the icon so that you can instruct AHK to click on it.


this


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 14th, 2011, 12:25 pm 
Offline

Joined: May 12th, 2009, 3:36 pm
Posts: 27
I had the same question and found this thread... and the solution (thanks to this thread ;))

I am using Everything, but not as an admin. It starts automatically with windows into the system try and I have to say "Yes" to the UAC...).

Now I want to open this programm in the system tray via shortcut, not by using the mouse via double click.

This code works for me:
Code:
!.::
   IfWinExist, ahk_class EVERYTHING_TASKBAR_NOTIFICATION
   {
      WinActivate
      PostMessage, 1025, 0, 0x0203
   }
   else
      msgbox, Everything is not open
return


I got the values from TrayIcon.ahk (see link above to http://www.autohotkey.com/forum/topic17314.html respectively http://www.autohotkey.net/~Sean/Scripts/TrayIcon.zip)

1025 = Message ID for the system tray icon of Everything
0 = uID
0x0203 = WM_LBUTTONDBLCLK


Bye, Carlos


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Google Feedfetcher, Yahoo [Bot] and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group