Python Forum
Get filepath to save from notepad.exe python3
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get filepath to save from notepad.exe python3
#1
I'm looking to obtain the file path for any output save files from notepad. A user may choose to save anywhere so directory monitoring didn't seem feesable. I've tried using the subprocess module to open notepad and obtain it's stdout, but it outputs to file. I've been instructed to explore hooking. If I can help it I'd like to not go that route.
Is it possible to use a bat file to set up a pipe that would read it's output file path?
Or am I not understanding the subprocess module?
Is hooking createfile() the only route?
Im capable of figuring most stuff out but my brain can only think of so much stuff for Google searches and the likes. There wasn't an obvious answer and I can't think of anymore searches so I apologise if it's simple to another, but this is where I'm stuck for now.
Reply
#2
Not quite sure what you are trying to do. As you point out, Notepad (or any program that allows saving really) can save a file almost anywhere, though the default, at least as far as Notepad is concerned, is the users Document folder. Also, by default, it will save as a plain '.txt' file with ANSI encoding, but again those can be changed. Given that other programs are also able to save files as '.txt' files. Many file types, including rich text files (formatted text files) have a file 'signature' contained in the first few bytes of the file (header), plain text files do not. I'm not sure there is a way to determine, with 100% accuracy, that a file was created by Notepad. Also, plain text files are not the only ones without a header or signature, so scanning the first few bytes would be somewhat pointless.

Even if you opened an instance of Notepad and 'forced' it to save to a specific directory, what would prevent the user from moving it to another directory that your program is not aware of?
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to save to multiple locations during save cubangt 1 509 Oct-23-2023, 10:16 PM
Last Post: deanhystad
Question Trouble installing modules/libraries and getting Notepad++ to show cyrillic letters Dragiev 6 2,179 Jul-24-2022, 12:55 PM
Last Post: Dragiev
  How to concatenate filepath with variable? Mark17 2 5,441 Jan-31-2022, 09:13 PM
Last Post: Mark17
  Output CSV file with filepath and file contents glittergirl 1 1,705 Aug-03-2020, 01:50 AM
Last Post: glittergirl
  Trying to pass an exe filepath to tkinter Chatbot & expecting the chatbot to run it svkroy 0 1,557 Jul-16-2020, 07:46 AM
Last Post: svkroy
  pytest in CircleCI filepath error alyflex 0 1,246 Apr-20-2020, 04:39 PM
Last Post: alyflex
  Variable from notepad problem samuelbachorik 2 2,259 Apr-10-2020, 09:04 AM
Last Post: samuelbachorik
  Gnuradio python3 is not compatible python3 xmlrpc library How Can I Fix İt ? muratoznnnn 3 4,820 Nov-07-2019, 05:47 PM
Last Post: DeaD_EyE
  Running python code meant for Notepad++ plugin independently greektranslator 3 2,933 Jan-28-2019, 06:03 PM
Last Post: maxtimbo
  Exporting Python Output to Notepad Nirmal 4 3,517 Sep-02-2018, 02:36 PM
Last Post: Nirmal

Forum Jump:

User Panel Messages

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