Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FindTrayIcon in EXE
#1
I am trying to use the function FindTrayIcon in an EXE but cannot use the function share. I cannot figure out how to use the CProcessMemory to replace it either.
#2
The function returns toolbar control button id. If you need button index, can use acc instead. However it is not always the same as button id, especially on Windows 7.

Macro Macro1275
Code:
Copy      Help
int w1=id(1504 win("" "Shell_TrayWnd"))

out FindTrayIcon(w1 "Quick*")

Acc a=acc("Quick*" "PUSHBUTTON" w1 "ToolbarWindow32" "" 0x1001)
out a.elem-1
#3
FindTrayIcon with CProcessMemory.
Function FindTrayIcon2
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=SendMessage(hwnd TB_BUTTONCOUNT 0 0)
if(!n) ret -1

#compile __CProcessMemory
CProcessMemory 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+sizeof(b))
,if(t<=0) continue
,str s
,m.ReadStr(s t*2 sizeof(b) 1)
,if(matchw(s tooltip 1)) ret b.idCommand
ret -1
#4
Thank you, worked perfect.


Forum Jump:


Users browsing this thread: 3 Guest(s)