python實(shí)現(xiàn)控制電腦鼠標(biāo)和鍵盤,登錄QQ的方法示例
本文實(shí)例講述了python實(shí)現(xiàn)控制電腦鼠標(biāo)和鍵盤,登錄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() #點(diǎn)擊右下角刷新桌面圖標(biāo) mouse.position = (1433, 884) mouse.press(Button.left) mouse.release(Button.left) sleep(2) #打開QQ(跟進(jìn)QQ具體路徑來設(shè)置) os.startfile("C:\Program Files (x86)\Tencent\QQ\Bin\QQScLauncher.exe") mouse = Controller() #讀取鼠標(biāo)位置 # sleep(5) # print('當(dāng)前指針坐標(biāo)位置是{}'.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賬號(hào) keyboard.type("QQ賬號(hào)") sleep(1) #輸入密碼 keyboard.press(Key.tab) keyboard.release(Key.tab) keyboard.type("QQ密碼") #QQ密碼指針坐標(biāo)位置是(765, 551) keyboard.press(Key.enter) keyboard.release(Key.enter)
更多關(guān)于Python相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Python進(jìn)程與線程操作技巧總結(jié)》、《Python Socket編程技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構(gòu)與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進(jìn)階經(jīng)典教程》及《Python文件與目錄操作技巧匯總》
希望本文所述對(duì)大家Python程序設(shè)計(jì)有所幫助。
相關(guān)文章
python heic后綴圖片文件轉(zhuǎn)換成jpg格式的操作
這篇文章主要介紹了python heic后綴圖片文件轉(zhuǎn)換成jpg格式的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2021-03-03基于Python實(shí)現(xiàn)音樂播放器的實(shí)現(xiàn)示例代碼
這篇文章主要介紹了如何利用Python編寫簡易的音樂播放器,文中的示例代碼講解詳細(xì),具有一的參考價(jià)值,需要的小伙伴可以參考一下2022-04-04Python爬蟲實(shí)現(xiàn)抓取電影網(wǎng)站信息并入庫
本文主要介紹了利用Python爬蟲實(shí)現(xiàn)抓取電影網(wǎng)站信息的功能,并將抓取到的信息入庫。文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起了解一下2022-02-02Python優(yōu)秀開源項(xiàng)目Rich源碼解析的流程分析
這篇文章主要介紹了Python優(yōu)秀開源項(xiàng)目Rich源碼解析,本文通過實(shí)例圖文相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07Python實(shí)現(xiàn)數(shù)通設(shè)備端口使用情況監(jiān)控實(shí)例
這篇文章主要介紹了Python實(shí)現(xiàn)數(shù)通設(shè)備端口使用情況監(jiān)控的方法,涉及Python針對(duì)設(shè)備監(jiān)控的操作技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2015-07-07