 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Sean
Joined: 12 Feb 2007 Posts: 2185
|
Posted: Thu Mar 08, 2007 8:39 am Post subject: Extract Informations about TrayIcons |
|
|
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 Tue Aug 21, 2007 5:06 am; edited 11 times in total |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4114 Location: Belgrade
|
Posted: Thu Mar 08, 2007 8:54 am Post subject: |
|
|
Kewl. I was looking at MSDN and I noted that adding tray icos can be done too. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2185
|
Posted: Thu Mar 08, 2007 9:14 am Post subject: |
|
|
| 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 Fri Mar 09, 2007 7:26 am; edited 1 time in total |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4114 Location: Belgrade
|
Posted: Thu Mar 08, 2007 10:42 am Post subject: |
|
|
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. _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2185
|
Posted: Thu Mar 08, 2007 12:39 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 4114 Location: Belgrade
|
Posted: Thu Mar 08, 2007 1:08 pm Post subject: |
|
|
| 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... _________________
 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2185
|
Posted: Thu Mar 08, 2007 1:22 pm Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
XavierGr
Joined: 15 Jul 2006 Posts: 43
|
Posted: Sat Mar 10, 2007 4:28 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
Aurelain
Joined: 10 Mar 2007 Posts: 1 Location: Romania
|
Posted: Sat Mar 10, 2007 10:14 pm Post subject: |
|
|
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"... |
|
| Back to top |
|
 |
raven-gm Guest
|
Posted: Mon Mar 19, 2007 3:33 am Post subject: |
|
|
| is there a way to use this to get the tooltip of a perticular icon? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2185
|
Posted: Mon Mar 19, 2007 4:04 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
raven-gm Guest
|
Posted: Sat Mar 24, 2007 9:30 pm Post subject: |
|
|
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! |
|
| Back to top |
|
 |
BoBo Guest
|
Posted: Sat Mar 24, 2007 11:17 pm Post subject: |
|
|
Impressing. Thx for sharing it.  |
|
| Back to top |
|
 |
keyboardfreak
Joined: 09 Oct 2004 Posts: 196 Location: Budapest, Hungary
|
Posted: Sun Mar 25, 2007 3:19 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1687
|
Posted: Sun Mar 25, 2007 6:57 pm Post subject: |
|
|
| 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. _________________
 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|