|
I want to read out the "Status" of a certain TrayIcon (for instance for avgtn.exe - AntivirGuard). So I filled in the Script of Sean:
TrayIcons(sExeName = "avgnt.exe") as recommended.
Also Ilooked for the nfo's in which there are changes when Changing the try-Icon by clicking with the mouse. ( "inaktiv" and "aktiv")...
My questions are:
Is it neccessary to get all of the tray icons with the function"GetTrayBar(0)" or is there a possibility to reduce the script?
Are all of the dllCalls necessary or can I kick out some of them? Or: What do the different dll-Calls do?
Is the loop still neccessary, when only one exe-file is the aked one?
I've experimented with the script and found out, that only a few volumes are changing when I change the status of the relevant Icon (by Right Mousclick...)
Here is my Reduced code of your TrayIcon.ahk (within the demand if you could reduce it a little bit more..):
---------------------------------------------------------------------
MsgBox % TrayIcons()
Return
TrayIcons(sExeName = "avgnt.exe")
{
WinGet, pidTaskbar, PID, ahk_class Shell_TrayWnd
hProc:= DllCall("OpenProcess", "Uint", 0x38, "int", 0, "Uint", pidTaskbar)
pProc:= DllCall("VirtualAllocEx", "Uint", hProc, "Uint", 0, "Uint", 32, "Uint", 0x1000, "Uint", 0x4)
idxTB:= GetTrayBar()
SendMessage, 0x418, 0, 0, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_BUTTONCOUNT
Loop, %ErrorLevel%
{
SendMessage, 0x417, A_Index-1, pProc, ToolbarWindow32%idxTB%, ahk_class Shell_TrayWnd ; TB_GETBUTTON
VarSetCapacity(btn,32,0), VarSetCapacity(nfo,32,0)
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", pProc, "Uint", &btn, "Uint", 32, "Uint", 0)
idn := NumGet(btn, 4)
If dwData := NumGet(btn,12)
iString := NumGet(btn,16)
Else dwData := NumGet(btn,16,"int64"), iString:=NumGet(btn,24,"int64")
DllCall("ReadProcessMemory", "Uint", hProc, "Uint", dwData, "Uint", &nfo, "Uint", 32, "Uint", 0)
If NumGet(btn,12)
hWnd := NumGet(nfo, 0)
, Var1 := NumGet(nfo,21)
, Var2 := NumGet(nfo,22)
, hIcon := NumGet(nfo,20)
Else hWnd := NumGet(nfo, 0,"int64"), uID:=NumGet(nfo, Cool, nMsg:=NumGet(nfo,12)
WinGet, pid, PID, ahk_id %hWnd%
WinGet, sProcess, ProcessName, ahk_id %hWnd%
If !sExeName || (sExeName = sProcess) || (sExeName = pid)
VarSetCapacity(sTooltip,128), VarSetCapacity(wTooltip,128*2)
, DllCall("ReadProcessMemory", "Uint", hProc, "Uint", iString, "Uint", &wTooltip, "Uint", 128*2, "Uint", 0)
, DllCall("WideCharToMultiByte", "Uint", 0, "Uint", 0, "str", wTooltip, "int", -1, "str", sTooltip, "int", 128, "Uint", 0, "Uint", 0)
, sTrayIcons .= "hIcon: " . hIcon . " | Var1: " . Var1 . " | Var2: " . Var2 . " | Process: " . sProcess . "`n" . " | Tooltip: " . sTooltip . "`n"
}
Return sTrayIcons
}
GetTrayBar()
{
ControlGet, hParent, hWnd,, TrayNotifyWnd1 , ahk_class Shell_TrayWnd
ControlGet, hChild , hWnd,, ToolbarWindow321, ahk_id %hParent%
Loop
{
ControlGet, hWnd, hWnd,, ToolbarWindow32%A_Index%, ahk_class Shell_TrayWnd
If Not hWnd
Break
Else If hWnd = %hChild%
{
idxTB := A_Index
Break
}
}
Return idxTB
}
__________________________________
thanks
|
|