【问题标题】:Return to start menu after closing win form application in Windows 10 tablet mode在 Windows 10 平板电脑模式下关闭 win 表单应用程序后返回开始菜单
【发布时间】:2017-06-01 21:17:15
【问题描述】:

我有一个在平板电脑模式下运行的 Windows 平板电脑上运行的 winform 应用程序 (C#)。但是,当我关闭应用程序时,屏幕会转到桌面,在平板电脑模式下,桌面只是带有空白屏幕的任务栏。直到您单击屏幕才会拉出开始菜单。

出于某种原因,这似乎与在平板模式下运行的任何 winform 应用程序一致,但无论如何我都想找到一种方法,在关闭应用程序后简单地调出开始菜单。

我尝试在应用程序通过调用关闭后模拟鼠标点击(归功于https://www.gamedev.net/topic/321029-how-to-simulate-a-mouse-click-in-c/):

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

private const int MOUSEEVENTF_LEFTDOWN = 0x02;    

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0);
}

但这不起作用。我尝试过使用任务栏设置,看看是否可以通过 Windows 修复它,但没有运气。

有谁知道如何在通过代码或设置关闭winform应用程序后简单地调出开始菜单?

【问题讨论】:

    标签: c# windows winforms tablet


    【解决方案1】:

    我在这篇文章的帮助下解决了这个问题:SendKeys.Send and Windows Key

    看起来不是发送鼠标点击,而是发送一个键,然后是 LWin 键的一个键:

        [DllImport("user32.dll")]
        private static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
    
        private const int KEYEVENTF_EXTENDEDKEY = 1;
        private const int KEYEVENTF_KEYUP = 2;
    
    
        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
             keybd_event((byte)Keys.LWin, 0, KEYEVENTF_EXTENDEDKEY, 0);
             keybd_event((byte)Keys.LWin, 0, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0);
        }
    

    当然,这段代码需要一些额外的检查来确保我们确实处于平板模式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-06-09
      • 2015-08-30
      • 2015-10-31
      • 2017-04-12
      • 1970-01-01
      • 2016-10-16
      • 1970-01-01
      相关资源
      最近更新 更多