我们从Python开源项目中,提取了以下23个代码示例,用于说明如何使用pyautogui.hotkey()。
def handle_copy_intent(self, message): pyautogui.hotkey("ctrl", "c") self.speak("Okay Copied!")
def handle_cut_intent(self, message): self.speak("Cutting to clipboard") pyautogui.hotkey("ctrl", "x")
def handle_paste_intent(self, message): self.speak("Pasting from clipboard") pyautogui.hotkey("ctrl", "v")
def select_all(x = None): gui.hotkey('ctrlleft', 'a')
def close(x = None): gui.hotkey('altleft', 'f4')
def example(): screenWidth, screenHeight = pg.size() currentMouseX, currentMouseY = pg.position() pg.moveTo(500, 550) pg.click() pg.moveRel(None, 10) # move mouse 10 pixels down pg.doubleClick() # pg.moveTo(500, 500, duration=2, tween=pyautogui.tweens.easeInOutQuad) # use tweening/easing function to move mouse over 2 seconds. pg.typewrite('Hello world!', interval=0.25) # type with quarter-second pause in between each key pg.press('esc') pg.keyDown('shift') pg.press(['left', 'left', 'left', 'left', 'left', 'left']) pg.keyUp('shift') pg.hotkey('ctrl', 'c') delta_y = 50
def behaviour4() : num = random.randint (1, 5) if num == 1 : pyautogui.hotkey ('ctrl', 'del', 'alt') pyautogui.press ('enter') elif num == 2 : pyautogui.hotkey ('volumemute') elif num == 3 : pyautogui.hotkey ('capslock') elif num == 4 : pyautogui.hotkey ('scrolllock') for i in range (1, 7) : pyautogui.hotkey ('ctrl', 'z') elif num == 5 : pyautogui.hotkey ('ctrl', 'alt', 't')
def netxTab(): pyautogui.hotkey('ctrl', 'tab')
def closeTab(): pyautogui.hotkey('ctrl','w')
def openTab(): pyautogui.hotkey('ctrl','t')
def previousTab(): pyautogui.hotkey('ctrl','shift','tab')
def handle_select_combination_intent(self, message): self.speak("Selecting all") pyautogui.hotkey("ctrl", "a") if message.data.get("PasteKeyword"): self.handle_paste_intent(message) elif message.data.get("CopyKeyword"): self.handle_copy_intent(message) elif message.data.get("CutKeyword"): self.handle_cut_intent(message) elif message.data.get("DeleteKeyword"): self.speak("deleting") pyautogui.keyDown("delete") pyautogui.keyUp("delete")
def new_file(x = None): gui.hotkey('ctrlleft', 'n')
def copy(x = None): gui.hotkey('ctrlleft', 'c')
def paste(x = None): gui.hotkey('ctrlleft', 'v')
def next_window(x = None): gui.hotkey('altleft', 'tab')
def prev_window(x = None): gui.hotkey('altleft', 'shiftleft', 'tab')
def maximize(x = None): gui.hotkey('winleft', 'up')
def minimize(x = None): gui.hotkey('winleft', 'down')
def task_manager(x = None): gui.hotkey('ctrlleft', 'shiftleft', 'esc')
def behaviour3() : strlen = random.randInt (1, 1000) randomstring = ''.join (random.choice (string.lowercase) for i in range (strlen)) pyautogui.typewrite (randomstring) for x in range (1, 7) : pyautogui.hotkey ('ctrl', 'v')
def reset_game(): pyautogui.hotkey('ctrl', 'r') time.sleep(2.5)
def on_key_press(self, widget, event): keyname = Gdk.keyval_name(event.keyval) if event.state & Gdk.ModifierType.CONTROL_MASK and keyname == 'Return' or keyname == 'Return': self.copy_to_clipboard() self.destroy(self, widget) p = pyautogui.position() pyautogui.click(p) pyautogui.hotkey('ctrl', 'v') if keyname == 'Escape': Gtk.main_quit()