Example #1
0
 def clear_keys_pressed(self):
     keystate = (BYTE * 256)()
     if GetKeyboardState(keystate):
         vknames = {}
         for vkconst in (x for x in dir(win32con) if x.startswith("VK_")):
             vknames[getattr(win32con, vkconst)] = vkconst[3:]
         pressed = []
         for i in range(256):
             if keystate[i]:
                 pressed.append(vknames.get(i, i))
         keylog("keys still pressed: %s", csv(pressed))
         for x in (
                 win32con.VK_LSHIFT,
                 win32con.VK_RSHIFT,
                 win32con.VK_SHIFT,
                 win32con.VK_LCONTROL,
                 win32con.VK_RCONTROL,
                 win32con.VK_CONTROL,
                 win32con.VK_LMENU,
                 win32con.VK_RMENU,
                 win32con.VK_MENU,
                 win32con.VK_LWIN,
                 win32con.VK_RWIN,
         ):
             keystate[x] = 0
         SetKeyboardState(keystate)
Example #2
0
 def clear_keys_pressed(self):
     keystate = (BYTE*256)()
     if GetKeyboardState(keystate):
         vknames = {}
         for vkconst in (x for x in dir(win32con) if x.startswith("VK_")):
             vknames[getattr(win32con, vkconst)] = vkconst[3:]
         pressed = []
         for i in range(256):
             if keystate[i]:
                 pressed.append(vknames.get(i, i))
         keylog("keys still pressed: %s", csv(pressed))
         #clear all: (this does not affect lock modifiers: caps , num, scroll)
         keystate = (BYTE*256)()
         SetKeyboardState(keystate)