AutoHotkey Community

It is currently May 27th, 2012, 4:53 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 139 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next
Author Message
 Post subject:
PostPosted: January 27th, 2010, 3:00 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 28th, 2010, 6:25 am 
hi,

i'm also interested in seeing this useful script updated for windows 7


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 6:41 am 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 7:40 am 
hi sean, how did u make the script work for NotifyIconOverflowWindow?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 9:48 am 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: January 31st, 2010, 12:05 pm 
Offline

Joined: February 12th, 2007, 7:54 am
Posts: 2462
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 2nd, 2010, 12:27 pm 
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/topic52 ... dows++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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 4th, 2010, 6:41 am 
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 :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 9th, 2010, 5:08 am 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Right clicking an icon
PostPosted: April 6th, 2010, 5:10 am 
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!


Report this post
Top
  
Reply with quote  
PostPosted: April 6th, 2010, 5:16 am 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
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%

WM_RBUTTONDOWN = 0x204
WM_RBUTTONUP = 0x205

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2010, 2:05 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject: Found it
PostPosted: April 6th, 2010, 2:17 pm 
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 :lol:


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2010, 5:12 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 6th, 2010, 11:42 pm 
Offline

Joined: November 8th, 2009, 2:46 am
Posts: 234
Location: Canberra Oz
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)
}


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 139 posts ]  Go to page Previous  1 ... 3, 4, 5, 6, 7, 8, 9, 10  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group