Goal was to make a quick and dirty trade calculator to help plan out the new trade missions (i.e. figure out which missions to take to build a good round trip/maximize a single leg). Couldn't find a way to hook directly into the missions so I tried doing it via screen scraping. Regexing OCRed text fucking sucks so that's a dud, probably just going to resort to a webapp with manual inputs for the avaliable missions. Here's the code if someone else wants to take a stab at fixing my/chatGPT's regex. n.b: pytesseract has tesseract as a dependency that needs to be installed separately import pygetwindow as gw import pyautogui import pytesseract import cv2 import numpy as np import keyboard import time import re import os import subprocess import requests is_processing = False def prestart(): pytesseract.pytesseract.tesseract_cmd = r'C:\Program Files\Tesseract-OCR\tesseract.exe' def process_screenshot(window): global is_processing if is_processing: return # Prevent concurrent processing print('Processing screenshot') is_processing = True window_title = "Star Citizen" try: # Get the window object windows = gw.getWindowsWithTitle(window_title) if windows: window = windows[0] # Define the bounding box for the screenshot, I CBA doing the math to find the exact pixels of that UI element left, top, width, height = window.left, window.top, window.width, window.height # Process the image with pytesseract screenshot = pyautogui.screenshot(region=(left, top, width, height)) screenshot_cv = cv2.cvtColor(np.array(screenshot), cv2.COLOR_RGB2BGR) text = pytesseract.image_to_string(screenshot_cv) #print("Extracted Text:") #print(text) process_text(text) else: print(f"Window with title '{window_title}' not found.") return None finally: is_processing = False # Reset processing state def process_text(text): collect_pattern = r"(?i)Collect\s+(.+?)\s+from\s+(.+?)(?:\n|$)" deliver_pattern = r"(?i)\bDeliver\s+0/\d+\s+SCU\s+to\s+([A-Za-z0-9\s-]+)(?:\n|$)" collect_matches = re.findall(collect_pattern, text) deliver_matches = re.findall(deliver_pattern, text) #if len(collect_matches) == 0 or len(deliver_matches) == 0: print(text) print(collect_matches) print(deliver_matches) def main(): prestart() #set env vars print("shift + alt + m' to take a screenshot and process it with OCR.") # Hotkey listener keyboard.add_hotkey('shift + alt + m', lambda: process_screenshot(window)) # Keep the script running try: while True: time.sleep(1) except KeyboardInterrupt: print("Exiting...") if __name__ == "__main__": main()