天天看點

python pywinauto 單擊滑鼠_Python輕松自動看視訊

python pywinauto 單擊滑鼠_Python輕松自動看視訊

如果有很多視訊需要看,得依靠自動化看比較好。

方法:通過模拟滑鼠鍵盤等技巧。

工具:Python

一般自動化控制滑鼠和鍵盤等操作(python)可以用以下方法:

1. pyautogui

2. pynput

3. pywinauto(用于操作Windows标準圖形界面的自動化測試的腳本子產品,比較複雜)

4. auto.py(我自己寫的python檔案)

下面我用第四個方法:

auto.py(我自己寫的python檔案)

下面是簡單介紹:

視訊介紹:

知乎視訊​www.zhihu.com

python pywinauto 單擊滑鼠_Python輕松自動看視訊

文字介紹:

下面這個位址是代碼,可以直接拿來引用:

https://github.com/dxp432/auto/blob/master/auto.py​github.com

然後就開始寫代碼了。

  • 打開視訊網頁代碼:
computer_web_open('https://www.bilibili.com/video/BV1Dk4y1B7Nh?from=search&seid=10827080849902354338')
           
  • 智能找到播放按鈕(不是通過固定x,y軸坐标定位的),而是通過查找播放按鈕。
computer_prtsc('Screencap.png')
computer_matchImgClick('Screencap.png', 'play.png')
           
python pywinauto 單擊滑鼠_Python輕松自動看視訊
  • 判斷視訊是否正在播放:
while True:
    computer_prtsc('Screencap.png')
    if computer_if_matchImg('Screencap.png', 'sound.png'):
        print('正在播放.....')
           
python pywinauto 單擊滑鼠_Python輕松自動看視訊

還有其他更多的功能,以後再細說吧。

繼續閱讀