def keyboard_use_skill(hwnd, slot): vks = ( win32con.VK_LMENU, # Left Alt win32api.VkKeyScanEx('s', 0), # Skills Tab win32api.VkKeyScanEx(str(slot), 0), win32api.VkKeyScanEx('g', 0), # Char Tab ) for vk in vks: keyboard_send_vk_as_scan_code(hwnd, vk)
def keycode_from_key(self, key): if key in self.replacement_mods: return self.replacement_mods[key] if key in self.replacement_keys: return self.replacement_keys[key] if len(key) == 1: return win32api.VkKeyScanEx(key, win32api.GetKeyboardLayout())
def _kc(character): sequence = [] # Doesn't support unicode if len(character) > 1: return [] vk = win32api.VkKeyScanEx(character, self.layout_id) # Low bit is keycode kc = vk & 0xFF mods = vk >> 8 # Keyboard layout does not have this key if kc < 0 or mods < 0: return [] # High bit is modifiers if (mods & 1): # Shift sequence.append(0xA1) if (mods & 2): # Control sequence.append(0xA3) if (mods & 4): # Alt sequence.append(0xA5) sequence.append(kc) return sequence
def _get_initial_keycode(cls, char): # Get the code for this character. layout = cls.get_current_layout() try: code = win32api.VkKeyScanEx(char, layout) except TypeError: code = -1 if code == -1: raise ValueError("Unknown char: %r" % char) return code
def _get_initial_keycode(cls, char, char_vk_fallback=True): # Get the code for this character. layout = cls.get_current_layout() try: code = win32api.VkKeyScanEx(char, layout) except TypeError: code = -1 # Fallback on the keycode in CHAR_VK_MAP, if applicable. # Note: char_vk_fallback=False is used when typing these characters # with the Unicode keyboard. if (char_vk_fallback and code == -1 and char in Win32KeySymbols.CHAR_VK_MAP): code = Win32KeySymbols.CHAR_VK_MAP[char] if code == -1: raise ValueError("Unknown char: %r" % char) return code
def testVkKeyScanEx(self): # hopefully ' ' doesn't depend on the locale! assert win32api.VkKeyScanEx(' ', 0) == 32
def testVkKeyScanEx(self): # hopefully ' ' doesn't depend on the locale! self.failUnlessEqual(win32api.VkKeyScanEx(' ', 0), 32)
def Minuses(string): ids = [] for id in string: ids.append(w3a.VkKeyScanEx(id, lcs.AllList()[0])) minpos = [id for id, x in enumerate(ids) if x == -1] return minpos
def reallyUPPER(str): match = re.search(r"[!@#$%^&*()_+|}{:\"?><]", str) rtrn = False if match != None: rtrn = True if str.isupper(): rtrn = True return rtrn def Minuses(string): ids = [] for id in string: ids.append(w3a.VkKeyScanEx(id, lcs.AllList()[0])) minpos = [id for id, x in enumerate(ids) if x == -1] return minpos if __name__ == '__main__': inpt = input("Enter String:\n") inptloc = int(input("Enter layout id:\n")) minpos = Minuses(inpt) rst = "" print(minpos) for r in inpt: kst = create_string_buffer(256) if reallyUPPER(r): kst[16] = 0xff rst += ToUn(w3a.VkKeyScanEx(r, lcs.AllList()[0]), 0, kst, inptloc) print(rst)
def testVkKeyScanEx(self): # hopefully ' ' doesn't depend on the locale! self.assertEqual(win32api.VkKeyScanEx(" ", 0), 32)