以编程方式从 Windows 8 中的开始(或地铁)屏幕调出桌面应用程序 [英] Bring up desktop app from Start(or metro) screen in Windows 8 programatically
问题描述
我正在编写一个 LOB WPF 程序,它向用户提供一些文本警报(只是简单的 MessageBox.Show();
).
但正如您想象的那样,除非用户通过单击桌面"磁贴切换到桌面模式,否则我编写的桌面应用不会显示给用户.
我尝试使用 InputSimulator 来虚拟按下 Win+D,但抛出异常.>
如何以编程方式将桌面应用程序调至前台?
如果我正确理解了这个问题,那么您并没有编写额外的 Windows 应用商店/Metro 应用程序...您只是想让用户看到您的 WPF 桌面应用程序引发的警报,即使它们当前位于全屏 Windows 应用商店/Metro 应用程序中而不是在桌面上.
为了解决这个问题,我推荐使用 toast 通知系统.您可以从 Windows 应用商店应用程序或桌面应用程序发送 toast 通知,因此您的 WPF 应用程序可以引发 toast 通知,而不是使用文本警报/MessageBox.Show() 机制.无论用户身在何处……在桌面、开始屏幕、Windows 应用商店/Metro 应用程序中,都会向用户显示此 Toast 通知……这是否解决了您的问题?
这是关于从桌面发送 toast 通知的文档应用.它还链接到快速入门代码演练.
I am writing a LOB WPF program which gives some text alert (just simple MessageBox.Show();
) to user.
But as you imagine, the desktop app that I wrote does NOT be displayed to user unless the user switches to Desktop mode by clicking "Desktop" tile.
I tried to use InputSimulator in order to press Win+D virtually, but exception was thrown.
How can I bring up desktop app to foreground programatically?
If I'm understanding the question correctly, you aren't writing an additional Windows Store/Metro app as well...you just want the user to see the alert raised by your WPF desktop app even if they are currently in a full-screen Windows Store/Metro app and not on the desktop.
To solve this problem, I recommend using the toast notification system. You can send toast notifications from either Windows Store apps or desktop apps, so your WPF app could raise a toast notification instead of using your text alert/MessageBox.Show() mechanism. This toast notification will be displayed to the user no matter where they are...on the desktop, on the Start screen, in a Windows Store/Metro app...does this solve your problem?
Here is the documentation on sending toast notifications from desktop apps. It also links to a quickstart code walkthrough.
这篇关于以编程方式从 Windows 8 中的开始(或地铁)屏幕调出桌面应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!