python 呼叫widows 微信快捷鍵,進行自動傳送微信訊息
阿新 • • 發佈:2022-05-25
原理說明
可以程式碼執行windows按鍵,然後呼叫微信程式的快捷鍵,然後進行傳送相關訊息,不失於一個批處理程式
擴充套件
可以對程式裡面的一些資料進行維護後變更,比如需要批量傳送的微信彭勇,使用者名稱,需要傳送的內容,可以用表格進行維護後,執行程式取值傳送
import time import pyautogui as pg import pyperclip as pc class SendMsg(object): def __init__(self): self.name = 'admin' self.msg = '傳送語句' def send_msg(self): # 操作間隔為1秒 pg.PAUSE = 1.5 pg.hotkey('ctrl', 'alt', 'c') pg.hotkey('ctrl', 'f') # 找到好友 pc.copy(self.name) pg.hotkey('ctrl', 'v') pg.press('enter') # 傳送訊息 pc.copy(self.msg) pg.hotkey('ctrl', 'v') pg.press('enter') # 隱藏微信 time.sleep(1) pg.hotkey('ctrl', 'alt', 'c') if __name__ == '__main__': s = SendMsg() for i in range(3): # time.sleep(1) s.send_msg()