Hemlock
Hemlock

Reputation: 6208

How can I detect when the Windows 7 start menu opens

I have written a WPF application in C# which I would like to show every time the start menu is opened and hide again when the menu is closed. I would prefer to do this without polling the state of the start menu. So far I've tried listening to the SHELLHOOK messages but I'm not seeing anything useful there.

Upvotes: 6

Views: 987

Answers (1)

Rajesh Subramanian
Rajesh Subramanian

Reputation: 6490

I Can't write you full code but here is the logic behind it,

  1. First find the handle for the task bar using

    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
    

    also pass Shell_TrayWnd as lpClassName

  2. Activate the Start Menu by simulating click button.

  3. Get the window handle of Start Menu

  4. Use GetWindowLong function to check it is open or not.

Upvotes: 2

Related Questions