Apr-07-2021, 05:00 PM
(Apr-07-2021, 04:33 PM)bowlofred Wrote: Files aren't onscreen, windows are. File data may be used to draw some of the information in that window, but
that doesn't mean there's a one-to-one relationship between files and windows.
Unfortunately, GUIs aren't standardized in a cross-platform way. I don't know any way to query a window and have the controlling app respond with the filename associated with that window.
Or are you talking about a window that's part of your application?
I am talking about any text file that's open on screen in any text editor.
Here is an example inserted by a Windows text editor: 2021-04-07 - Z:\media\linux-data\google-drive\shared\linux-notes.txt
This is what I have so far.
# Description, kybd = win + INS insert current date, time and path and filename import os, time, datetime ts = time.time() time_stamp = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M') + " " # file_name = keyboard.send_keys(time_stamp) # keyboard.send_keys(time_stamp + "-" + file_name)Please note that "keyboard.send_keys" is the substitute for print()
If I knew how to access the system variables in Python, I am sure that one of them would have the active filename.