在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)?
问题描述
不仅仅是为了当前窗口,而是全局环境。示例:当我键入文档时,我可以按右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屋!