• 实现挂机会议


    png

    py文件 

    1. import os
    2. import pyautogui
    3. import time
    4. from typing import Callable, Tuple
    5. from datetime import datetime
    6. import cv2
    7. import schedule
    8. #通过图像模板匹配在屏幕上找到指定区域并操作
    9. def imgAutoClick(tempFile: str, whatDo: Callable[[Tuple[int, int, int, int]], None], debug: bool = False):
    10. #截图
    11. screenshot_path = 'big.png'
    12. pyautogui.screenshot(screenshot_path)
    13. #加载和处理图像
    14. gray = cv2.imread(screenshot_path, cv2.IMREAD_GRAYSCALE)
    15. img_template = cv2.imread(tempFile, cv2.IMREAD_GRAYSCALE)
    16. #获取模板尺寸
    17. w, h = img_template.shape[::-1]
    18. #模板匹配
    19. res = cv2.matchTemplate(gray, img_template, cv2.TM_SQDIFF)
    20. min_val, _, min_loc, _ = cv2.minMaxLoc(res)
    21. #计算边界框坐标
    22. top_left = min_loc
    23. bottom_right = (top_left[0] + w, top_left[1] + h)
    24. #移动鼠标并执行操作
    25. pyautogui.moveTo(top_left[0] + w / 2, top_left[1] + h / 2)
    26. whatDo((top_left[0], top_left[1], w, h))
    27. #调试
    28. if debug:
    29. img = cv2.imread(screenshot_path)
    30. cv2.rectangle(img, top_left, bottom_right, (0, 0, 255), 2)
    31. img_resized = cv2.resize(img, (0, 0), fx=0.5, fy=0.5, interpolation=cv2.INTER_NEAREST)
    32. cv2.imshow("Processed", img_resized)
    33. cv2.waitKey(0)
    34. cv2.destroyAllWindows()
    35. #清理截图
    36. os.remove(screenshot_path)
    37. #登录会议
    38. def signIn(meeting_id):
    39. #会议路径
    40. os.startfile(r"xxxxxxxx")
    41. time.sleep(10)
    42. #会议图标
    43. imgAutoClick("xxxxtubiao.png", pyautogui.click, False)
    44. time.sleep(1)
    45. #加入会议
    46. imgAutoClick("xxxxjoinbtn.png", pyautogui.click, False)
    47. time.sleep(1)
    48. #输入会议号
    49. imgAutoClick("xxxxmeeting_id.png", pyautogui.click, False)
    50. pyautogui.write(meeting_id)
    51. time.sleep(2)
    52. #最后加入会议
    53. imgAutoClick("xxxxxfinal.png", pyautogui.click, False)
    54. time.sleep(1)
    55. #再次登录会议
    56. def signIn_two(meeting_id):
    57. #加入会议
    58. imgAutoClick("xxxxxxjoinbtn.png", pyautogui.click, False)
    59. time.sleep(1)
    60. #输入会议号
    61. imgAutoClick("xxxxxmeeting_id.png", pyautogui.click, False)
    62. pyautogui.write(meeting_id)
    63. time.sleep(2)
    64. #最后加入会议
    65. imgAutoClick("xxxxxfinal.png", pyautogui.click, False)
    66. time.sleep(1)
    67. def job():
    68. while True:
    69. #获取当前时间
    70. now = datetime.now()
    71. #判断是否是周六
    72. if now.weekday() == 5:
    73. #开始时间
    74. start_time = datetime(now.year, now.month, now.day, 14, 0, 0).strftime("%H:%M:%S")
    75. #结束时间
    76. end_time = datetime(now.year, now.month, now.day, 17, 30, 0).strftime("%H:%M:%S")
    77. #当前时间
    78. current = now.strftime("%H:%M:%S")
    79. #会议号
    80. meeting_id = '11111111'
    81. #间隔一小时进行操作
    82. if start_time <= current <= end_time:
    83. if current == "14:00:00":
    84. signIn(meeting_id)
    85. time.sleep(5)
    86. elif current == "15:00:00":
    87. signIn_two(meeting_id)
    88. time.sleep(5)
    89. elif current == "16:00:00":
    90. signIn_two(meeting_id)
    91. time.sleep(5)
    92. elif current == "17:00:00":
    93. signIn_two(meeting_id)
    94. time.sleep(5)
    95. else:
    96. print("Today is not Saturday.")
    97. break
    98. if __name__ == '__main__':
    99. #设置定时任务
    100. schedule.every().saturday.at("13:58").do(job)
    101. while True:
    102. schedule.run_pending()
    103. time.sleep(1)

    bat文件

    1. @echo off
    2. 输出当前工作目录
    3. echo Current directory: %cd%
    4. 输出Python 解释器的路径
    5. echo Python path: "xxxxx.exe"
    6. 输出py脚本的路径
    7. echo Script path: "xxxxx.py"
    8. 执行指定的 py脚本
    9. "xxxxx.exe" "xxxxx.py"
    10. pause

    vbs

    1. 在后台最小化命令提示符窗口并执行批处理文件
    2. Set WshShell = CreateObject("WScript.Shell")
    3. WshShell.Run chr(34) & "xxxxxxx.bat" & Chr(34), 7

  • 相关阅读:
    【kaggle】AI Report 2023概览
    嵌入式函数调用入栈与出栈
    【云原生之Docker实战】使用Docker部署Solo个人博客站点
    WSL+VSCODE安装以及使用
    win11部署自己的privateGpt(2024-0304)
    【敬伟ps教程】自由变换
    【电子器件笔记7】MOS管参数和选型
    Java-SPI机制详解
    刷题记录:POJ - 2486Apple Tree
    this指针
  • 原文地址:https://blog.csdn.net/qq_53488289/article/details/141096523