python 實(shí)現(xiàn)控制鼠標(biāo)鍵盤
1、安裝類庫
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)鍵盤的詳細(xì)內(nèi)容,更多關(guān)于python 控制鼠標(biāo)鍵盤的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. 基于PHP做個圖片防盜鏈2. php使用正則驗(yàn)證密碼字段的復(fù)雜強(qiáng)度原理詳細(xì)講解 原創(chuàng)3. ASP.NET MVC使用Boostrap實(shí)現(xiàn)產(chǎn)品展示、查詢、排序、分頁4. XML在語音合成中的應(yīng)用5. jscript與vbscript 操作XML元素屬性的代碼6. asp.net core 認(rèn)證和授權(quán)實(shí)例詳解7. ASP.NET MVC把數(shù)據(jù)庫中枚舉項(xiàng)的數(shù)字轉(zhuǎn)換成文字8. 如何使用ASP.NET Core 配置文件9. .NET中實(shí)現(xiàn)對象數(shù)據(jù)映射示例詳解10. 基于javaweb+jsp實(shí)現(xiàn)企業(yè)車輛管理系統(tǒng)
