我试图捕获Shift+ PrintScreen,因为Ctrl+c在这个答案中被捕获。
虽然答案已经过时,但即使我修复了导入,它也不起作用:
import pythoncom
from pyHook import HookManager, GetKeyState, HookConstants
def OnKeyboardEvent(event):
ctrl_pressed = GetKeyState(HookConstants.VKeyToID('VK_CONTROL') >> 15)
if ctrl_pressed and HookConstant.IDToName(event.keyId) == 'd':
print("ctrl plus d was pressed at same time")
return True
# create a hook manager
hm = HookManager()
# watch for all keyboard events
hm.KeyDown = OnKeyboardEvent
# set the hook
hm.HookKeyboard()
# wait forever
pythoncom.PumpMessages()
我想捕获 PrintScreen 键并打开我能够做到的 Screenshot 应用程序。现在我想捕获 Shift + PrintScreen 并使用其他一些配置打开我的应用程序。如何一次捕获两个密钥?