import win32gui import win32process import psutil import pyautogui import time import threading from pynput import keyboard import tkinter as tk # For the overlay GUI from ctypes import windll # For window transparency # Global flags game_running = True program_running = True current_sequence = 2 # Start with second script (1 or 2) game_window_rect = None # Stores game window position/size overlay_visible = False # Track overlay visibility # Create overlay window (hidden initially) overlay = tk.Tk() overlay.overrideredirect(True) # Remove window decorations overlay.attributes("-alpha", 0.7) # Semi-transparent overlay.attributes("-topmost", True) # Always on top overlay.configure(bg='black') overlay.geometry("200x30+0+0") # Default size/position overlay.withdraw() # Start hidden # Create label for sequence text label = tk.Label( overlay, text="Sequence: With Para", fg='white', bg='black', font=('Arial', 12, 'bold') ) label.pack(expand=True, fill='both') def update_overlay(): """Update overlay position and text based on game state""" global overlay_visible, game_window_rect if not program_running: overlay.destroy() return if game_running and game_window_rect: try: # Position overlay at top-center of game window left, top, right, bottom = game_window_rect width = right - left x = left + (width - 200) // 2 # Center horizontally y = top + 10 # 10px from top # Update text based on current sequence text = "Sequence: With Para" if current_sequence == 2 else "Sequence: Without Para" label.config(text=text) # Show overlay overlay.geometry(f"200x30+{x}+{y}") if not overlay_visible: overlay.deiconify() overlay_visible = True except: hide_overlay() else: hide_overlay() # Check every 100ms overlay.after(100, update_overlay) def hide_overlay(): """Hide the overlay window""" global overlay_visible if overlay_visible: overlay.withdraw() overlay_visible = False def get_active_process_name(): hwnd = win32gui.GetForegroundWindow() if hwnd: _, pid = win32process.GetWindowThreadProcessId(hwnd) try: process = psutil.Process(pid) return process.name() except (psutil.NoSuchProcess, psutil.AccessDenied): return None return None def execute_sequence1(): # First script's sequence original_pos = pyautogui.position() pyautogui.press('w') pyautogui.moveTo(1797, 249, duration=0) pyautogui.click() pyautogui.moveTo(original_pos.x, original_pos.y, duration=0) def execute_sequence2(): # Second script's sequence original_pos = pyautogui.position() pyautogui.press('w') pyautogui.moveTo(1866, 252, duration=0) pyautogui.click() pyautogui.moveTo(original_pos.x, original_pos.y, duration=0) def on_press(key): global current_sequence if not game_running: return True if get_active_process_name() != "gamemd-spawn.exe": return True # Switch sequence on K/k press if key in (keyboard.KeyCode.from_char('k'), keyboard.KeyCode.from_char('K')): current_sequence = 1 if current_sequence == 2 else 2 print(f"\nSwitched to Sequence {current_sequence}") return True # Execute current sequence on J/j press if key in (keyboard.KeyCode.from_char('j'), keyboard.KeyCode.from_char('J')): if current_sequence == 1: execute_sequence1() else: execute_sequence2() return True def monitor_game_process(): """Track game status and window position""" global game_running, game_window_rect while program_running: game_exists = any( proc.name() == "gamemd-spawn.exe" for proc in psutil.process_iter(['name']) ) # Update game running status game_running = game_exists # Find game window position if running game_window_rect = None if game_exists: try: # Find game window by process name def callback(hwnd, hwnds): if win32gui.IsWindowVisible(hwnd): _, pid = win32process.GetWindowThreadProcessId(hwnd) try: proc = psutil.Process(pid) if proc.name() == "gamemd-spawn.exe": hwnds.append(hwnd) except: pass return True hwnds = [] win32gui.EnumWindows(callback, hwnds) if hwnds: game_window_rect = win32gui.GetWindowRect(hwnds[0]) except: pass time.sleep(1) def main(): global program_running print("Para/Non Para Autoic for Red Alert 2 (Only)") print("This program works only with 1920x1080, as its coordinates") print("==========================================") print("Press 'J' in-game : Execute with para sequence") print("Press 'K' in-game : Switch to without para") print("Press 'F12': Exit program") print("------------------------------------------") print("Sequence 1: Coordinates (1797, 249) Without Para") print("Sequence 2: Coordinates (1866, 252) With Para") print("------------------------------------------") print("This window must remain open during gameplay") print("Close this window to exit the AutoIC Program") print("------------------------------------------") print("Made by rileduv with love <3") print("Contact me on discord rileduv") # Start game monitoring thread monitor_thread = threading.Thread(target=monitor_game_process, daemon=True) monitor_thread.start() # Start keyboard listener thread listener_thread = threading.Thread( target=lambda: keyboard.Listener(on_press=on_press).start(), daemon=True ) listener_thread.start() # Set up F12 as exit hotkey def on_f12(): global program_running program_running = False overlay.destroy() print("\nExiting program...") exit_listener = keyboard.GlobalHotKeys({'': on_f12}) exit_listener.start() # Start overlay updates overlay.after(100, update_overlay) # Start the Tkinter main loop try: overlay.mainloop() except: program_running = False if __name__ == "__main__": main()