Skip to content

Commit bfdbfe5

Browse files
author
m10x.de
authored
Update globalhotkeys.py
1 parent 7f24f75 commit bfdbfe5

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

globalhotkeys.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from ctypes import byref as ctypes_byref
2-
from ctypes.windll import user32 as windll_user32
3-
from ctypes.wintypes import MSG as wintypes_MSG
1+
import ctypes
42
import win32con
53

64

75
class GlobalHotKeys(object):
86

97
key_mapping = []
10-
user32 = windll_user32
8+
user32 = ctypes.windll.user32
119
MOD_ALT = win32con.MOD_ALT
1210
MOD_CTRL = win32con.MOD_CONTROL
1311
MOD_CONTROL = win32con.MOD_CONTROL
@@ -54,16 +52,16 @@ def listen(cls):
5452
return
5553

5654
try:
57-
msg = wintypes_MSG()
58-
while cls.user32.GetMessageA(ctypes_byref(msg), None, 0, 0) != 0:
55+
msg = ctypes.wintypes.MSG()
56+
while cls.user32.GetMessageA(ctypes.byref(msg), None, 0, 0) != 0:
5957
if msg.message == win32con.WM_HOTKEY:
6058
(vk, keyname, modifiers, func) = cls.key_mapping[msg.wParam]
6159
if not func:
6260
break
6361
func()
6462

65-
cls.user32.TranslateMessage(ctypes_byref(msg))
66-
cls.user32.DispatchMessageA(ctypes_byref(msg))
63+
cls.user32.TranslateMessage(ctypes.byref(msg))
64+
cls.user32.DispatchMessageA(ctypes.byref(msg))
6765

6866
finally:
6967
for index, (vk, keyname, modifiers, func) in enumerate(cls.key_mapping):

0 commit comments

Comments
 (0)