Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Extract Informations about TrayIcons


  • Please log in to reply
149 replies to this topic
badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005
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?

  • Guests
  • Last active:
  • Joined: --
Use it after replacing app.exe with the name of your app.
^t::RegExMatch(TrayIcons("app.exe"), "(?<=idn: )\d+", idn), HideTrayIcon(idn, bHide:=!bHide)


badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005

Use it after replacing app.exe with the name of your app.

^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?

  • Guests
  • Last active:
  • Joined: --

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 (=8).

  • Guests
  • Last active:
  • Joined: --
After replacing inside TrayIcons() function
" | idn: " . idn
with
" | idn: " . idn . " | Statyle: " . Statyle
you can use
^t::RegExMatch(TrayIcons("app.exe"), "idn: (?<idn>\d+).*?Statyle: (?<Statyle>\d+)", TB_), HideTrayIcon(TB_idn, !(TB_Statyle&8))


badmojo
  • Members
  • 204 posts
  • Last active: Jul 23 2014 01:39 AM
  • Joined: 11 Nov 2005
thanks again, Mr. Guest. ;) but i'm confused by the variable "Statyle", is it actually "State" or "Style"?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006
It is, as the name implies, a combination of state and style.

Instead of
Statyle := NumGet(btn, 8)
;...
" | idn: " . idn . " | Statyle: " . Statyle
it would be more logical to use
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.)

Z Gecko
  • Guests
  • Last active:
  • Joined: --
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:
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 ([color=red]([/color]sClass <> "SysPager"[color=red]) and (sClass <> "TrayNotifyWnd")[/color])
			Continue
		idxTB := A_Index
			Break
	}

	Return	idxTB
}


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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.

Z Gecko
  • Guests
  • Last active:
  • Joined: --
Cool,
your new version works fine for me! 8)

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Cool, your new version works fine for me! 8)

Good. BTW, the current GetTrayBar() may the slowest one among possible methods, so if you ever experience a performance problem, please let me know.

ACoder
  • Guests
  • Last active:
  • Joined: --
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,

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.

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!

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

RemoveTrayIcon(hWnd,0,0,0,2)

You need to specify uID too. The correct syntax is
RemoveTrayIcon(hWnd, uID)


ACoder
  • Guests
  • Last active:
  • Joined: --
Ah, ok :oops:

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? :)

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

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.
MsgBox % TrayIcons("myprogram.exe")