如何显示 WIndows 开始菜单

maj*_*tor 5 winapi

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

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

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

小智 1

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

  // 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));
Run Code Online (Sandbox Code Playgroud)

否则,您可能会使用WinSpy++或类似的实用程序探索“Shell_TrayWnd”窗口,也许“开始”菜单是托盘窗口的子窗口。