Differences
This shows you the differences between two versions of the page.
python:python_programs:rswqueuebot_livechat [2024/05/07 04:55] – created jcorona | python:python_programs:rswqueuebot_livechat [Unknown date] (current) – removed - external edit (Unknown date) 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== RSWQueueBot Live Chat ====== | ||
- | <code python> | ||
- | import schedule | ||
- | import time | ||
- | import datetime | ||
- | from pywinauto.application import Application | ||
- | from pynput.keyboard import Controller, Key | ||
- | |||
- | # Initialize keyboard controller and task completion tracking | ||
- | keyboard = Controller() | ||
- | task_completed = { | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | " | ||
- | } | ||
- | |||
- | # Function to reset task completion at midnight | ||
- | def reset_task_completion(): | ||
- | for day in task_completed: | ||
- | task_completed[day] = False | ||
- | print(" | ||
- | |||
- | # Schedule the reset to happen at midnight | ||
- | schedule.every().day.at(" | ||
- | |||
- | # Function for each weekday task | ||
- | def task_monday(): | ||
- | if not task_completed[" | ||
- | print(" | ||
- | task_completed[" | ||
- | # Task logic | ||
- | app = Application().connect(title=" | ||
- | main_window = app.window(title=' | ||
- | main_window.set_focus() | ||
- | main_window.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | support_chat = app.window(title=' | ||
- | support_chat.set_focus() | ||
- | support_chat.type_keys( | ||
- | ' | ||
- | with_spaces=True | ||
- | ) | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | # Define other weekday tasks with similar logic | ||
- | def task_tuesday(): | ||
- | if not task_completed[" | ||
- | print(" | ||
- | task_completed[" | ||
- | # Task logic | ||
- | app = Application().connect(title=" | ||
- | main_window = app.window(title=' | ||
- | main_window.set_focus() | ||
- | main_window.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | support_chat = app.window(title=' | ||
- | support_chat.set_focus() | ||
- | support_chat.type_keys( | ||
- | ' | ||
- | with_spaces=True | ||
- | ) | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | # Continue defining tasks for Wednesday through Friday | ||
- | def task_wednesday(): | ||
- | if not task_completed[" | ||
- | print(" | ||
- | task_completed[" | ||
- | app = Application().connect(title=" | ||
- | main_window = app.window(title=' | ||
- | main_window.set_focus() | ||
- | main_window.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | | ||
- | # Paste the screenshot in Support Chat | ||
- | support_chat = app.window(title=' | ||
- | support_chat.set_focus() | ||
- | support_chat.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | def task_thursday(): | ||
- | if not task_completed[" | ||
- | print(" | ||
- | task_completed[" | ||
- | print(" | ||
- | app = Application().connect(title=" | ||
- | main_window = app.window(title=' | ||
- | main_window.set_focus() | ||
- | main_window.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | | ||
- | # Paste the screenshot in Support Chat | ||
- | support_chat = app.window(title=' | ||
- | support_chat.set_focus() | ||
- | support_chat.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | def task_friday(): | ||
- | if not task_completed[" | ||
- | print(" | ||
- | task_completed[" | ||
- | app = Application().connect(title=" | ||
- | main_window = app.window(title=' | ||
- | main_window.set_focus() | ||
- | main_window.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | | ||
- | # Paste the screenshot in Support Chat | ||
- | support_chat = app.window(title=' | ||
- | support_chat.set_focus() | ||
- | support_chat.type_keys(' | ||
- | keyboard.press(Key.enter) | ||
- | keyboard.release(Key.enter) | ||
- | |||
- | # Schedule tasks at 9:15 AM for each weekday | ||
- | schedule.every().monday.at(" | ||
- | schedule.every().tuesday.at(" | ||
- | schedule.every().wednesday.at(" | ||
- | schedule.every().thursday.at(" | ||
- | schedule.every().friday.at(" | ||
- | |||
- | # Run the schedule | ||
- | def run_schedule(): | ||
- | while True: | ||
- | schedule.run_pending() | ||
- | time.sleep(1) | ||
- | |||
- | # Start the schedule runner | ||
- | run_schedule() | ||
- | |||
- | </ |