我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用win32con.VK_RETURN。
def QQ_AtPerson(name): win32api.keybd_event(win32con.VK_SHIFT, 0, 0, 0); win32api.keybd_event(ord('2'), 0, 0, 0); win32api.keybd_event(ord('2'), 0, win32con.KEYEVENTF_KEYUP, 0); win32api.keybd_event(win32con.VK_SHIFT, 0, win32con.KEYEVENTF_KEYUP, 0); time.sleep(0.5) QQ_PrintText(user_list[name]['spell']) time.sleep(0.8) win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0); win32api.keybd_event(win32con.VK_RETURN, 0, win32con.KEYEVENTF_KEYUP, 0); # Parse out the AT directives.
def generateVirtualKey(self, key): keyMap = { "left": win32con.VK_LEFT, "down": win32con.VK_DOWN, "tab" : win32con.VK_TAB, "up": win32con.VK_UP, "right": win32con.VK_RIGHT, "ctrl" : win32con.VK_CONTROL, "esc" : win32con.VK_ESCAPE, "enter" : win32con.VK_RETURN, "alt" : win32con.VK_MENU, ";:" : 0xBA, "\\|" : 0xDC, ".>" : 0xBE, "-_" : 0xBD, "win" : 0x5B, "shift" : win32con.VK_SHIFT } if key in keyMap: return keyMap[key] else: return ord(key.upper())
def QQ_Enter(): win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0); win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0); win32api.keybd_event(win32con.VK_RETURN, 0, win32con.KEYEVENTF_KEYUP, 0); win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0); # The interface function to send QQ a message.
def QQ_SendTextWithAt(str): os.system(qq_shortcut) try_time = 0 while True: time.sleep(0.5) hwnd = win32gui.FindWindow(None, '??&??') # hwnd = win32gui.FindWindow(None, 'OSVT?O?') print('try_time = %d, hwnd = %d' % (try_time, hwnd)) if hwnd != 0: break elif try_time >= 60: print ('SendTextToQQ Error.') return else: try_time = try_time + 1 win32gui.SetForegroundWindow(hwnd) QQ_PrintTextWithAt(str) QQ_Enter() # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_RETURN, 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_RETURN, 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('v'), 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('v'), 0) #win32gui.SendMessage(hwnd, win32con.WM_SETTEXT, None, 'aaa') #win32gui.SetWindowText(hwnd, 'aaa') #win32gui.ReplaceSel() #win32gui.PostMessage(hwnd, win32con.WM_CHAR, '', 3) # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, win32con.VK_CONTROL, 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYDOWN, ord('V'), 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, ord('V'), 0) # win32gui.PostMessage(hwnd, win32con.WM_KEYUP, win32con.VK_CONTROL, 0)