欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實(shí)現(xiàn)控制電腦鼠標(biāo)和鍵盤,登錄QQ的方法示例

 更新時(shí)間:2019年07月06日 08:40:03   作者:shawn xie123  
這篇文章主要介紹了python實(shí)現(xiàn)控制電腦鼠標(biāo)和鍵盤,登錄QQ的方法,涉及Python基于Button,Controller,Key模塊針對(duì)鍵盤、鼠標(biāo)的控制相關(guān)操作技巧,需要的朋友可以參考下

本文實(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)文章

最新評(píng)論