This is an old revision of the document!
RSWQueueBot Live Chat
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 = { "monday": False, "tuesday": False, "wednesday": False, "thursday": False, "friday": False } # Function to reset task completion at midnight def reset_task_completion(): for day in task_completed: task_completed[day] = False print("Task completion reset for the new day.") # Schedule the reset to happen at midnight schedule.every().day.at("00:00").do(reset_task_completion) # Function for each weekday task def task_monday(): if not task_completed["monday"]: print("Monday task running at 9:15 AM") task_completed["monday"] = True # Mark the task as completed # Task logic app = Application().connect(title="Trillian", visible_only=True) main_window = app.window(title='Trillian') main_window.set_focus() main_window.type_keys('Support Chat', with_spaces=True) keyboard.press(Key.enter) keyboard.release(Key.enter) support_chat = app.window(title='Support Chat Trillian') support_chat.set_focus() support_chat.type_keys( 'Keith, Billy, RJ, Julian, and Mitchell, please ensure you are signed into live chat. @all ', 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["tuesday"]: print("Tuesday task running at 9:15 AM") task_completed["tuesday"] = True # Task logic app = Application().connect(title="Trillian", visible_only=True) main_window = app.window(title='Trillian') main_window.set_focus() main_window.type_keys('Support Chat', with_spaces=True) keyboard.press(Key.enter) keyboard.release(Key.enter) support_chat = app.window(title='Support Chat Trillian') support_chat.set_focus() support_chat.type_keys( 'Julian, Mitchell, Keith, Billy, and Christopher, please ensure you are signed into live chat. @all ', 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["wednesday"]: print("Wednesday task running at 9:15 AM") task_completed["wednesday"] = True app = Application().connect(title="Trillian", visible_only=True) main_window = app.window(title='Trillian') main_window.set_focus() main_window.type_keys('Support Chat', with_spaces=True) keyboard.press(Key.enter) keyboard.release(Key.enter) # Paste the screenshot in Support Chat support_chat = app.window(title='Support Chat Trillian') support_chat.set_focus() support_chat.type_keys('RJ, Mahashwar, Keith, Julian and Christopher, Please make sure you are currently signed into live chat. @all ', with_spaces=True) # Paste from clipboard keyboard.press(Key.enter) keyboard.release(Key.enter) def task_thursday(): if not task_completed["thursday"]: print("Thursday task running at 9:15 AM") task_completed["thursday"] = True print("Thursday task running at 9:15 AM") app = Application().connect(title="Trillian", visible_only=True) main_window = app.window(title='Trillian') main_window.set_focus() main_window.type_keys('Support Chat', with_spaces=True) keyboard.press(Key.enter) keyboard.release(Key.enter) # Paste the screenshot in Support Chat support_chat = app.window(title='Support Chat Trillian') support_chat.set_focus() support_chat.type_keys('RJ, Mahashwar, Mitchell, Billy and Christopher, Please make sure you are currently signed into live chat. @all ', with_spaces=True) # Paste from clipboard keyboard.press(Key.enter) keyboard.release(Key.enter) def task_friday(): if not task_completed["friday"]: print("Friday task running at 9:15 AM") task_completed["friday"] = True app = Application().connect(title="Trillian", visible_only=True) main_window = app.window(title='Trillian') main_window.set_focus() main_window.type_keys('Support Chat', with_spaces=True) keyboard.press(Key.enter) keyboard.release(Key.enter) # Paste the screenshot in Support Chat support_chat = app.window(title='Support Chat Trillian') support_chat.set_focus() support_chat.type_keys('Mahashwar, Billy, Keith, Julian and Christopher, Please make sure you are currently signed into live chat. @all ', with_spaces=True) # Paste from clipboard keyboard.press(Key.enter) keyboard.release(Key.enter) # Schedule tasks at 9:15 AM for each weekday schedule.every().monday.at("09:15").do(task_monday) schedule.every().tuesday.at("09:15").do(task_tuesday) schedule.every().wednesday.at("09:15").do(task_wednesday) schedule.every().thursday.at("09:15").do(task_thursday) schedule.every().friday.at("09:15").do(task_friday) # Run the schedule def run_schedule(): while True: schedule.run_pending() time.sleep(1) # To prevent excessive CPU usage # Start the schedule runner run_schedule()