From 2e8350bdf17d5e878fef922d5695a089ad4e4e2a Mon Sep 17 00:00:00 2001 From: TvT <16676419+tvturnhout@users.noreply.github.com> Date: Tue, 4 Jun 2024 10:33:28 +0200 Subject: [PATCH] fixed for windows --- openrecall/app.py | 27 ++++++++++++++++++++++----- requirements.txt | 3 ++- 2 files changed, 24 insertions(+), 6 deletions(-) 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 %}