Notepad++: get path

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

Notepad++: get path

18 Aug 2018, 15:12

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

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:
Notepad2: get path - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=54265
VismundCygnus
Posts: 12
Joined: 23 Dec 2017, 12:16

Re: Notepad++: get path

18 Aug 2018, 17:55

Clipboard and WinTitle are pretty unreliable. This is a much more stable method:

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

Last edited by VismundCygnus on 20 Aug 2018, 11:04, edited 1 time in total.
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Notepad++: get path

18 Aug 2018, 18:08

- Many thanks for this. I did a bit of searching and didn't come across NPPM_GETFULLCURRENTPATH.
- Warning: I would save any files before testing the function, since interacting with the address space of another process can potentially cause crashes and thus the loss of data.
VismundCygnus
Posts: 12
Joined: 23 Dec 2017, 12:16

Re: Notepad++: get path

20 Aug 2018, 11:06

Turns out that the method I was using before to determine the PID and necessary hwnd of the Notepad++ class was less than reliable. I've updated the post with what I hope will be much less prone to failure. Changed how I did a few things and threw in a couple more failsafes as well as tried to include a bit of commenting to maybe make things a bit more clear.
User avatar
TheDewd
Posts: 1037
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Notepad++: get path

22 Aug 2018, 13:33

You could also retrieve the ToolTip text from the tabs while hovering the mouse cursor over them:

Code: [Select all] [Download] (Untitled.ahk)GeSHi © Codebox Plus

#SingleInstance, Force

CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen

F1::
ControlGetText, tooltip1,, ahk_class tooltips_class32
MsgBox, % tooltip1
return


I don't like this method, but if you really need the info it's great to know more examples.
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Notepad++: get path

22 Aug 2018, 13:47

Here's another way. I don't use Notepad++ very much, so I only wrote it just now.

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

User avatar
TheDewd
Posts: 1037
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Notepad++: get path

22 Aug 2018, 14:11

Here's another one:

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
User avatar
jeeswg
Posts: 4991
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Notepad++: get path

30 Aug 2018, 20:33

- Here's a list of keyboard shortcuts:
Keyboard And Mouse Shortcuts - Notepad++ Wiki
http://docs.notepad-plus-plus.org/index.php/Keyboard_And_Mouse_Shortcuts
- Here's a list of menu constants:

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


Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 20 guests