代码之家  ›  专栏  ›  技术社区  ›  majkinetor

如何显示WIndows开始菜单

  •  4
  • majkinetor  · 技术社区  · 15 年前

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

    我知道我可以向特定的窗口发送CTRL+ESC或Win键,然后移动窗口,但它在短时间内仍会在原始位置显示菜单(除非我安装了hook,否则这对任务来说是过分了)。

    2 回复  |  直到 15 年前
        1
  •  1
  •   Gabriella    15 年前

    如果你以编程方式“按下”按钮,你会有同样的行为吗?

      // 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++

        2
  •  1
  •   Iain Ballard    14 年前
    [DllImport("user32.dll", SetLastError = true)]
    public static extern IntPtr FindWindow (string lpClassName, string lpWindowName);
    
    [DllImport("user32.dll")]
    public static extern bool ShowWindow (IntPtr hWnd, ShowWindowCommand nCmdShow);
    
    int ShowCmd = 5;
    int HideCmd = 0;
    ShowWindow(FindWindow("DV2ControlHost", "Start menu"), ShowCmd);
    

    至少应该在windows 7中做到这一点。使用“HideCmd”而不是“ShowCmd”再次隐藏。