Guest User

Untitled

a guest
Apr 4th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.45 KB | None | 0 0
  1.     if not hasattr(window, 'hhotkey_hook'):
  2.         from ctypes import Structure, windll, WINFUNCTYPE, cast, POINTER
  3.         from ctypes import c_int, wintypes
  4.         user32 = windll.user32
  5.  
  6.         class KBDLLHOOKSTRUCT(Structure):
  7.             _fields_ = [
  8.                 ('vkCode', wintypes.DWORD),
  9.                 ('scanCode', wintypes.DWORD),
  10.                 ('flags', wintypes.DWORD),
  11.                 ('time', wintypes.DWORD),
  12.                 ('dwExtraInfo', c_int),
  13.             ]
  14.  
  15.         def hhotkey(code, wp, lp):
  16.             if code < 0 or wp != 0x100:
  17.                 return user32.CallNextHookEx(0, code, wp, lp)
  18.             kbd = cast(lp, POINTER(KBDLLHOOKSTRUCT)).contents
  19.             if kbd.vkCode == VK_SPACE and user32.GetKeyState(VK_LWIN) & 0x80:
  20.                 pyauto.Input.send([pyauto.KeyUp(VK_SPACE)])
  21.                 window.hotkey_Activate()
  22.                 return 1
  23.             return user32.CallNextHookEx(0, code, wp, lp)
  24.  
  25.         def hhotkey_destroy():
  26.             if window.hhotkey_hook:
  27.                 user32.UnhookWindowsHookEx(window.hhotkey_hook)
  28.             window.old_destroy()
  29.  
  30.         hhotkey_type = WINFUNCTYPE(
  31.             c_int, c_int, wintypes.WPARAM, wintypes.LPARAM)
  32.         window.hhotkey_proc = hhotkey_type(hhotkey)
  33.         window.hhotkey_hook = user32.SetWindowsHookExW(
  34.             13, window.hhotkey_proc, 0, 0)
  35.         window.old_destroy = window.destroy
  36.         window.destroy = hhotkey_destroy
Advertisement
Add Comment
Please, Sign In to add comment