在Win32上,如何使用Perl,Python或Ruby(或C)来检测是否按下左Shift或Right ALT? [英] On Win32, how to detect whether a Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or C)?

查看:107
本文介绍了在Win32上,如何使用Perl,Python或Ruby(或C)来检测是否按下左Shift或Right ALT?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Win32上,我想知道如何使用Perl,Python或Ruby(或者甚至在C)中检测左Shift还是右ALT?



不仅仅是为了当前窗口,而是全局环境。示例:当我键入文档时,我可以按右ALT启动用Ruby编写的音乐播放器,然后再次按右ALT,它可以暂停或停止程序。谢谢。

解决方案

您需要设置低级别键盘钩。您可以通过使用 LowLevelKeyboardProc 调用SetWindowsHookEx来执行此操作,然后观看适当的虚拟密钥代码



有左右Shift和Alt键的键码。


On Win32, I wonder how to detect whether Left Shift or Right ALT is pressed using Perl, Python, or Ruby (or even in C)?

Not just for the current window, but the global environment overall. Example: when I am typing a document, I can press Right ALT to start the music player written in Ruby, and then press Right ALT again and it can pause or stop the program. thanks.

解决方案

You need to setup a Low Level Keyboard Hook. You do this by calling SetWindowsHookEx with a LowLevelKeyboardProc, and then watch for the appropriate virtual key code.

There are key codes for left and right shift and alt keys.

这篇关于在Win32上,如何使用Perl,Python或Ruby(或C)来检测是否按下左Shift或Right ALT?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆