diff --git a/openrecall/app.py b/openrecall/app.py index df1550a..70cf7a9 100644 --- a/openrecall/app.py +++ b/openrecall/app.py @@ -88,9 +88,16 @@ def get_active_app_name_windows(): """returns the app's name .exe""" import psutil import win32gui + import win32process - pid = win32gui.GetForegroundWindow() - exe = psutil.Process(win32gui.GetWindowThreadProcessId(pid)[-1]).name() + # Get the handle of the foreground window + hwnd = win32gui.GetForegroundWindow() + + # Get the thread process ID of the foreground window + _, pid = win32process.GetWindowThreadProcessId(hwnd) + + # Get the process name using psutil + exe = psutil.Process(pid).name() return exe @@ -299,9 +306,11 @@ def human_readable_time(timestamp): def timestamp_to_human_readable(timestamp): import datetime - - dt_object = datetime.datetime.fromtimestamp(timestamp) - return dt_object.strftime("%Y-%m-%d %H:%M:%S") + try: + dt_object = datetime.datetime.fromtimestamp(timestamp) + return dt_object.strftime("%Y-%m-%d %H:%M:%S") + except: + return "" app.jinja_env.filters["human_readable_time"] = human_readable_time @@ -364,6 +373,7 @@ def timeline(): +{% if timestamps|length > 0 %}
@@ -373,7 +383,14 @@ def timeline(): Image for timestamp
+{% else %} +
+ +
+{% endif %} diff --git a/requirements.txt b/requirements.txt index e8d40ee..f656af7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,5 @@ torchvision==0.18.0 git+https://github.com/koenvaneijk/doctr.git shapely h5py -rapidfuzz \ No newline at end of file +rapidfuzz +psutil \ No newline at end of file