WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Systray Icon Questions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Refresh System Tray Area


Question:

In certain cases with assorted Microsoft operating systems, icons representing now-closed programs are still visible in the System Tray area... until you move your mouse over the System Tray (at which point the O/S says to itself, "Ah, time to update the icons in the Tray now, so that they reflect reality.") Or so it seems to me, under some circumstances.

Does anyone know if there's a command to have this "refresh" done programmatically, i.e., without physically sliding the mouse over the Tray?

Answer:

You will need to find window handle of the system tray, gets its bounding rectangle, and programmatically moves the mouse over it.

I believe the operative API is GetWindowRect, documented at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/Windows/WindowReference/WindowFunctions/GetWindowRect.asp

Getting the system tray's handle seems to consist of (assuming the user hasn't switched shells):

ControlHandle=cWndByWndSpec("Shell_TrayWnd","explorer",0)
So the code would look something like this:
ControlHandle=cWndByWndSpec("Shell_TrayWnd","explorer",0)
buf = BinaryAlloc(16)
dll = StrCat(DirWindows(1), "USER32.DLL")
DllCall(dll, long:"GetWindowRect", long:ControlHandle, lpbinary:buf)
BinaryEodSet(buf, 16)
left = BinaryPeek4(buf, 0)
top = BinaryPeek4(buf, 4)
right = BinaryPeek4(buf, 8)
bottom = BinaryPeek4(buf, 12)
BinaryFree(buf)
Message("Coordinates", "%left% %top% %right% %bottom%")
Now use the MousePlay function to move the mouse to those coordinates.

User Reply:

Thanks very much -- works like a charm!
Article ID:   W16725
File Created: 2005:02:18:12:22:02
Last Updated: 2005:02:18:12:22:02