Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not hasattr(window, 'hhotkey_hook'):
- from ctypes import Structure, windll, WINFUNCTYPE, cast, POINTER
- from ctypes import c_int, wintypes
- user32 = windll.user32
- class KBDLLHOOKSTRUCT(Structure):
- _fields_ = [
- ('vkCode', wintypes.DWORD),
- ('scanCode', wintypes.DWORD),
- ('flags', wintypes.DWORD),
- ('time', wintypes.DWORD),
- ('dwExtraInfo', c_int),
- ]
- def hhotkey(code, wp, lp):
- if code < 0 or wp != 0x100:
- return user32.CallNextHookEx(0, code, wp, lp)
- kbd = cast(lp, POINTER(KBDLLHOOKSTRUCT)).contents
- if kbd.vkCode == VK_SPACE and user32.GetKeyState(VK_LWIN) & 0x80:
- pyauto.Input.send([pyauto.KeyUp(VK_SPACE)])
- window.hotkey_Activate()
- return 1
- return user32.CallNextHookEx(0, code, wp, lp)
- def hhotkey_destroy():
- if window.hhotkey_hook:
- user32.UnhookWindowsHookEx(window.hhotkey_hook)
- window.old_destroy()
- hhotkey_type = WINFUNCTYPE(
- c_int, c_int, wintypes.WPARAM, wintypes.LPARAM)
- window.hhotkey_proc = hhotkey_type(hhotkey)
- window.hhotkey_hook = user32.SetWindowsHookExW(
- 13, window.hhotkey_proc, 0, 0)
- window.old_destroy = window.destroy
- window.destroy = hhotkey_destroy
Advertisement
Add Comment
Please, Sign In to add comment