winapi – 如何显示WIndows开始菜单

我需要在鼠标位置激活
Windows开始菜单.

我知道我可以将CTRL ESC或Win键发送到特定窗口,然后移动窗口,但它仍然会在原始位置显示菜单很短的时间(除非我安装了钩子,这对任务来说太过分了).

我记得有一些方法可以做到这一点,使用一些DLL调用或发送一些消息到shell或其他东西.

最佳答案 如果您以编程方式“按下”按钮,您会得到相同的行为吗?

  // Find the Start button
  HANDLE hScreenDC = GetDC(0);
  DWORD height = GetDeviceCaps(hScreenDC, VERTRES);
  ReleaseDC(0, hScreenDC);
  hTaskBarWnd = FindWindow("Shell_TrayWnd", 0);
  hStartButtonWnd = GetWindow(hTaskBarWnd, GW_CHILD);

  // Now simulate a press on the Start button
  SendMessage(hButtonWnd, WM_LBUTTONDOWN,
        MK_LBUTTON, LOWORD(5) + HIWORD(height - 20));

否则,您可以使用WinSpy++或使用类似的实用程序浏览“Shell_TrayWnd”窗口,也许“开始”菜单是托盘窗口的子窗口.

点赞