import keyboard from src.adischeck import is_adis_running, get_active_name, print_new_signature, adis_get_signature, adis_save_and_enter_exemplar, new_search, taskswitcher_name import pyautogui from src.database import Database import time import sys import clipboard catalogue_pid = None print_pid = None database = Database() def main(): global catalogue_pid, print_pid if not is_adis_running(): print("aDISCl is not running. Please start all required aDIS instances and try again.") return print("aDISCl is running. Proceeding to capture PIDs...") print("Press 'c' to capture the PID of the Catalogue aDIS instance.") keyboard.wait('c') #press backspace to clear any previous input catalogue_pid = get_active_name() print("Captured Catalogue PID:", catalogue_pid) pyautogui.hotkey("ctrl", "a") # Switch to the next aDIS instance pyautogui.hotkey("delete") # pyautogui.press("backspace") print("Press 'p' to capture the PID of the Print aDIS instance.") keyboard.wait('p') print_pid = get_active_name() print("Captured Print PID:", print_pid) pyautogui.hotkey("ctrl", "a") # Switch to the next aDIS instance pyautogui.hotkey("delete") if catalogue_pid and print_pid: print("Both Catalogue and Print PIDs captured successfully.") print("Switching back to Catalogue aDIS instance...") taskswitcher_name(catalogue_pid) # Switch to Catalogue aDIS instance # pyautogui.hotkey("alt", "s") # Open the search dialog in Catalogue aDIS else: print("Failed to capture one or both PIDs. Please ensure you have the correct aDIS instances open.") print("Exiting the program.") sys.exit(1) while True: keyboard.wait('space') print("Space key pressed. Switching to Catalogue aDIS instance...") time.sleep(5) text = adis_get_signature() new = database.insert_ma(text) clipboard.copy(new) # Copy the new signature to clipboard print(text, new) pyautogui.hotkey('ctrl', 'v') # Select all text mednr = adis_save_and_enter_exemplar(new) # Example usage with a new signature print("finished main work, printing new signature") time.sleep(1) print_new_signature(catalogue_pid, print_pid, mednr) new_search() if __name__ == "__main__": main() # time.sleep(5) # Wait for a few seconds before starting # print_new_signature("3 - PHFR: Katalog - aDIS/Client", "4 - PHFR(42): Exemplare - aDIS/Client", "004862920129")