마찬가지로 Ctl, Alt + deleteWindows에서 3 개의 인수로 글로벌 단축키를 만드는 방법은 무엇입니까?
python에서 3 개 이상의 인수가있는 전역 단축키를 사용하는 프로그램을 작성하고 싶습니다. 키보드의 세 키를 모두 눌러야 할당 된 기능을 수행 할 수 있습니다. 예를 들어 고도, 창 및 F3.
win32con.VK_F3, win32con.MOD_WIN, win32con.VK_F5
이 내가 실행하고자하는 현재의 프로그램입니다, 그러나 출력은 다음과 같습니다
Traceback (most recent call last):
File "C:\Python32\Syntax\hot keys\hotkeys2.py", line 41, in <module>
for id, (vk, modifiers) in HOTKEYS.items():
ValueError: too many values to unpack (expected 2)
프로그램 :
import os
import sys
import ctypes
from ctypes import wintypes
import win32con
byref = ctypes.byref
user32 = ctypes.windll.user32
HOTKEYS = {
1 : (win32con.VK_F3, win32con.MOD_WIN, win32con.VK_F5),
2 : (win32con.VK_F4, win32con.MOD_WIN),
3 : (win32con.VK_F2, win32con.MOD_WIN)
}
def handle_win_f3():
#os.startfile (os.environ['TEMP'])
print ("Hello WOrld! F3")
def handle_win_f4():
#user32.PostQuitMessage (0)
print ("Hello WOrld! F4")
def handle_win_f1_escape():
print("exit")
sys.exit()
HOTKEY_ACTIONS = {
1 : handle_win_f3,
2 : handle_win_f4,
3 : handle_win_f1_escape
}
for id, (vk, modifiers) in HOTKEYS.items():
print ("Registering id", id, "for key", vk)
if not user32.RegisterHotKey (None, id, modifiers, vk):
print ("Unable to register id", id)
try:
msg = wintypes.MSG()
while user32.GetMessageA (byref (msg), None, 0, 0) != 0:
if msg.message == win32con.WM_HOTKEY:
action_to_take = HOTKEY_ACTIONS.get (msg.wParam)
#print(" msg.message == win32con.WM_HOTKEY:")
if action_to_take:
action_to_take()
user32.TranslateMessage (byref (msg))
user32.DispatchMessageA (byref (msg))
finally:
for id in HOTKEYS.keys():
user32.UnregisterHotKey (None, id)
print("user32.UnregisterHotKey (None, id)")
Registering 3 hotkeys? Possible? 하나 하나의 키를 할당 사용할 수있는 방법을 설명하는 그 중 두 개를 눌러야 할 경우. 그러나 나는 모든 기능이 동시에 눌려지면 기능 만 수행한다는 것을 알지 못한다. 내가 걸렸습니다
https://github.com/boppreh/keyboard – Andrew