if not SysTray then SysTray = {}; end SysTray.FindToolbarWindow = function() local hWnd = tonumber(DLL.CallFunction("user32.dll", "FindWindowA", "\"Shell_TrayWnd\",0", 0, 1)); if hWnd == 0 then return -1; end hWnd = tonumber(DLL.CallFunction("user32.dll", "FindWindowExA", hWnd..",0,\"TrayNotifyWnd\",0", 0, 1)); if hWnd == 0 then return -1; end local hWnd = tonumber(DLL.CallFunction("user32.dll", "FindWindowExA", hWnd..",0,\"SysPager\",0", 0, 1)); if hWnd == 0 then return -1; end local hWnd = tonumber(DLL.CallFunction("user32.dll", "FindWindowExA", hWnd..",0,\"ToolbarWindow32\",0", 0, 1)); if hWnd == 0 then return -1; end return hWnd; end SysTray._HANDLE = SysTray.FindToolbarWindow(); SysTray.GetIconCount = function() if not SysTray._HANDLE or SysTray._HANDLE == -1 then return -1; end return tonumber(DLL.CallFunction("user32.dll", "SendMessageA", SysTray._HANDLE..", 1048, 0, 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)); end SysTray.GetIconText = function(nIconIndex) local sIconText = ""; if not SysTray._HANDLE or SysTray._HANDLE == -1 then return ""; end local nBuffer = tonumber(DLL.CallFunction("user32.dll", "SendMessageA", SysTray._HANDLE..", 1099, "..nIconIndex..", 0", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)); if nBuffer < 1 then return ""; end nBuffer = 2 * (nBuffer + 1); local pBuffer = Memory.Allocate(nBuffer); iRet = DLL.CallFunction("user32.dll", "SendMessageA", SysTray._HANDLE..", 1099, "..nIconIndex..", "..pBuffer, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); sIconText = Memory.GetString(pBuffer, -1, "Ascii"); Memory.Free(pBuffer); return "'"..sIconText.."'"; end n = SysTray.GetIconCount(); for i = 0, n - 1 do Dialog.Message("Notice", SysTray.GetIconText(i), MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end |