 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Wed Feb 06, 2008 5:24 am Post subject: |
|
|
i came to know about this script from here but i'd like how to single out a particular app and use hot-key to toggle show/hide the tray icon? i tried "Process, Exist" but not sure how to get it to return the idn.
also, will the idn be consistent throughout the session? |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Feb 06, 2008 6:43 am Post subject: |
|
|
Use it after replacing app.exe with the name of your app.
| Code: | | ^t::RegExMatch(TrayIcons("app.exe"), "(?<=idn: )\d+", idn), HideTrayIcon(idn, bHide:=!bHide) |
|
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Wed Feb 13, 2008 10:18 am Post subject: |
|
|
| Anonymous wrote: | Use it after replacing app.exe with the name of your app.
| Code: | | ^t::RegExMatch(TrayIcons("app.exe"), "(?<=idn: )\d+", idn), HideTrayIcon(idn, bHide:=!bHide) |
|
thanks for the above code but somehow it only works for visible icons but not for those already hidden by WinXP. is it possible to detect the icon's status and toggle the hidden status before applying this AHK hide method? |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Feb 13, 2008 3:23 pm Post subject: |
|
|
| badmojo wrote: | | is it possible to detect the icon's status and toggle the hidden status before applying this AHK hide method? |
The variable Statyle contains that information, TBSTATE_HIDDEN (= . |
|
| Back to top |
|
 |
Guest
|
Posted: Wed Feb 13, 2008 3:34 pm Post subject: |
|
|
After replacing inside TrayIcons() function
with
| Code: | | " | idn: " . idn . " | Statyle: " . Statyle |
you can use
| Code: | | ^t::RegExMatch(TrayIcons("app.exe"), "idn: (?<idn>\d+).*?Statyle: (?<Statyle>\d+)", TB_), HideTrayIcon(TB_idn, !(TB_Statyle&8)) |
|
|
| Back to top |
|
 |
badmojo
Joined: 11 Nov 2005 Posts: 202
|
Posted: Thu Feb 14, 2008 2:42 am Post subject: [b][/b] |
|
|
thanks again, Mr. Guest. but i'm confused by the variable "Statyle", is it actually "State" or "Style"? |
|
| Back to top |
|
 |
Lexikos
Joined: 17 Oct 2006 Posts: 7299 Location: Australia
|
Posted: Thu Feb 14, 2008 4:54 am Post subject: |
|
|
It is, as the name implies, a combination of state and style.
Instead of | Code: | Statyle := NumGet(btn, 8)
;...
" | idn: " . idn . " | Statyle: " . Statyle | it would be more logical to use | Code: | State := NumGet(btn, 8, "uchar")
Style := NumGet(btn, 9, "uchar")
;...
" | idn: " . idn . " | State: " . State . " | Style: " . Style | (or just state if you don't need style.) |
|
| Back to top |
|
 |
Z Gecko Guest
|
Posted: Wed Jun 11, 2008 5:15 pm Post subject: |
|
|
I just played around with this nice script,
and it didnīt work on my german Win2000 System.
I had to modify the GetTrayBar-Function to get it to work:
| Code: | GetTrayBar()
{
WinGet, ControlList, ControlList, ahk_class Shell_TrayWnd
RegExMatch(ControlList, "(?<=ToolbarWindow32)\d+(?!.*ToolbarWindow32)", nTB)
Loop, %nTB%
{
ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
hParent := DllCall("GetParent", "Uint", hWnd)
WinGetClass, sClass, ahk_id %hParent%
If ((sClass <> "SysPager") and (sClass <> "TrayNotifyWnd"))
Continue
idxTB := A_Index
Break
}
Return idxTB
} |
|
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Wed Jun 11, 2008 11:20 pm Post subject: |
|
|
| Z Gecko wrote: | I just played around with this nice script,
and it didnīt work on my german Win2000 System.
I had to modify the GetTrayBar-Function to get it to work: |
That's too bad. I rewrote the function using IsChild API and uploaded the new one. You may try it. One thing though: it's based on the assumption that TrayNotifyWnd has only one child ToolbarWindow32. |
|
| Back to top |
|
 |
Z Gecko Guest
|
Posted: Wed Jun 11, 2008 11:36 pm Post subject: |
|
|
Cool,
your new version works fine for me!  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Thu Jun 12, 2008 12:20 am Post subject: |
|
|
| Z Gecko wrote: | Cool, your new version works fine for me!  |
Good. BTW, the current GetTrayBar() may the slowest one among possible methods, so if you ever experience a performance problem, please let me know. |
|
| Back to top |
|
 |
ACoder Guest
|
Posted: Sun Jul 13, 2008 9:38 pm Post subject: |
|
|
Can someone please show me how to use the RemoveTrayIcon command?
I think I am doing it almost right, but it doesn't work....
For the program I want to use this on, I am first using this to ascertain the hWnd on the program class, which works,
| Code: |
WinGet, hWnd,, %insert_ahk_Class%
|
I am getting a hWnd var back, like a 0x183839, so it seems to find the program...
but, running this command next, doesn't seem to do anything.
| Code: |
RemoveTrayIcon(hWnd,0,0,0,2)
|
What could I be missing here? I am not sure about the syntax above If anyone could help point me in right direction it would be greatly appreciated! Thanks! |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Sun Jul 13, 2008 11:54 pm Post subject: |
|
|
| ACoder wrote: | | Code: | | RemoveTrayIcon(hWnd,0,0,0,2) |
| You need to specify uID too. The correct syntax is
| Code: | | RemoveTrayIcon(hWnd, uID) |
|
|
| Back to top |
|
 |
ACoder Guest
|
Posted: Mon Jul 14, 2008 7:41 pm Post subject: |
|
|
Ah, ok
Sorry Sean, I am still learning about the various identifiers for applications, .... can you clear me up?
The UID (Unique ID).... is this something I can set for a application I am running? so if I run a
run, myprogram.exe
is there some additional part to the run command which sets a UID? or no? how do i find out the UID for the program i have in mind?  |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Mon Jul 14, 2008 11:08 pm Post subject: |
|
|
| ACoder wrote: | how do i find out the UID for the program i have in mind?  | You can obtain uID of your application's trayicon using the following. Probably you need to run it only once as uID is pretty constant with many apps.
| Code: | | MsgBox % TrayIcons("myprogram.exe") |
|
|
| 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
|