简体   繁体   English

Windows Mobile 6.1 / 6.5上具有全局热键的应用程序切换

[英]Application Switching with a Global Hot Key on Windows Mobile 6.1/6.5

I'm working on writing an application that straddles the line between C# and C/++ on Windows Mobile 6.1/6.5. 我正在写一个跨越Windows Mobile 6.1 / 6.5上C#和C / ++之间界限的应用程序。 We currently have a kiosk application running on our devices, and would like to add the ability to switch back and forth to a second kiosk application. 目前,我们的设备上正在运行一个自助服务终端应用程序,并希望增加在第二个自助服务终端应用程序之间来回切换的功能。

Our goal is to establish a global hot key that switches process windows (similar to the way that alt+tab works) whenever it is pressed. 我们的目标是建立一个全局热键,该热键在每次按下时都会切换过程窗口(类似于alt + tab的工作方式)。 We already have both applications and I've written some code that switches the processes, but am having a rough time getting the global hot key portion of the project working. 我们已经有两个应用程序,并且我已经写了一些代码来切换流程,但是在使项目的全局热键部分正常工作方面花费了很多时间。

From all of the reading that I've done, my understanding is that the best way to monitor global key presses is to link into the system message pump with the SetWindowsHookEx function in coredll.dll . 从我完成的所有阅读中,我的理解是,监视全局按键的最佳方法是使用coredll.dll中的SetWindowsHookEx函数链接到系统消息泵 Unfortunately, I've also read that this function isn't technically supported on the platform. 不幸的是,我还读到该平台在技术上不支持此功能。

I also found some tutorials that suggested using a message map with the ON_WM_KEYUP/ON_WM_KEYDOWN macros in the MFC framework, but couldn't find any documentation specific to Windows Mobile. 我还发现一些教程建议在MFC框架中使用带有ON_WM_KEYUP / ON_WM_KEYDOWN宏的消息映射,但是找不到特定于Windows Mobile的任何文档。 When I tried to use the documentation here , my device kept crashing. 当我尝试使用此处的文档时 ,我的设备一直崩溃。

Is there an accepted best practice for setting some kind of global key hook on the platform? 在平台上设置某种全局密钥挂钩是否存在公认的最佳实践? If not, is there something that's at least technically supported? 如果没有,至少在技术上是否有支持?

Thanks in advance. 提前致谢。

ReplyQuote 回复报价

Why not use a RegisterHotKey call and use that to swap applications? 为什么不使用RegisterHotKey调用并使用它来交换应用程序? IIRC the hardware buttons typically map to key codes starting at 0xC1 (193). IIRC的硬件按钮通常映射到从0xC1(193)开始的键控代码。

We actually ended up polling the GetAsyncKeyState function in coredll.dll on a separate thread. 实际上,我们最终在单独的线程上轮询了coredll.dll中的GetAsyncKeyState函数。 The thread monitors a specific key, and throws an event whenever it is pressed. 该线程监视特定的键,并在按下该键时引发事件。

Because the event is executed on the key polling thread, you have to be sure to use a delegate to invoke its handler on the GUI thread when the event is thrown. 由于事件是在键轮询线程上执行的,因此必须确保在引发事件时使用委托在GUI线程上调用其处理程序。

I would go for a keyboard hook, but only if RegisterHotKey didn't work for your particular scenario. 我会寻求一个键盘挂钩,但是前提是RegisterHotKey在您的特定情况下不起作用。

From all of the reading that I've done, my understanding is that the best way to monitor global key presses is to link into the system message pump with the SetWindowsHookEx function in coredll.dll. 从我完成的所有阅读中,我的理解是,监视全局按键的最佳方法是使用coredll.dll中的SetWindowsHookEx函数链接到系统消息泵中。 Unfortunately, I've also read that this function isn't technically supported on the platform. 不幸的是,我还读到该平台在技术上不支持此功能。

Not technically supported, is correct in theory, but I've not seen a WM 6.5.* device that hasn't supported it in reality. 从技术上讲,没有技术上的支持,从理论上讲是正确的,但是我还没有看到实际上不支持它的WM 6.5。*设备。 Keyboard hooking is such an important feature of vertical market custom rugged WM device apps that it I think it just cannot be removed, for backwards compatibilty. 键盘挂钩是垂直市场定制的坚固耐用WM设备应用程序的重要功能,我认为它无法向后兼容,因此无法删除。

The enterprise side of the WM space is too important. WM空间的企业端太重要了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM