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
This commit is contained in:
2026-01-28 08:09:28 -05:00
parent aa9895e049
commit 9a70a693eb

View File

@@ -1,164 +1,164 @@
import threading import threading
import time import time
from watchfiles import watch from watchfiles import watch
import pygetwindow as gw import pygetwindow as gw
import pyautogui import pyautogui
import subprocess import subprocess
from termcolor import colored from termcolor import colored
# ---------- CONFIGURATION ---------- # # ---------- CONFIGURATION ---------- #
monitor_path = r"C:\Program Files\Renato Software\Senso.Cloud.Client" # Path to be monitored monitor_path = r"C:\Program Files\Renato Software\Senso.Cloud.Client" # Path to be monitored
# ---------- DON'T TOUCH ---------- # # ---------- DON'T TOUCH ---------- #
program = "" # 0 is use path, -1 is use name, 1-4 is programs program = "" # 0 is use path, -1 is use name, 1-4 is programs
p_name = "" p_name = ""
p_path = "" # used only if program = 0. p_path = "" # used only if program = 0.
# ---------- BRING TO FRONT ---------- # # ---------- BRING TO FRONT ---------- #
def bring_to_front(window_title): def bring_to_front(window_title):
time.sleep(0.1) time.sleep(0.5)
try: try:
print("Bringing to front...", end = " ") print("Bringing to front...", end = " ")
windows = gw.getWindowsWithTitle(window_title) windows = gw.getWindowsWithTitle(window_title)
if windows: if windows:
window = windows[0] window = windows[0]
window.restore() window.restore()
window.activate() window.activate()
print("Window has been brought to front.") print("Window has been brought to front.")
else: else:
print(colored("ERROR: Window not found", 'red')) print(colored("ERROR: Window not found", 'red'))
except Exception as e: except Exception as e:
print(colored(f"Error: {e}", 'red')) print(colored(f"Error: {e}", 'red'))
# ---------- FILE WATCHER ---------- # # ---------- FILE WATCHER ---------- #
def file_watch(): def file_watch():
print("=" * 80) print("=" * 80)
print("Monitoring changes in " + monitor_path + ".") print("Monitoring changes in " + monitor_path + ".")
print("-" * 80) print("-" * 80)
try: try:
for changes in watch(monitor_path): for changes in watch(monitor_path):
for change_type, path in changes: for change_type, path in changes:
print(f"Change type: {change_type}, Path: {path}") print(f"Change type: {change_type}, Path: {path}")
return True return True
except Exception as e: except Exception as e:
print(colored(f"File Watch Error: {e}", 'red')) print(colored(f"File Watch Error: {e}", 'red'))
# ---------- MINIMIZE ---------- # # ---------- MINIMIZE ---------- #
def minimize(): def minimize():
print("=" * 80) print("=" * 80)
print("Minimizing all windows...", end = " ") print("Minimizing all windows...", end = " ")
pyautogui.hotkey('win', 'd') pyautogui.hotkey('win', 'd')
print("Completed.") print("Completed.")
# ---------- LAUNCH COVER PROGRAM ---------- # # ---------- LAUNCH COVER PROGRAM ---------- #
def launch_cover(programs): def launch_cover(programs):
time.sleep(0.1) time.sleep(0.5)
print("=" * 80) print("=" * 80)
print("Launching cover application...", end = " ") print("Launching cover application...", end = " ")
if programs == "1": # Chrome if programs == "1": # Chrome
try: try:
subprocess.run( subprocess.run(
["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"] ["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe"]
) )
print("Launched Chrome.") print("Launched Chrome.")
except Exception as e: except Exception as e:
print(colored(f"Chrome Launch Error: {e}", 'red')) print(colored(f"Chrome Launch Error: {e}", 'red'))
elif programs == "2": # Edge elif programs == "2": # Edge
try: try:
subprocess.run( subprocess.run(
["C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"] ["C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"]
) )
print("Launched Edge.") print("Launched Edge.")
except Exception as e: except Exception as e:
print(colored(f"Edge Launch Error: {e}", 'red')) print(colored(f"Edge Launch Error: {e}", 'red'))
elif programs == "3": # Adobe Illustrator elif programs == "3": # Adobe Illustrator
try: try:
subprocess.run( subprocess.run(
["C:\\Program Files\\Adobe\\Adobe Illustrator 2025\\Support Files\\Contents\\Windows\\Illustrator.exe"] ["C:\\Program Files\\Adobe\\Adobe Illustrator 2025\\Support Files\\Contents\\Windows\\Illustrator.exe"]
) )
print("Launched Illustrator.") print("Launched Illustrator.")
except Exception as e: except Exception as e:
print(colored(f"Illustrator Launch Error: {e}", 'red')) print(colored(f"Illustrator Launch Error: {e}", 'red'))
elif programs == "4": # Onenote elif programs == "4": # Onenote
try: try:
subprocess.run( subprocess.run(
["C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"] ["C:\\Program Files (x86)\\Microsoft Office\\root\\Office16\\ONENOTE.EXE"]
) )
print("Launched OneNote.") print("Launched OneNote.")
except Exception as e: except Exception as e:
print(colored(f"OneNote Launch Error: {e}", 'red')) print(colored(f"OneNote Launch Error: {e}", 'red'))
else: else:
print(colored("Error: Invalid Cover App Specified.", 'red')) print(colored("Error: Invalid Cover App Specified.", 'red'))
# ---------- LAUNCH COVER PROGRAM PATH ---------- # # ---------- LAUNCH COVER PROGRAM PATH ---------- #
def launch_cover_path(path): def launch_cover_path(path):
print("Launching custom path...", end = " ") print("Launching custom path...", end = " ")
time.sleep(0.1) time.sleep(0.5)
subprocess.run( subprocess.run(
[path] [path]
) )
print("Launched custom path.") print("Launched custom path.")
# ---------- Main Process ---------- # # ---------- Main Process ---------- #
def main(): def main():
global p_name, p_path global p_name, p_path
print("=" * 80) print("=" * 80)
print("Interceptor APS (Active Protection System)") print("Interceptor APS (Active Protection System)")
print("-" * 80) print("-" * 80)
print("Choose a cover app to open:") print("Choose a cover app to open:")
print("[1] Chrome (empty)") print("[1] Chrome (empty)")
print("[2] Edge (empty)") print("[2] Edge (empty)")
print("[3] Adobe Illustrator (predetermined)") print("[3] Adobe Illustrator (predetermined)")
print("[4] Onenote (Identical)") print("[4] Onenote (Identical)")
print("[5] Enter a path (Not recommended)") print("[5] Enter a path (Not recommended)")
print("[6] It has a name (NOTE)", end = "\n\n") print("[6] It has a name (NOTE)", end = "\n\n")
print("- Empty: window opens empty") print("- Empty: window opens empty")
print("- Predetermined: window opens with whatever was on it.") print("- Predetermined: window opens with whatever was on it.")
print(" * Requires having it open in the first place") 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("- 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("- 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(" * 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("- 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.") print(" * Type the name of the window (partial names work, like note for OneNote) and it will pop up.")
program = input("Enter your option > ") program = input("Enter your option > ")
if program == "5": # If path is selected (I doubt that) if program == "5": # If path is selected (I doubt that)
p_path = input("Enter full path > ") p_path = input("Enter full path > ")
program = "0" # Indicate that the path option is selected program = "0" # Indicate that the path option is selected
elif program == "6": # If name is chosen elif program == "6": # If name is chosen
program = "-1" # Indicate that the name option is selected program = "-1" # Indicate that the name option is selected
p_name = input("Name > ") p_name = input("Name > ")
else: else:
pass # All other options, if selected, are already stored in program by this time pass # All other options, if selected, are already stored in program by this time
# Begin the watching process. # Begin the watching process.
try: try:
watchresults = file_watch() watchresults = file_watch()
except KeyboardInterrupt: except KeyboardInterrupt:
print("Canceled by user.") print("Canceled by user.")
sys.exit(0) sys.exit(0)
# If it advances to below then there must have been a file change. (VERIFY) # If it advances to below then there must have been a file change. (VERIFY)
if program == "0": # If we chose path if program == "0": # If we chose path
minimize() minimize()
launch_cover_path(p_path) # VERIFY IF DOUBLE ESCAPES ARE NEEDED WHEN PATH IS FIRST ENTERED BY USER 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 elif program == "-1": # If we chose name
minimize() minimize()
bring_to_front(p_name) bring_to_front(p_name)
else: else:
minimize() minimize()
launch_cover(program) # Other options must be string numbers 1-4 launch_cover(program) # Other options must be string numbers 1-4
# ---------- Running the code ---------- # # ---------- Running the code ---------- #
if __name__ == "__main__": if __name__ == "__main__":
main() main()