Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect when the Windows 7 start menu opens

Tags:

c#

windows-7

wpf

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.

like image 884
Hemlock Avatar asked Jun 20 '12 13:06

Hemlock


1 Answers

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.

like image 71
Rajesh Subramanian Avatar answered Oct 20 '22 01:10

Rajesh Subramanian