python实现控制电脑鼠标和键盘,登录QQ的方法示例
人气:0本文实例讲述了python实现控制电脑鼠标和键盘,登录QQ的方法。分享给大家供大家参考,具体如下:
import os from pynput.mouse import Button,Controller from pynput.keyboard import Key from pynput.keyboard import Controller as W from time import sleep mouse = Controller() keyboard = W() #点击右下角刷新桌面图标 mouse.position = (1433, 884) mouse.press(Button.left) mouse.release(Button.left) sleep(2) #打开QQ(跟进QQ具体路径来设置) os.startfile("C:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe") mouse = Controller() #读取鼠标位置 # sleep(5) # print('当前指针坐标位置是{}'.format(mouse.position)) sleep(2) mouse.position = (654, 340) mouse.press(Button.left) mouse.release(Button.left) sleep(1) mouse.position = (729, 489) keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.press(Key.tab) keyboard.release(Key.tab) #输入QQ账号 keyboard.type("QQ账号") sleep(1) #输入密码 keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.type("QQ密码") #QQ密码指针坐标位置是(765, 551) keyboard.press(Key.enter) keyboard.release(Key.enter)
希望本文所述对大家Python程序设计有所帮助。
您可能感兴趣的文章:
加载全部内容