AutoHotkey Community

It is currently May 24th, 2012, 8:37 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 139 posts ]  Go to page 1, 2, 3, 4, 5 ... 10  Next
Author Message
PostPosted: March 8th, 2007, 9:39 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
It will display the infos of the current tray icons:
exename, classname, hWnd, nMsg (:Message ID), uID (:Icon ID), idn (:Button ID)

1) Using idn, can Hide/Show the tray icons:
HideTrayIcon(idn, True/False)

Can still control the trayicon after hidden, e.g., right-click:
PostMessage, nMsg, uID, 0x204, , ahk_id %hWnd%
PostMessage, nMsg, uID, 0x205, , ahk_id %hWnd%

2) Using 1-based index, can rearrage the trayicon from idxOld to idxNew:
MoveTrayIcon(idxOld, idxNew)

Actually, it can appy equally to task buttons too, replacing the last 1 in ToolbarWindow321 with appropriate number.

DOWNLOAD TrayIcon.ahk.


Last edited by Sean on August 21st, 2007, 6:06 am, edited 11 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 9:54 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Kewl. I was looking at MSDN and I noted that adding tray icos can be done too.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 10:14 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
Kewl. I was looking at MSDN and I noted that adding tray icos can be done too.

Yes, basically using the same Shell_NotifyIcon, but need to provide more informations. The most important one may be hIcon. As a matter of fact, TrayIcons() function can extract hIcon too, so, can add back the deleted tray icons, in principle. However, there is one glitch: hIcon is not always the correct one for some apps, e.g., Process Explorer etc. So, I decided to not implement it.

May consider using HideTrayIcon(idn, true/false) (:note idn, it's not idx) instead. However, the traybar won't resize even after hiding a trayicon.
(:This symptom is now cured, so, it would be a better solution now.)


Last edited by Sean on March 9th, 2007, 8:26 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 11:42 am 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
So, are you going to do Adding tray icons or me ?

I imagine this interface for the start:

Code:
AddTrayIcon( iconPath, onMouseLeft, onMouseRight="", onMouseMove="" )


with iconPath that can be specified as string or number in which case icon handle should be seen.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 1:39 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
majkinetor wrote:
So, are you going to do Adding tray icons or me ?

What purpose do you have in mind to add tray icons?
I may add an option to restore the tray icons removed although it won't work always. But, I don't have any further plan. So, I suppose it's up to you.

Code:
AddTrayIcon( iconPath, onMouseLeft, onMouseRight="", onMouseMove="" )

Basically, need hWnd, MessageID, and IconID which controls the tray icon and communicate with the shell. I think this can be done using OnMessage().
And, yes, then hIcon and sTooltip.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 2:08 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Quote:
What purpose do you have in mind to add tray icons?

You mean, besides setting multiple tray icons per script and things like that ? Like, CPU usage and MEM usage ? Script creating custom menus, and eatch menu being able to represent itself via tray ? I mean... why the fuk do you need tray icons in windows at all....

Quote:
So, I suppose it's up to you.

i suppose...

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 8th, 2007, 2:22 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
As a matter of fact, I seldom use tray icons. The purpose of this script was to not click tray icons, at least for me.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2007, 5:28 pm 
Offline

Joined: July 15th, 2006, 1:30 am
Posts: 48
Excellent Script Sean! I was looking something like this for months.
This can be utilized for a complete boss mode script in order to hide all running processes instead of terminating them.

Thanks again for these wonderful functions. :)

_________________
One hotkey to rule them all!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2007, 11:14 pm 
Offline

Joined: March 10th, 2007, 10:59 pm
Posts: 1
Location: Romania
Sean's RemoveTrayIcon function (see above) already does AddTrayIcon, as long as it's passed the proper parameters.

For example, if one were to add this to Sean's script:
Code:
Process, Exist
WinGet, hWnd,, ahk_pid %ErrorLevel%
RemoveTrayIcon(hWnd,999,0,0,0)
you would already have a new blank icon. I changed the hWnd to the current one, the uID to a random one, a blank nMsg, a blank hIcon and the command to ADD (which is 0, while MODIFY is 1 and REMOVE is 2).

An interesting script would be the following:
Code:
#Persistent
DetectHiddenWindows, On
Process, Exist
WinGet, hWnd,, ahk_pid %ErrorLevel%
AddTrayIcon(hWnd,101,0,0,0)
AddTrayIcon(hWnd,102,0,0,0)
AddTrayIcon(hWnd,103,0,0,0)


AddTrayIcon(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
   VarSetCapacity(ni, 68, 0)
   EncodeInteger(&ni + 0, VarSetCapacity(ni))
   EncodeInteger(&ni + 4, hWnd)
   EncodeInteger(&ni + 8, uID)
   EncodeInteger(&ni +12, 1|2|4)
   EncodeInteger(&ni +16, nMsg)
   EncodeInteger(&ni +20, hIcon)
   DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
}


EncodeInteger(ref, val, nSize = 1)
{
   DllCall("ntdll\RtlFillMemoryUlong", "Uint", ref, "Uint", nSize * 4, "Uint", val)
}

Why would anyone want that? Well, there are some people who place controls on the taskbar and need some "spacers"...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2007, 4:33 am 
is there a way to use this to get the tooltip of a perticular icon?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2007, 5:04 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
Quote:
is there a way to use this to get the tooltip of a perticular icon?

Sure. Use exename like
Code:
TrayIcons("autohotkey.exe")

If there exist multiple instances, it will also produce multiple results.

Now, I suppose it's easy to edit it to fit the need.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 24th, 2007, 10:30 pm 
Oh, ok.

I did it a different way, retrieving all the info then searching it for the strings I needed, but it looks like your way is a lot faster.

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2007, 12:17 am 
Impressing. Thx for sharing it. 8)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2007, 4:19 pm 
Offline

Joined: October 9th, 2004, 8:55 pm
Posts: 217
Location: Budapest, Hungary
Thanks for this script. It's just what I needed. There was an application which appeared from time to time in the tray, but it disappeared in 1 sec, so I couldn't click on it to determine what it is.

I added this code to the beginning of the script to pop up a message box when a new icon appears in the tray:
Code:
prevtray =
loop
{
  tr := TrayIcons()
  if (tr <> prevtray)
    MsgBox % tr
  prevtray := tr
  sleep 1000
}

and put this code before the line "sTrayIcons .= ..." to filter out my usual programs:
Code:
      if (instr(sTooltip, "volume") or ...)
                   continue

The misterious program turned to be the autoupdater of my firewall.

Thanks again for this script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 25th, 2007, 7:57 pm 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1865
Quote:
What purpose do you have in mind to add tray icons?
there was a time when when i wanted to write my own small, custom shell to replace explorer. the roadblock i faced was that i didn't know how to add tray icons of applications (well, dllcall wasn't there in ahk at that time either).
now that could be one use.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 139 posts ]  Go to page 1, 2, 3, 4, 5 ... 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: lblb, Scratch, teadrinker and 20 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