This above script works, but I can't make those functions work with the icon of another script.lexikos wrote:Code: Select all
MsgBox This script has an icon. If killTrayIcon(A_ScriptHwnd) MsgBox And now it doesn't. If restoreTrayIcon(A_ScriptHwnd) MsgBox And now it does again. killTrayIcon(scriptHwnd) { DetectHiddenWindows, On Static NIM_DELETE := 2, AHK_NOTIFYICON := 1028 VarSetCapacity(nic, size := 936 + 4 * A_PtrSize) NumPut(size, nic, 0, "UInt") NumPut(scriptHwnd, nic, A_PtrSize) NumPut(AHK_NOTIFYICON, nic, A_PtrSize * 2, "UInt") Return DllCall("Shell32\Shell_NotifyIcon", "UInt", NIM_DELETE, "Ptr", &nic) } restoreTrayIcon(scriptHwnd) { DetectHiddenWindows, On WM_TASKBARCREATED := DllCall("RegisterWindowMessage", "Str", "TaskbarCreated") PostMessage, WM_TASKBARCREATED,,,, ahk_id %scriptHwnd% }
Say we have script dummy.ahk with the code #Persistent that, for the ease of example we are going to start right from the script that is supposed to kill its tray icon:
Code: Select all
Run, dummy.ahk,,, dummy_pid
While !(dummy_hwnd) ;
WinGet, dummy_hwnd, ID, ahk_pid %dummy_pid%
; dummy_hwnd := WinExist("ahk_pid " dummy_pid)
killTrayIcon(dummy_hwnd) ; fails
Could someone, please, tell me why doesn't lexikos's script work with hwnd of another ahk script and how to make it work by hwnd (or more preferably right by PID)?