python 實(shí)現(xiàn)控制鼠標(biāo)鍵盤(pán)
1、安裝類庫(kù)
pip install pyautogui
2、代碼:
import pyautogui,time,randompyautogui.PAUSE = 3pyautogui.FAILSAFE = Truewidth, height = pyautogui.size()#print(str(width))#print(str(height))def drawRct(): for i in range(10): pyautogui.moveTo(300, 300, duration=0.25) pyautogui.moveTo(400, 300, duration=0.25) pyautogui.moveTo(400, 400, duration=0.25) pyautogui.moveTo(300, 400, duration=0.25)def mouseScroll(): time.sleep(5) for i in range(10): pyautogui.scroll(-200) time.sleep(2)def getXy(): try: while True: x, y = pyautogui.position() print(x,y) except KeyboardInterrupt: print(’nExit.’)def playVideo(x,y): for i in range(4): pyautogui.click(x,y) x=x+240 playAndComment()def playAndComment(): time.sleep(random.randint(5,15)) pyautogui.scroll(-400) pyautogui.scroll(-400) pyautogui.click(200,300) pyautogui.typewrite(’very good!’) pyautogui.click(900,400) pyautogui.click(710,16)if __name__ == ’__main__’: time.sleep(5) pyautogui.scroll(-300) for i in range(9): print(str(i)) time.sleep(random.randint(3,5)) #pyautogui.click(360,16) pyautogui.scroll(-300) time.sleep(random.randint(1,5)) playVideo(404,330)
以上就是python 實(shí)現(xiàn)控制鼠標(biāo)鍵盤(pán)的詳細(xì)內(nèi)容,更多關(guān)于python 控制鼠標(biāo)鍵盤(pán)的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. Jsp中request的3個(gè)基礎(chǔ)實(shí)踐2. Django程序的優(yōu)化技巧3. XML入門(mén)的常見(jiàn)問(wèn)題(一)4. IntelliJ IDEA 統(tǒng)一設(shè)置編碼為utf-8編碼的實(shí)現(xiàn)5. jsp EL表達(dá)式詳解6. Django ORM實(shí)現(xiàn)按天獲取數(shù)據(jù)去重求和例子7. chat.asp聊天程序的編寫(xiě)方法8. Python多線程操作之互斥鎖、遞歸鎖、信號(hào)量、事件實(shí)例詳解9. idea設(shè)置自動(dòng)導(dǎo)入依賴的方法步驟10. 怎樣才能用js生成xmldom對(duì)象,并且在firefox中也實(shí)現(xiàn)xml數(shù)據(jù)島?
