我们从Python开源项目中,提取了以下8个代码示例,用于说明如何使用win32api.MapVirtualKey()。
def hwcode(Media): hwcode = win32api.MapVirtualKey(Media, 0) return hwcode
def make_key_name(vk, flags): # Check alt keys. flags_done = 0 parts = [] for moddata in _checks: for name, checkflag in moddata: if flags & checkflag: parts.append(name) flags_done = flags_done & checkflag break if flags_done & flags: parts.append(hex( flags & ~flags_done ) ) # Now the key name. if vk is None: parts.append("<Unknown scan code>") else: try: parts.append(key_code_to_name[vk]) except KeyError: # Not in our virtual key map - ask Windows what character this # key corresponds to. scancode = win32api.MapVirtualKey(vk, MAPVK_VK_TO_CHAR) parts.append(unichr(scancode)) sep = "+" if sep in parts: sep = "-" return sep.join([p.capitalize() for p in parts])
def make_key_name(vk, flags): # Check alt keys. flags_done = 0 parts = [] for moddata in _checks: for name, checkflag in moddata: if flags & checkflag: parts.append(name) flags_done = flags_done & checkflag break if flags_done & flags: parts.append(hex( flags & ~flags_done ) ) # Now the key name. if vk is None: parts.append("<Unknown scan code>") else: try: parts.append(key_code_to_name[vk]) except KeyError: # Not in our virtual key map - ask Windows what character this # key corresponds to. scancode = win32api.MapVirtualKey(vk, MAPVK_VK_TO_CHAR) parts.append(chr(scancode)) sep = "+" if sep in parts: sep = "-" return sep.join([p.capitalize() for p in parts])
def nextSong(self): keybd_event(0xB0, MapVirtualKey(0xB0, 0))
def stopSong(self): keybd_event(0xB2, MapVirtualKey(0xB2, 0))
def playSong(self): ## Play the song keybd_event(0xB3, MapVirtualKey(0xB3, 0)) ## Restart the song keybd_event(0xB1, MapVirtualKey(0xB1, 0))