添加自动发送祝福语功能和坐标配置
This commit is contained in:
84
send_blessing.py
Normal file
84
send_blessing.py
Normal file
@@ -0,0 +1,84 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
发送祝福语自动化脚本
|
||||
使用pyautogui库执行鼠标和键盘操作
|
||||
"""
|
||||
import pyautogui
|
||||
import pyperclip
|
||||
import time
|
||||
import os
|
||||
|
||||
# 加载坐标
|
||||
coords = {}
|
||||
coords_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'wechat_coords.txt')
|
||||
if os.path.exists(coords_file):
|
||||
with open(coords_file, 'r', encoding='utf-8') as f:
|
||||
for line in f:
|
||||
if ':' in line:
|
||||
key, value = line.strip().split(': ')
|
||||
x, y = map(int, value.strip('()').split(','))
|
||||
coords[key] = (x, y)
|
||||
|
||||
search_box_x, search_box_y = coords.get('搜索框', (1933, 39))
|
||||
search_result_x, search_result_y = coords.get('搜索结果区域', (2009, 100))
|
||||
chat_input_x, chat_input_y = coords.get('聊天输入框', (2160, 1173))
|
||||
|
||||
name = '夏骥'
|
||||
blessing = '马年新春快乐!愿您在新的一年里,事业腾飞,马到成功!'
|
||||
|
||||
print("=" * 50)
|
||||
print("发送祝福语自动化脚本")
|
||||
print("=" * 50)
|
||||
print(f"搜索框坐标: ({search_box_x}, {search_box_y})")
|
||||
print(f"搜索结果坐标: ({search_result_x}, {search_result_y})")
|
||||
print(f"聊天输入框坐标: ({chat_input_x}, {chat_input_y})")
|
||||
print(f"发送对象: {name}")
|
||||
print(f"祝福语: {blessing}")
|
||||
print("=" * 50)
|
||||
print()
|
||||
print("5秒后开始执行,请切换到微信窗口...")
|
||||
time.sleep(5)
|
||||
|
||||
# 设置pyautogui
|
||||
pyautogui.PAUSE = 0.5 # 每次操作后暂停0.5秒
|
||||
|
||||
# 1. 点击搜索框
|
||||
print(f"1. 点击搜索框 ({search_box_x}, {search_box_y})")
|
||||
pyautogui.moveTo(search_box_x, search_box_y, duration=0.3)
|
||||
pyautogui.click()
|
||||
time.sleep(0.5)
|
||||
|
||||
# 2. 清空搜索框并输入名字
|
||||
print(f"2. 输入名字: {name}")
|
||||
pyautogui.hotkey('ctrl', 'a')
|
||||
time.sleep(0.2)
|
||||
pyperclip.copy(name)
|
||||
pyautogui.hotkey('ctrl', 'v')
|
||||
time.sleep(1)
|
||||
|
||||
# 3. 点击搜索结果
|
||||
print(f"3. 点击搜索结果 ({search_result_x}, {search_result_y})")
|
||||
pyautogui.moveTo(search_result_x, search_result_y, duration=0.3)
|
||||
pyautogui.click()
|
||||
time.sleep(1)
|
||||
|
||||
# 4. 点击聊天输入框
|
||||
print(f"4. 点击聊天输入框 ({chat_input_x}, {chat_input_y})")
|
||||
pyautogui.moveTo(chat_input_x, chat_input_y, duration=0.3)
|
||||
pyautogui.click()
|
||||
time.sleep(0.5)
|
||||
|
||||
# 5. 输入祝福语
|
||||
print(f"5. 输入祝福语")
|
||||
pyperclip.copy(blessing)
|
||||
pyautogui.hotkey('ctrl', 'v')
|
||||
time.sleep(0.5)
|
||||
|
||||
# 6. 发送
|
||||
print("6. 发送消息")
|
||||
pyautogui.press('enter')
|
||||
|
||||
print()
|
||||
print("=" * 50)
|
||||
print("操作完成!")
|
||||
print("=" * 50)
|
||||
Reference in New Issue
Block a user