【问题标题】:How to switch desktop to metro UI by code? [closed]如何通过代码将桌面切换到 Metro UI? [关闭]
【发布时间】:2012-11-26 09:44:24
【问题描述】:

我想知道如何以编程方式将桌面切换到 Metro UI。我知道按 Windows 键可以做到,但如何通过代码做同样的事情?

【问题讨论】:

    标签: c# .net wpf windows-8 microsoft-metro


    【解决方案1】:

    对于桌面应用程序

    1. 您可以使用窗口服务主机。参考链接Pro-grammatically open window start menu

    2. 使用 P/Invoke 发送窗口键(来自link)

      private static extern int keybd_event(Byte bVk, Byte bScan, long dwFlags, long dwExtraInfo);
      private const byte UP = 2;
      private const byte CTRL = 17;
      private const byte ESC = 27;
      
      Finally on the event where you want to open start menu use :
      // Press Ctrl-Esc key to open Start menu
      keybd_event(CTRL, 0, 0, 0);
      keybd_event(ESC, 0, 0, 0);
      
      // Need to Release those two keys
      keybd_event(CTRL, 0, UP, 0);
      keybd_event(ESC, 0, UP, 0);
      

    对于现代 UI 应用,由于 API 支持有限,我不确定是否可以这样做。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-01
      • 1970-01-01
      相关资源
      最近更新 更多