 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
King_254 Guest
|
Posted: Wed Jan 27, 2010 2:00 pm Post subject: |
|
|
Hello Sean,
I find your solution to hide tray icons of other programs really genius idea, but it has 2 bug, at least under W7
-If always show all icons and notifications on the taskbar is disabled then it wont work anymore.
-If enabled then it works but it will leave an empty space.
Here is the script I use, maybe something wrong with it? And if not will you consider updating your function?
| Code: | DetectHiddenWindows,On
#Include TrayIcon.ahk
Settimer, Winamp, 1000
Winamp:
Process, Exist, Winamp.exe
Sleep, 3000
{
RegExMatch(TrayIcons("winamp.exe"), "(?<=idn: )\d+", idn)
HideTrayIcon(idn)
}
Process, WaitClose, winamp.exe
Return |
|
|
| Back to top |
|
 |
nehnehpork Guest
|
Posted: Thu Jan 28, 2010 5:25 am Post subject: |
|
|
hi,
i'm also interested in seeing this useful script updated for windows 7 |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Sun Jan 31, 2010 5:41 am Post subject: |
|
|
| Quote: | | -If always show all icons and notifications on the taskbar is disabled then it wont work anymore. |
This is not a bug, just the internal op was changed in Win7. I myself always disable the notification area and retrieve the tray icon infos from NotifyIconOverflowWindow, not through Shell_TrayWnd in Win7. |
|
| Back to top |
|
 |
nehnehpork Guest
|
Posted: Sun Jan 31, 2010 6:40 am Post subject: |
|
|
| hi sean, how did u make the script work for NotifyIconOverflowWindow? |
|
| Back to top |
|
 |
King_254 Guest
|
Posted: Sun Jan 31, 2010 8:48 am Post subject: |
|
|
| Sean wrote: | | This is not a bug, just the internal op was changed in Win7. I myself always disable the notification area and retrieve the tray icon infos from NotifyIconOverflowWindow, not through Shell_TrayWnd in Win7. |
How about the empty space it leaves? |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 2462
|
Posted: Sun Jan 31, 2010 11:05 am Post subject: |
|
|
Replace inside the TrayIcons() all occurence of:
| Code: | Shell_TrayWnd -> NotifyIconOverflowWindow
ToolbarWindow32%idxTB% -> ToolbarWindow321 ; idxTB := GetTrayBar() no longer needed. |
| Quote: | | How about the empty space it leaves? | I haven't noticed it, I said I always disabled it. Anyway, it just means that the old method I used to update the taskbar/traybar is not working in Win7, so you have to find out other way to update it. |
|
| Back to top |
|
 |
ykk Guest
|
Posted: Tue Feb 02, 2010 11:27 am Post subject: |
|
|
from my experience, i can remove the icon and the empty space with the script found in this forum (read http://www.autohotkey.com/forum/topic52523.html&highlight=windows++tray )
however, it deletes the allocated tray space and cannot be restored automatically unlike ex-win7 os where u can use hide and unhide to do that. i have an idea on how to solve this problem:
1/. read all info about the icon ( here, i'm having problems in reading the icon file, ie which .ico is in used rather then embedded icons)
2/. delete the icon and empty space
3/. store the removed icon details in memory or array and recreate the space and icon later when u want them
until now, i still have no idea on how to retrieve the related ico file
hope this help |
|
| Back to top |
|
 |
nehnehpork Guest
|
Posted: Thu Feb 04, 2010 5:41 am Post subject: |
|
|
| Sean wrote: | Replace inside the TrayIcons() all occurence of:
| Code: | Shell_TrayWnd -> NotifyIconOverflowWindow
ToolbarWindow32%idxTB% -> ToolbarWindow321 ; idxTB := GetTrayBar() no longer needed. |
|
thanx sean, works great  |
|
| Back to top |
|
 |
Michael@Oz
Joined: 08 Nov 2009 Posts: 233 Location: Canberra Oz
|
Posted: Tue Mar 09, 2010 4:08 am Post subject: |
|
|
EDIT: Having some icons disappear.
EDIT: Not anymore I think it was Winspector &/or Window Spy.
Modification to allow abandoned tray icons tray icons to be cleaned-up.
Plus a new way to get the right ToolbarWindow32. Works on XP, not tested elsewhere.
| Code: | ;#NoTrayIcon ; uncomment these three lines to test standalone
;TrayIcon_CleanUp()
;Return
; Based on TrayIcon by Sean @ http://www.autohotkey.com/forum/topic17314.html
TrayIcon_CleanUp()
{ ; Remove abandoned icons in notification tray, such as left behine by "Process Close"
DetectHiddenWindows, On
ControlGet, hWndTray, hWnd,, Notification Area, ahk_class Shell_TrayWnd
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
SendMessage, 0x418, 0, 0,, ahk_id %hWndTray% ; TB_BUTTONCOUNT
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index - 1, pRB,, ahk_id %hWndTray% ; TB_GETBUTTON
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
dwData := NumGet(btn,12)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := NumGet(nfo, 0)
uID := NumGet(nfo, 4)
if !WinExist("ahk_id " . hWnd)
TrayIcon_Remove(hWnd,uID)
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
Return sTrayIcon_CleanUp
}
TrayIcon_Remove(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
DetectHiddenWindows, On
NumPut(VarSetCapacity(ni,444,0), ni)
NumPut(hWnd , ni, 4)
NumPut(uID , ni, 8)
NumPut(1|2|4, ni,12)
NumPut(nMsg , ni,16)
NumPut(hIcon, ni,20)
Return DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
}
| As noted above the Notification Tray functions have changed in Win7 & prob won't work with it. |
|
| Back to top |
|
 |
newb Guest
|
Posted: Tue Apr 06, 2010 4:10 am Post subject: Right clicking an icon |
|
|
Hey, can someone explain how to right click on an icon using this code? I can get the info using | Code: | | MsgBox, % TrayIcons("vidalia.exe") | , but can't figure out what to send the PostMessage command to display the right-click menu for that icon. Any help? Thanks! |
|
| Back to top |
|
 |
MasterFocus
Joined: 08 Apr 2009 Posts: 3035 Location: Rio de Janeiro - RJ - Brasil
|
Posted: Tue Apr 06, 2010 4:16 am Post subject: Re: Extract Informations about TrayIcons |
|
|
| FIRST POST wrote: | 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% |
_________________ "Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried."
Antonio França
My stuff: Google Profile |
|
| Back to top |
|
 |
newb Guest
|
Posted: Tue Apr 06, 2010 1:05 pm Post subject: |
|
|
Yeah, I saw that code in the first post, but can't figure out how to implement it in a script. Here's what I've got:
| Code: | #NoTrayIcon
DetectHiddenWindows, On
Process, Exist, vidalia.exe
WinGet, hWnd,, ahk_pid %ErrorLevel%
MsgBox, % TrayIcons("vidalia.exe")
WM_RBUTTONDOWN = 0x0204
WM_RBUTTONUP = 0x0205
PostMessage, nMsg, uID, 0x204, , ahk_id %hWnd%
PostMessage, nMsg, uID, 0x205, , ahk_id %hWnd%
Return
;...Functions for TrayIcon are below this line...
|
Are "nMsg" and "uID" supposed to have values? Where do they come from? Here's what I get from the MsgBox line:
| Quote: | idx: 8 | idn: 24 | Pid: 5444 | uID: 0 | MessageID: 32869 | hWnd: 460070 | Class: QWidget | Process: vidalia.exe
| Tooltip: Connected to the Tor network! |
I need to be able to right click on the tray icon for this program. Any ideas? |
|
| Back to top |
|
 |
newb Guest
|
Posted: Tue Apr 06, 2010 1:17 pm Post subject: Found it |
|
|
Thank you SKAN @ http://www.autohotkey.com/forum/topic41097.html...
| Code: | DetectHiddenWindows, On
TI := TrayIcons( "vidalia.exe" )
StringSplit,TIV, TI, |
uID := RegExReplace( TIV4, "uID: " )
Msg := RegExReplace( TIV5, "MessageID: " )
hWnd := RegExReplace( TIV6, "hWnd: " )
PostMessage, Msg, uID,0x204,, ahk_id %hWnd% ; Right Click down
PostMessage, Msg, uID,0x205,, ahk_id %hWnd% ; Right Click Up |
Sweeeet  |
|
| Back to top |
|
 |
ruespe* Guest
|
Posted: Tue Apr 06, 2010 4:12 pm Post subject: |
|
|
| Michael@oz wrote: | EDIT: Having some icons disappear.
EDIT: Not anymore I think it was Winspector &/or Window Spy.
Modification to allow abandoned tray icons tray icons to be cleaned-up.
Plus a new way to get the right ToolbarWindow32. Works on XP, not tested elsewhere.
| Code: | ; #NoTrayIcon ; uncomment these three lines to test standalone
; TrayIcon_CleanUp()
; Return
; Based on TrayIcon by Sean @ http://www.autohotkey.com/forum/topic17314.html
TrayIcon_CleanUp()
{ ; Remove abandoned icons in notification tray, such as left behine by "Process Close"
DetectHiddenWindows, On
ControlGet, hWndTray, hWnd,, Infobereich, ahk_class Shell_TrayWnd
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
SendMessage, 0x418, 0, 0,, ahk_id %hWndTray% ; TB_BUTTONCOUNT
ToolTip, %ErrorLevel%
Loop, %ErrorLevel%
{
Restart:
SendMessage, 0x417, A_Index - 1, pRB,, ahk_id %hWndTray% ; TB_GETBUTTON
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
dwData := NumGet(btn,12)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := NumGet(nfo, 0)
uID := NumGet(nfo, 4)
if !WinExist("ahk_id " . hWnd)
{
TrayIcon_Remove(hWnd,uID)
Goto Restart
}
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
Return sTrayIcon_CleanUp
}
TrayIcon_Remove(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
DetectHiddenWindows, On
NumPut(VarSetCapacity(ni,444,0), ni)
NumPut(hWnd , ni, 4)
NumPut(uID , ni, 8)
NumPut(1|2|4, ni,12)
NumPut(nMsg , ni,16)
NumPut(hIcon, ni,20)
Return DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
}
| As noted above the Notification Tray functions have changed in Win7 & prob won't work with it. | Very nice. Just one little bug: when there is an icon to delete, the next one will not be tested because when for example icon 6 will be deleted, the former number 7 will become number 6 and will be oberjumped. I made a little correction. |
|
| Back to top |
|
 |
Michael@Oz
Joined: 08 Nov 2009 Posts: 233 Location: Canberra Oz
|
Posted: Tue Apr 06, 2010 10:42 pm Post subject: |
|
|
| ruespe* wrote: | | Very nice. Just one little bug: when there is an icon to delete, the next one will not be tested because when for example icon 6 will be deleted, the former number 7 will become number 6 and will be oberjumped. I made a little correction. |
Thanks for finding the bug ruespe*, no offence but I don't like goto's, hence;
| Code: | ;#NoTrayIcon ; uncomment these three lines to test standalone
;TrayIcon_CleanUp()
;Return
; Based on TrayIcon by Sean @ http://www.autohotkey.com/forum/topic17314.html
TrayIcon_CleanUp()
{ ; Remove abandoned icons in notification tray, such as left behine by "Process Close"
; v0-2 - Work from Button Count to zero to catch bug where icons are renumbered
; - eg Remove #2, #3 becomes #2, loop goes to test #3 so new #2 not checked, thanks ruespe*
DetectHiddenWindows, On
ControlGet, hWndTray, hWnd,, Notification Area, ahk_class Shell_TrayWnd
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc := DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pRB := DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 20, "Uint", 0x1000, "Uint", 0x4)
VarSetCapacity(btn, 20)
VarSetCapacity(nfo, 24)
SendMessage, 0x418, 0, 0,, ahk_id %hWndTray% ; TB_BUTTONCOUNT
While_Index := ErrorLevel
While (--While_Index >= 0)
{
SendMessage, 0x417, While_Index, pRB,, ahk_id %hWndTray% ; TB_GETBUTTON
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pRB, "Uint", &btn, "Uint", 20, "Uint", 0)
dwData := NumGet(btn,12)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 24, "Uint", 0)
hWnd := NumGet(nfo, 0)
uID := NumGet(nfo, 4)
if !WinExist("ahk_id " . hWnd)
TrayIcon_Remove(hWnd,uID)
}
DllCall("VirtualFreeEx", "Uint", hProc, "Uint", pRB, "Uint", 0, "Uint", 0x8000)
DllCall("CloseHandle", "Uint", hProc)
Return sTrayIcon_CleanUp
}
TrayIcon_Remove(hWnd, uID, nMsg = 0, hIcon = 0, nRemove = 2)
{
DetectHiddenWindows, On
NumPut(VarSetCapacity(ni,444,0), ni)
NumPut(hWnd , ni, 4)
NumPut(uID , ni, 8)
NumPut(1|2|4, ni,12)
NumPut(nMsg , ni,16)
NumPut(hIcon, ni,20)
Return DllCall("shell32\Shell_NotifyIconA", "Uint", nRemove, "Uint", &ni)
}
|
|
|
| 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
|