Python Forum
read active document name - other than from the window title
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
read active document name - other than from the window title
#1
This simple date time & filename script is activated from Autokey and works well, except where I need it most - in Geany. In a GTK based theme, regardless of the title font size, the filename is shortened to fit long file names in their scheme.

Here are two apps displaying the filename in their title-bar, both in GTK and same theme in Cinnamon:

# 2023-08-06 01:38 - utils_update_system_and local_mime_databases.sh - Pluma
# 2023-09-08 22:24 - utils_update_s…me_databases.sh - /media/dgdrive/scripts/utils - Geany

I am looking for the code snippet to extract the active document name in Python before it's been altered by a display.

This is my current script.

clipboard.fill_clipboard('')
time.sleep(0.1)

activetitle_ = window.get_active_title()
time.sleep(0.1)

home_ = '<home>'
paste_ = '<shift>+<insert>'
ts_ = time.time()
timestamp_ = datetime.datetime.fromtimestamp(ts_).strftime('%Y-%m-%d %H:%M')
time.sleep(0.1)

combined_ = '# ' + timestamp_ + ' - ' + activetitle_
time.sleep(0.1)

clipboard.fill_clipboard(combined_)
time.sleep(0.1)

keyboard.send_keys(home_)

keyboard.send_keys(paste_)
Linux Mint Cinnamon 21.3 - Python 3.10.12 - Autokey-gtk 0.96.0 as of 2024-01-13.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Active Directory integration dady 2 515 Oct-13-2023, 04:02 AM
Last Post: deanhystad
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,800 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,185 Jun-13-2022, 08:59 AM
Last Post: Shena76
  Read and write active Excel file euras 4 3,521 Jun-29-2021, 11:16 PM
Last Post: Pedroski55
  How to read check boxes from word document srikanthpython 0 2,605 Mar-30-2021, 01:58 PM
Last Post: srikanthpython
  Active Directory add an attribute. SpongeB0B 2 2,248 Oct-13-2020, 05:36 AM
Last Post: SpongeB0B
  A problem with a TButton's foreground 'active' color. Mik3e 0 1,418 Sep-10-2020, 01:12 AM
Last Post: Mik3e
  Edit Open and Active Excel sheet in Python JoeDainton123 1 2,122 Jul-29-2020, 12:52 AM
Last Post: Larz60+
  Python3/Flask/LDAP-Active Directory tundrwd 1 36,876 Dec-13-2019, 05:48 PM
Last Post: Clunk_Head
  How to change font size of chart title and axis title ? thrupass 5 15,613 Mar-30-2018, 04:02 PM
Last Post: DrFunn1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020