AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Extract Informations about TrayIcons
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
badmojo



Joined: 11 Nov 2005
Posts: 143

PostPosted: Wed Feb 06, 2008 6:24 am    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Wed Feb 06, 2008 7:43 am    Post subject: Reply with quote

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: 143

PostPosted: Wed Feb 13, 2008 11:18 am    Post subject: Reply with quote

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
View user's profile Send private message
Guest






PostPosted: Wed Feb 13, 2008 4:23 pm    Post subject: Reply with quote

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 (=Cool.
Back to top
Guest






PostPosted: Wed Feb 13, 2008 4:34 pm    Post subject: Reply with quote

After replacing inside TrayIcons() function
Code:
" | idn: " . idn
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: 143

PostPosted: Thu Feb 14, 2008 3:42 am    Post subject: [b][/b] Reply with quote

thanks again, Mr. Guest. Wink but i'm confused by the variable "Statyle", is it actually "State" or "Style"?
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 2558
Location: Australia, Qld

PostPosted: Thu Feb 14, 2008 5:54 am    Post subject: Reply with quote

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
View user's profile Send private message
Z Gecko
Guest





PostPosted: Wed Jun 11, 2008 6:15 pm    Post subject: Reply with quote

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: 1337

PostPosted: Thu Jun 12, 2008 12:20 am    Post subject: Reply with quote

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
View user's profile Send private message
Z Gecko
Guest





PostPosted: Thu Jun 12, 2008 12:36 am    Post subject: Reply with quote

Cool,
your new version works fine for me! Cool
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1337

PostPosted: Thu Jun 12, 2008 1:20 am    Post subject: Reply with quote

Z Gecko wrote:
Cool, your new version works fine for me! Cool

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
View user's profile Send private message
ACoder
Guest





PostPosted: Sun Jul 13, 2008 10:38 pm    Post subject: Reply with quote

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 Sad If anyone could help point me in right direction it would be greatly appreciated! Thanks!
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1337

PostPosted: Mon Jul 14, 2008 12:54 am    Post subject: Reply with quote

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
View user's profile Send private message
ACoder
Guest





PostPosted: Mon Jul 14, 2008 8:41 pm    Post subject: Reply with quote

Ah, ok Embarassed

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? Smile
Back to top
Sean



Joined: 12 Feb 2007
Posts: 1337

PostPosted: Tue Jul 15, 2008 12:08 am    Post subject: Reply with quote

ACoder wrote:
how do i find out the UID for the program i have in mind? Smile
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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, 4, 5  Next
Page 3 of 5

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group