使用Python實現(xiàn)企業(yè)微信的自動打卡功能
上下班打卡是程序員最討厭的東西,更討厭的是設(shè)置了連上指定wifi打卡。
手機上有一些定時機器人之類的app,經(jīng)過實際測試,全軍覆沒,沒一個可以活著走到啟動企業(yè)微信的這一步,所以還是靠自己吧。
下面就通過Python程序來實現(xiàn)自動打卡,原理很簡單,用Python設(shè)置定時任務(wù),然后通過adb操作手機,完成打卡。
1、準(zhǔn)備工作
a、安裝了Python,ADB驅(qū)動(安裝方式及下載地址見之前文章)的電腦一臺;常駐在公司的測試機一臺;數(shù)據(jù)線一條。
b、將手機通過數(shù)據(jù)線連接電腦,打開開發(fā)者選項中的允許USB調(diào)試,然后命令行運行adb devices來測試下是否能顯示設(shè)備,ok則準(zhǔn)備工作完畢。
2、實現(xiàn)代碼
#本手機安裝了企業(yè)微信分身,可以打兩個人的卡 # coding: utf-8 import os import sys import time import schedule import requests def click(): #打第一個卡 os.system('adb shell input keyevent 82')#點亮屏幕 time.sleep(1) os.system('adb shell input keyevent 3')#單擊home鍵,回到主頁 time.sleep(1) os.system('adb shell input swipe 500 300 300 300')#左劃屏幕 time.sleep(1) os.system('adb shell input swipe 500 300 300 300')#左劃屏幕 time.sleep(2) os.system('adb shell input tap 920 800')#點擊企業(yè)微信 time.sleep(5) os.system('adb shell input tap 678 1820') time.sleep(5) os.system('adb shell input tap 410 330') time.sleep(10) os.system('adb shell input tap 540 1340') time.sleep(5) #打第二個卡 os.system('adb shell input keyevent 3') time.sleep(1) os.system('adb shell input swipe 500 300 300 300') time.sleep(1) os.system('adb shell input swipe 500 300 300 300') time.sleep(2) os.system('adb shell input tap 660 1100') time.sleep(5) os.system('adb shell input tap 678 1820') time.sleep(5) os.system('adb shell input tap 410 330') time.sleep(10) os.system('adb shell input tap 540 1340') time.sleep(5) #推送消息給微信,此處可以刪除,僅為通知 url = 'http://wxmsg.dingliqc.com/send?msg=打卡成功&userIds=自己微信的uid' requests.get(url) sys.exit() def main(): ''' 主函數(shù) ''' schedule.every().day.at('18:03').do(click) while True: schedule.run_pending() time.sleep(3) if __name__ == '__main__': main()
關(guān)于代碼中涉及到的坐標(biāo)點,可以通過手機頁面截圖,放到電腦里編輯圖片來查看觸摸點的坐標(biāo)值,跟機型和分辨率有關(guān),需要針對自己的手機調(diào)試,sleep的時間根據(jù)手機性能,網(wǎng)絡(luò)環(huán)境可以做優(yōu)化,然后運行代碼就行了。想后臺運行的話
start /b python startwork.py
當(dāng)然,最重要的一點,電腦要保持24H開機,程序員不擔(dān)心這個,因為真正的程序員從不關(guān)機。
總結(jié)
以上所述是小編給大家介紹的使用Python實現(xiàn)企業(yè)微信的自動打卡功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
相關(guān)文章
python中tqdm使用,對于for和while下的兩種不同情況問題
這篇文章主要介紹了python中tqdm使用,對于for和while下的兩種不同情況問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-08-08python連接mongodb操作數(shù)據(jù)示例(mongodb數(shù)據(jù)庫配置類)
這篇文章主要介紹了python連接mongodb操作數(shù)據(jù)示例,主要包括插入數(shù)據(jù)、更新數(shù)據(jù)、查詢數(shù)據(jù)、刪除數(shù)據(jù)等2013-12-12Windows下pycharm創(chuàng)建Django 項目(虛擬環(huán)境)過程解析
這篇文章主要介紹了Windows下pycharm創(chuàng)建Django 項目(虛擬環(huán)境)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2019-09-09探索Python int()函數(shù)傳入中文或者字符串會發(fā)生什么
這篇文章主要為大家介紹了Python int()函數(shù)傳入中文或者字符串會發(fā)生什么,詳細(xì)討論int()函數(shù)的常規(guī)使用以及它如何處理異常輸入,特別是涉及字符串和中文字符的情況2024-01-01