Notepad2: get path

Post your working scripts, libraries and tools
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Notepad2: get path

18 Aug 2018, 14:29

- Here is a script to retrieve the path of the text file from Notepad2.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


- To set the path, see the JEE_NotepadSetPath function here. It emulates a drag-and-drop to set the file path. (A technique that works on about half of the programs I use.)
notepad get/set path (get/set text file path) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=30050

- See also:
Notepad++: get path - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=54267
drozdman
Posts: 63
Joined: 05 Dec 2015, 01:07

Re: Notepad2: get path

30 Aug 2018, 11:25

@jeeswg
Thanks for the idea. The message for Notepad++ works perfectly, though the Notepad2 version doesn't work for me and creates some problems.
I needed something like that for Notepad2. I found in the help file "Shift+F9" shortcut for copying path in Notepad2. And that's how I got the message from Resource Hacker in menu (If I remember correctly it was your tip about the method).
Edit: Correction: I used "Resource Hacker" for Scite, but for Notepad2 I used "Winspector Spy".

Code: [Select all] [Download] GeSHi © Codebox Plus

SendMessage,0x0111,20032,,, ahk_class Notepad2U ;copy path
MsgBox,4096,, % clipboard


I got something like that also for Scite:

Code: [Select all] [Download] GeSHi © Codebox Plus

SendMessage,0x0111,118,,, ahk_class SciTEWindow  ;copy path  ;Shift+F9 
MsgBox,4096,, % clipboard
Last edited by drozdman on 30 Aug 2018, 14:12, edited 1 time in total.
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Notepad2: get path

30 Aug 2018, 12:45

- Great find, cheers.
- The Shift+F9 shortcut does not appear in the menus AFAICS.
- So, like you said, noticing 'Shift+F9' in the help file and then using Resource Hacker, would be a way to get the PostMessage/SendMessage ID.
- Other tools would be HotkeyP and Microsoft Spy++.
- If you're able to explain why the technique in the OP isn't working for you, that would be good to know.
- Here's a link to the help:
Notepad2.txt
http://www.flos-freeware.ch/doc/Notepad2.txt
- Here's a list of menu constants:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

- I really like Notepad2, and like to see when other people use it. One thing I like is simply that it doesn't do odd indentation by default like Notepad++.
Last edited by jeeswg on 30 Aug 2018, 20:20, edited 2 times in total.
drozdman
Posts: 63
Joined: 05 Dec 2015, 01:07

Re: Notepad2: get path

30 Aug 2018, 14:04

● It doesn't show anything. And I got drawing problems.
● I wrote it incorrectly, because I mingled Notepad2 and Scite. I used "Resource Hacker" for Scite, but for Notepad2 I used simply "Winspector Spy".
● Thanks for the tip about HotkeyP and Microsoft Spy++. They can spy on WM_COMMAND? I used at times "API Monitor". Though, I can't intercept much in "Save dialogs" or even "Windows Explorer".
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Notepad2: get path

30 Aug 2018, 14:14

- HotkeyP can only spy on WM_COMMAND. Microsoft Spy++ is similar to Winspector.
- IIRC I've managed to get every bit of automation I would like from Open/Save As dialogs/Explorer. With Explorer, sometimes I use messages, but a lot of the time it's COM.
jeeswg's Explorer tutorial - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=7&t=31755
[Script] PersistentSaveFolder - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=41306&p=188705#p188705
drozdman
Posts: 63
Joined: 05 Dec 2015, 01:07

Re: Notepad2: get path

30 Aug 2018, 15:08

● Cool, I will try those two programs
● Nice tutorial. I added my sort in "Windows Explorer" there
Though, I have been looking for Save/Open dialogs change of paths. It's not as easy as in shell windows (I used some crude methods here Toolbar for "Open/Save As" dialogs).
This is more hidden.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: buttshark and 19 guests