From 9a70a693eb0542c38ae1fb0b1c862d0a337249c1 Mon Sep 17 00:00:00 2001 From: p7mj Date: Wed, 28 Jan 2026 08:09:28 -0500 Subject: [PATCH] Updated interceptor-aps.py Credits to SpyDrone: reverted the intervals between cover launch and minimizing from 0.1 seconds to 0.5 seconds to allow system to finish minimizing --- interceptor-aps.py | 328 ++++++++++++++++++++++----------------------- 1 file changed, 164 insertions(+), 164 deletions(-) diff --git a/interceptor-aps.py b/interceptor-aps.py index f9a74dc..e20387f 100644 --- a/interceptor-aps.py +++ b/interceptor-aps.py @@ -1,164 +1,164 @@ -import threading -import time -from watchfiles import watch -import pygetwindow as gw -import pyautogui -import subprocess -from termcolor import colored - -# ---------- CONFIGURATION ---------- # -monitor_path = r"C:\Program Files\Renato Software\Senso.Cloud.Client" # Path to be monitored - -# ---------- DON'T TOUCH ---------- # -program = "" # 0 is use path, -1 is use name, 1-4 is programs -p_name = "" -p_path = "" # used only if program = 0. - -# ---------- BRING TO FRONT ---------- # -def bring_to_front(window_title): - time.sleep(0.1) - try: - print("Bringing to front...", end = " ") - windows = gw.getWindowsWithTitle(window_title) - if windows: - window = windows[0] - window.restore() - window.activate() - print("Window has been brought to front.") - else: - print(colored("ERROR: Window not found", 'red')) - except Exception as e: - print(colored(f"Error: {e}", 'red')) - -# ---------- FILE WATCHER ---------- # -def file_watch(): - print("=" * 80) - print("Monitoring changes in " + monitor_path + ".") - print("-" * 80) - try: - for changes in watch(monitor_path): - for change_type, path in changes: - print(f"Change type: {change_type}, Path: {path}") - return True - except Exception as e: - print(colored(f"File Watch Error: {e}", 'red')) - -# ---------- MINIMIZE ---------- # -def minimize(): - print("=" * 80) - print("Minimizing all windows...", end = " ") - pyautogui.hotkey('win', 'd') - print("Completed.") - -# ---------- LAUNCH COVER PROGRAM ---------- # -def launch_cover(programs): - time.sleep(0.1) - print("=" * 80) - print("Launching cover application...", end = " ") - if programs == "1": # Chrome - try: - subprocess.run( - ["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"] - ) - print("Launched Chrome.") - except Exception as e: - print(colored(f"Chrome Launch Error: {e}", 'red')) - - elif programs == "2": # Edge - try: - subprocess.run( - ["C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"] - ) - print("Launched Edge.") - except Exception as e: - print(colored(f"Edge Launch Error: {e}", 'red')) - - elif programs == "3": # Adobe Illustrator - try: - subprocess.run( - ["C:\\Program Files\\Adobe\\Adobe Illustrator 2025\\Support Files\\Contents\\Windows\\Illustrator.exe"] - ) - print("Launched Illustrator.") - except Exception as e: - print(colored(f"Illustrator Launch Error: {e}", 'red')) - - elif programs == "4": # Onenote - try: - subprocess.run( - ["C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"] - ) - print("Launched OneNote.") - except Exception as e: - print(colored(f"OneNote Launch Error: {e}", 'red')) - - else: - print(colored("Error: Invalid Cover App Specified.", 'red')) - -# ---------- LAUNCH COVER PROGRAM PATH ---------- # -def launch_cover_path(path): - print("Launching custom path...", end = " ") - time.sleep(0.1) - subprocess.run( - [path] - ) - print("Launched custom path.") - -# ---------- Main Process ---------- # -def main(): - global p_name, p_path - - print("=" * 80) - print("Interceptor APS (Active Protection System)") - print("-" * 80) - print("Choose a cover app to open:") - print("[1] Chrome (empty)") - print("[2] Edge (empty)") - print("[3] Adobe Illustrator (predetermined)") - print("[4] Onenote (Identical)") - print("[5] Enter a path (Not recommended)") - print("[6] It has a name (NOTE)", end = "\n\n") - print("- Empty: window opens empty") - print("- Predetermined: window opens with whatever was on it.") - print(" * Requires having it open in the first place") - print("- Identical: a NEW window opens with what you had earlier/what you have now.") - print("- Not recommended: Only use this if you know what you're doing.") - print(" * If you get the path wrong, the program will fail you at the most critical moment.") - print("- NOTE: Probably the best way by far.") - print(" * Type the name of the window (partial names work, like note for OneNote) and it will pop up.") - program = input("Enter your option > ") - - if program == "5": # If path is selected (I doubt that) - p_path = input("Enter full path > ") - program = "0" # Indicate that the path option is selected - elif program == "6": # If name is chosen - program = "-1" # Indicate that the name option is selected - p_name = input("Name > ") - else: - pass # All other options, if selected, are already stored in program by this time - - # Begin the watching process. - try: - watchresults = file_watch() - except KeyboardInterrupt: - print("Canceled by user.") - sys.exit(0) - - # If it advances to below then there must have been a file change. (VERIFY) - if program == "0": # If we chose path - minimize() - launch_cover_path(p_path) # VERIFY IF DOUBLE ESCAPES ARE NEEDED WHEN PATH IS FIRST ENTERED BY USER - elif program == "-1": # If we chose name - minimize() - bring_to_front(p_name) - else: - minimize() - launch_cover(program) # Other options must be string numbers 1-4 - - -# ---------- Running the code ---------- # -if __name__ == "__main__": - main() - - - - +import threading +import time +from watchfiles import watch +import pygetwindow as gw +import pyautogui +import subprocess +from termcolor import colored + +# ---------- CONFIGURATION ---------- # +monitor_path = r"C:\Program Files\Renato Software\Senso.Cloud.Client" # Path to be monitored + +# ---------- DON'T TOUCH ---------- # +program = "" # 0 is use path, -1 is use name, 1-4 is programs +p_name = "" +p_path = "" # used only if program = 0. + +# ---------- BRING TO FRONT ---------- # +def bring_to_front(window_title): + time.sleep(0.5) + try: + print("Bringing to front...", end = " ") + windows = gw.getWindowsWithTitle(window_title) + if windows: + window = windows[0] + window.restore() + window.activate() + print("Window has been brought to front.") + else: + print(colored("ERROR: Window not found", 'red')) + except Exception as e: + print(colored(f"Error: {e}", 'red')) + +# ---------- FILE WATCHER ---------- # +def file_watch(): + print("=" * 80) + print("Monitoring changes in " + monitor_path + ".") + print("-" * 80) + try: + for changes in watch(monitor_path): + for change_type, path in changes: + print(f"Change type: {change_type}, Path: {path}") + return True + except Exception as e: + print(colored(f"File Watch Error: {e}", 'red')) + +# ---------- MINIMIZE ---------- # +def minimize(): + print("=" * 80) + print("Minimizing all windows...", end = " ") + pyautogui.hotkey('win', 'd') + print("Completed.") + +# ---------- LAUNCH COVER PROGRAM ---------- # +def launch_cover(programs): + time.sleep(0.5) + print("=" * 80) + print("Launching cover application...", end = " ") + if programs == "1": # Chrome + try: + subprocess.run( + ["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"] + ) + print("Launched Chrome.") + except Exception as e: + print(colored(f"Chrome Launch Error: {e}", 'red')) + + elif programs == "2": # Edge + try: + subprocess.run( + ["C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"] + ) + print("Launched Edge.") + except Exception as e: + print(colored(f"Edge Launch Error: {e}", 'red')) + + elif programs == "3": # Adobe Illustrator + try: + subprocess.run( + ["C:\\Program Files\\Adobe\\Adobe Illustrator 2025\\Support Files\\Contents\\Windows\\Illustrator.exe"] + ) + print("Launched Illustrator.") + except Exception as e: + print(colored(f"Illustrator Launch Error: {e}", 'red')) + + elif programs == "4": # Onenote + try: + subprocess.run( + ["C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"] + ) + print("Launched OneNote.") + except Exception as e: + print(colored(f"OneNote Launch Error: {e}", 'red')) + + else: + print(colored("Error: Invalid Cover App Specified.", 'red')) + +# ---------- LAUNCH COVER PROGRAM PATH ---------- # +def launch_cover_path(path): + print("Launching custom path...", end = " ") + time.sleep(0.5) + subprocess.run( + [path] + ) + print("Launched custom path.") + +# ---------- Main Process ---------- # +def main(): + global p_name, p_path + + print("=" * 80) + print("Interceptor APS (Active Protection System)") + print("-" * 80) + print("Choose a cover app to open:") + print("[1] Chrome (empty)") + print("[2] Edge (empty)") + print("[3] Adobe Illustrator (predetermined)") + print("[4] Onenote (Identical)") + print("[5] Enter a path (Not recommended)") + print("[6] It has a name (NOTE)", end = "\n\n") + print("- Empty: window opens empty") + print("- Predetermined: window opens with whatever was on it.") + print(" * Requires having it open in the first place") + print("- Identical: a NEW window opens with what you had earlier/what you have now.") + print("- Not recommended: Only use this if you know what you're doing.") + print(" * If you get the path wrong, the program will fail you at the most critical moment.") + print("- NOTE: Probably the best way by far.") + print(" * Type the name of the window (partial names work, like note for OneNote) and it will pop up.") + program = input("Enter your option > ") + + if program == "5": # If path is selected (I doubt that) + p_path = input("Enter full path > ") + program = "0" # Indicate that the path option is selected + elif program == "6": # If name is chosen + program = "-1" # Indicate that the name option is selected + p_name = input("Name > ") + else: + pass # All other options, if selected, are already stored in program by this time + + # Begin the watching process. + try: + watchresults = file_watch() + except KeyboardInterrupt: + print("Canceled by user.") + sys.exit(0) + + # If it advances to below then there must have been a file change. (VERIFY) + if program == "0": # If we chose path + minimize() + launch_cover_path(p_path) # VERIFY IF DOUBLE ESCAPES ARE NEEDED WHEN PATH IS FIRST ENTERED BY USER + elif program == "-1": # If we chose name + minimize() + bring_to_front(p_name) + else: + minimize() + launch_cover(program) # Other options must be string numbers 1-4 + + +# ---------- Running the code ---------- # +if __name__ == "__main__": + main() + + + +