add tesseract, db to gitignore, update lockfile, change code, add web component

This commit is contained in:
2025-07-03 14:50:25 +02:00
parent 6d2cbe9e36
commit 1c13ee48cb
7 changed files with 308 additions and 47 deletions

115
main.py
View File

@@ -1,64 +1,91 @@
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
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,
get_mednr_exempl,
enter_print_mode,
exit_print_mode,
)
from src.adischeck_online import run, work_on_page
import pyautogui
from src.database import Database
import time
import sys
import clipboard
from playwright.sync_api import Playwright, sync_playwright, expect
catalogue_pid = None
print_pid = None
database = Database()
page = run()
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)
# 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.press("up")
# # 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)
print("Starting the script...")
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")
mednr = get_mednr_exempl()
print("Mednr:", mednr)
pyautogui.hotkey("alt", "s")
work_on_page(page, mednr)
enter_print_mode()
pyautogui.press("space")
time.sleep(1)
print_new_signature(catalogue_pid, print_pid, mednr)
new_search()
exit_print_mode()
# keyboard.wait('space')
# 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")
# 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")