Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
hide/replace trayicons
#1
in powerpro i can hide trayicons.
is there a way to do the same with qm ?

thanks
pi
#2
stupid as i am i guess that there must be somewhere a list of programs registered to tray, otherway shell replacements wouldn't be able to show at least the icons of those programs.

??
pi
#3
Code:
Copy      Help
int hwnd=child("Notification Area" "ToolbarWindow32" "+Shell_TrayWnd" 0x1)
int i n=SendMessage(hwnd WINAPI.TB_BUTTONCOUNT 0 0)
for(i 0 n)
,SendMessage(hwnd WINAPI.TB_HIDEBUTTON i 1)
Tray t.AddIcon("" "Tray icons are hidden") ;;to autosize
5
for(i 0 n)
,SendMessage(hwnd WINAPI.TB_HIDEBUTTON i 0)

Win XP only. Probably will not work with shell replacements.
#4
that looks promising, but i was unclear.

i want to hide existing trayicons from applications.

like trayicon hide hardware (found new hardware)
or as worst case :

hide qm icon and replace it with an own trayicon which is enabled for l/m/r mouse.
pi
#5
how do i get a list of all avaible trayicons (thwnd) ?

ppro has a dump trayicons command to file:

Code:
Copy      Help
exe=Smax4 id=101  fl=....  class=Afx:400000:0  cap=SoundMax4  tt=SoundMAX Systemsteuerung
exe=qm id=1  fl=....  class=QM_Editor  cap=Quick Macros - mc - [qm_deskbar_middle]  tt=Quick Macros
exe=Proxomitron id=1  fl=....  class=PrxTronCls  cap=The Proxomitron - default  tt=Proxomitron default
exe=strokeit id=1  fl=....  class=StrokeIt  cap=StrokeIt  tt=StrokeIt
exe=avgcc id=1049  fl=....  class=Avg70ControlCenter  cap=AVG 7.1 Email Server Edition - Control Center  tt=AVG 7.1 Email Server Edition - Control Center
pi
#6
NOTE: Look for updated functions in other post.


Function HideTrayIcon
Code:
Copy      Help
deleted


Function FindTrayIcon
Code:
Copy      Help
deleted


I don't know a way to identify tray icons other than by tooltip text.
#7
this is very very hot !!!
bruce (ppro) must do the same (tt)

the last function i ask for is the emum all current visible tray icons.

i love you Confusedhock:
pi
#8
NOTE: Look for updated function in other post.


Function EnumTrayIcons
Code:
Copy      Help
deleted
#9
i get no result :?:

Code:
Copy      Help
type TRAYICON str'tooltip !hidden
ARRAY(TRAYICON) a
EnumTrayIcons 0 a
int i
for i 0 a.len
,if(!a[i].hidden)
,,out a[i].tooltip
pi
#10
Try to debug EnumTrayIcons. Where it fails?
#11
it was 'Notification Area', in german the title is 'Infobereich'.
now it works.
pi
#12
can you extend EnumTrayIcons to return class ?

and is it possible to send mouse clicks to a trayicon ?
pi
#13
1. Don't know how.
2.
Code:
Copy      Help
Acc a=acc("Quick Macros" "PUSHBUTTON" "+Shell_TrayWnd" "ToolbarWindow32" "" 0x1001)
a.Mouse(2)
#14
2. cool -> how now to navigate in the traymenu ?
pi
#15
wait 0.5
key ...
#16
there is something wrong with EnumTrayIcons,
qm returns only:

Quick Macros
Ditto
SoundMAX Systemsteuerung
Proxomitron default
StrokeIt

while ppro returns:

Code:
Copy      Help
exe=Smax4 id=101  fl=....  class=Afx:400000:0  cap=SoundMax4  tt=SoundMAX Systemsteuerung
exe=strokeit id=1  fl=....  class=StrokeIt  cap=StrokeIt  tt=StrokeIt
exe=avgcc id=1049  fl=....  class=Avg70ControlCenter  cap=AVG 7.1 Email Server Edition - Control Center  tt=AVG 7.1 Email Server Edition - Control Center
exe=Proxomitron id=1  fl=....  class=PrxTronCls  cap=The Proxomitron - default  tt=Proxomitron default
exe=emule id=1  fl=...u  class=#32770  cap=eMule v0.47a  tt=eMule v0.47a (Verbunden)  Up: 20.0(0.8) | Down: 17.3(0.9)
exe=qm id=1  fl=....  class=QM_Editor  cap=Quick Macros - mc - [Macro9]  tt=Quick Macros

ditto is hidden, so its not in the ppro dump.
i miss emule and avg.
pi
#17
it seems that when the icon is set to "hide when inactive" and is then "hidden" the icon disappears from the systray completely.

if you go to taskbar properties and reset the behavior, it will reappear.
An old blog on QM coding and automation.

The Macro Hook
#18
I'm sorry _JOHN, your message disappeared. You asked how to add tray icon that would show a menu on right click.


Create a function, name it eg "TrayIconManager":

Code:
Copy      Help
AddTrayIcon "mouse.ico" "my menu" "" "My Menu"
wait -1

Here "My Menu" is menu name. Replace it. Also, replace icon file and tooltip.

Open or create function init2. Insert this somewhere in it:

Code:
Copy      Help
mac "TrayIconManager"

Restart QM.
#19
The FindTrayIcon and HideTrayIcon functions only work in XP, eh?

Is there a way to make them work in Windows2000?

If not, anybody know where the icon status is buried in the registry? :lol:
#20
Should work on W2000 too, but I didnt test.
#21
Sad Hmmm, unfortunately I can't get it to work on W2000. Maybe I'm doing something wrong. Here's what I'm doing:

1) Copy/create both functions.
2) To try to hide an icon I run this macro:

HideTrayIcon "*part of the tool tip text here*" 1

I don't know if this is the whole problem, but the FindTrayIcon function seems to be returning -1 to the HideTrayIcon function.

Does it seem like I'm doing something wrong? Thanks.

-jimbog


P.S. I notice there is a reference to "XP" in the comments for the FindTrayIcon function. But I am in W2000
#22
I updated the code, fixed bugs. Now works on Windows 2000 too.
#23
Thank you very much. I'm not trying to be difficult, but I still can't get it to work. I'm getting this error:

HideTrayIcon: this name already exists.

The cursor stops here:

def TB_HIDEBUTTON (WM_USER + 4)

I tried it without this def but then I get the error that it's not declared Sad
#24
I forgot to say that you have to restart QM after replacing the function.
#25
Works great! Thanks. Big Grin
#26
Gintaras,

Could you please advise on extending EnumTrayIcons to return tooltips strings in 2.3.0.0 -Unicode.

Thanks in advance
#27
Function FindTrayControl
Code:
Copy      Help
;/
function# [&nButtons]

;Finds child window (toolbar) that contains tray icons (buttons). Returns its handle, or 0 if not found.

;nButtons - if used, receives button count, including hidden.


ARRAY(int) a; int i
child("" "ToolbarWindow32" "+Shell_TrayWnd" 0x400 "" a)
for i a.len-1 -1 -1
,int w=a[i]
,int n=SendMessage(w TB_BUTTONCOUNT 0 0)
,if(n)
,,if(&nButtons) nButtons=n
,,ret w

Function FindTrayIcon
Code:
Copy      Help
;/
function# hwnd $tooltip

;Returns tray toolbar control button id, or -1 if not found.
;hwnd - tray toolbar control handle.
;tooltip - tooltip. Can contain wildcard characters (* and ?).


int i n
if(hwnd) n=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
else hwnd=FindTrayControl(n)
if(!n) ret -1

__ProcessMemory m.Alloc(hwnd 1000)
TBBUTTON b

for i 0 n
,if(!SendMessage(hwnd TB_GETBUTTON i m.address)) continue
,m.Read(&b sizeof(b))
,int t=SendMessage(hwnd TB_GETBUTTONTEXTW b.idCommand m.address+100)
,if(t<=0) continue
,str s
,m.ReadStr(s t*2 100 1)
,if(matchw(s tooltip 1)) ret b.idCommand
ret -1

Function EnumTrayIcons
Code:
Copy      Help
;/
function hwnd ARRAY(TRAYICONINFO)&a mask ;;mask: 1 get tooltip, 2 get hwnd, hicon, callbackMsg, callbackId

;Gets tray icon data for all icons.

;hwnd - tray toolbar control handle. If 0, the function tries to find the control.
;a - receives each icon info:
;;;.tooltip - tooltip text.
;;;.hidden - 0 if the icon is visible, 1 if hidden.
;;;.idCommand - toolbar control button id.
;;;.hwnd - handle of window that added the icon.
;;;.hicon - icon handle.
;;;.callbackMsg, .callbackId - on mouse and other events the window receives this message with this id.
;mask - must be 3 to get all info. If some info not needed, use 0, 1 or 2. It will make faster.

;EXAMPLE
;out
;#compile "__TRAYICONINFO"
;ARRAY(TRAYICONINFO) a
;EnumTrayIcons 0 a 3
;int i
;for i 0 a.len
,;TRAYICONINFO& r=a[i]
,;if(r.hidden) continue
,;RecGetWindowName r.hwnd &_s
,;out "tt='%s' idcmd=%i window=%s hicon=%i callbackId=%i callbackMsg=%i" r.tooltip r.idCommand _s r.hicon r.callbackId r.callbackMsg


type __SHTRAYICON hwnd callbackId callbackMsg unknown[2] hIcon
type __SHTRAYICON64 %hwnd callbackId callbackMsg unknown[2] %hIcon
type TBBUTTON64 iBitmap idCommand !fsState !fsStyle !bReserved[6] %dwData %iString

a=0
int i n
if(hwnd) n=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
else hwnd=FindTrayControl(n)
if(!n) ret -1

__ProcessMemory m.Alloc(hwnd 4096)
int ab(m.address) as(ab+50)
TBBUTTON b

for i 0 n
,if(!SendMessage(hwnd TB_GETBUTTON i ab)) continue
,m.Read(&b sizeof(b))
,TRAYICONINFO& ti=a[]
,ti.hidden=b.fsState&TBSTATE_HIDDEN!0
,ti.idCommand=b.idCommand
,if(mask&1)
,,int r=SendMessage(hwnd TB_GETBUTTONTEXTW b.idCommand 0)
,,if(r<0 or r>2000 or SendMessage(hwnd TB_GETBUTTONTEXTW b.idCommand as)<0) ti.tooltip=""
,,else m.ReadStr(ti.tooltip r*2 50 1)
,if(mask&2)
,,if(!_win64)
,,,__SHTRAYICON sti
,,,m.ReadOther(&sti +b.dwData sizeof(sti))
,,,ti.callbackId=sti.callbackId
,,,ti.callbackMsg=sti.callbackMsg
,,,ti.hicon=sti.hIcon
,,,ti.hwnd=sti.hwnd
,,else
,,,__SHTRAYICON64 sti64
,,,m.ReadOther(&sti64 +b.iString sizeof(sti64)) ;;64-bit dwData offset == 32-bit iString offset
,,,ti.callbackId=sti64.callbackId
,,,ti.callbackMsg=sti64.callbackMsg
,,,ti.hicon=sti64.hIcon
,,,ti.hwnd=sti64.hwnd

Function HideTrayIcon
Code:
Copy      Help
;/
function# $tooltip hide [hwnd]

;Hides or shows tray icon whose tooltip matches tooltip (can contain *?).
;Returns 1 if successful.

;tooltip - tooltip. Can contain wildcard characters (* and ?).
;hide - 1 to hide, 0 to show.
;hwnd - tray toolbar control handle. If 0 or omitted, the function tries to find the control.

;EXAMPLE
;HideTrayIcon "Quick*" 1
;5
;HideTrayIcon "Quick*" 0


if(!hwnd) hwnd=FindTrayControl; if(!hwnd) ret
int i=FindTrayIcon(hwnd tooltip); if(i<0) ret
if(!SendMessage(hwnd TB_HIDEBUTTON i hide)) ret
Tray t.AddIcon; t.Delete ;;autosize
ret 1
#28
It is perfect, many thanks.
#29
Hi Gindi,

Unfortunately HideTrayIcon2 does not appear to be working in Windows 10, at least not for me.  If it's an easy tweak to the code, that would be greatly appreciated.

Jimbog
#30
Does not find the toolbar control that contains tray icons. Because Windows 10 has 2 similar toolbars, and the function finds the wrong.

I updated the code and added new function FindTrayControl.
If still fails, before calling HideTrayIcon etc insert code that finds the control and pass its handle to HideTrayIcon (third parameter).


Forum Jump:


Users browsing this thread: 1 Guest(s)