Setup Notepad++ for AutoHotkey

Scripting and setups with Notepad++ and AutoHotkey.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Setup Notepad++ for AutoHotkey

01 Oct 2013, 04:15

Set up Notepad++ for AutoHotkey

( GitHub - Tested with Notepad++ v8.4.8 64-bit )



Syntax Highlighting
  • Download userDefineLang_AHK.xml (right-click the download link and choose Save link as)
  • Open your download folder
  • Start Notepad++ and click on menu Language -> User Defined Language -> Open User Defined Language folder...
  • Move userDefineLang_AHK.xml from your download folder to this folder
  • Restart Notepad++


Auto-Completion
  • Download AutoHotkey.xml (right-click the download link and choose Save link as)
  • Save it to the right location:
    • 32-Bit: C:\Program Files (x86)\Notepad++\autoCompletion\
    • 64-Bit: C:\Program Files\Notepad++\autoCompletion\
  • Start Notepad++ and click on menu Settings -> Preferences
  • Click on Auto-Completion and activate Enable auto-completion on each input
  • (Recommendation: From 2th character, Function completion & Function parameters hint on input)


Useful Notepad++ Plugins
These plugins may be useful when using Notepad++ to edit AutoHotkey scripts:
  • AutoSave - automatically save the currently open files based on a timer schedule.
  • RunMe - execute the currently open file, based on its shell association.
Install Notepad++ Plugins
You can install Notepad++ plugins by using the Notepad++ plugin manager:
  • Start Notepad++ and click on menu Plugins -> Plugins Admin...
  • Check the box for the plugins you want to install
  • Click Install
Or by using Notepad++ import:
  • Download the plugin's dll file
  • Start Notepad++ as administrator and click on menu Settings -> Import -> Import plugin(s)...
  • Navigate to the downloaded dll file and click the Open button


Set up AutoHotkey to Use Notepad++
AutoHotkey launches an editor to edit a script when menu option Edit Script or Edit This Script is selected. This menu option is listed in Windows Explorer's right-click menu and in several AutoHotkey menus.

If AutoHotkey v2 is installed
To set up AutoHotkey to use Notepad++ as script editor:
  • Run AutoHotkey (which launches AutoHotkey Dash) and click Editor settings
    (Or select Edit Script or Edit This Script in one of the menus if an editor has not been set yet)
  • A dialog will appear where you can set the editor of your choice. In the Command line field, enter the following text:

    Code: Select all

    Notepad++.exe "%L"
    
  • Click OK
If AutoHotkey v1 is installed and not also AutoHotkey v2
To set up AutoHotkey to use Notepad++ as script editor, do one of the following:
  • Create and run a .ahk file with the following contents (run as administrator):

    Code: Select all

    RegWrite REG_SZ, HKCR, AutoHotkeyScript\Shell\Edit\Command,, Notepad++.exe "`%L"
    
  • Or execute at the Command Prompt (run as administrator):

    Code: Select all

    REG ADD HKCR\AutoHotkeyScript\Shell\Edit\Command /ve /t REG_SZ /d "Notepad++.exe \"%L\"" /f
    


Others
  • Hotstrings - (by Helgef) expand parameters for AHK's functions, commands and directives.
  • FunctionList - enable function list in Notepad++ for AHK scripts.
  • MsgBox Creator - (by boiler) integrated into the editor like it is in SciTE4AutoHotkey.
  • Run - (by boiler) run a script directly from Notepad++ whether or not it has ever been saved to a file.


Downloads
Last edited by jNizM on 12 Jan 2023, 02:36, edited 8 times in total.
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Setup Notepad++ for AutoHotkey

25 Oct 2013, 11:45

I have two questions...

1.- Is it possible to define Autohotkey as Default Language in New Document. It's not possible to me.

Image

2.- Is it possible when I select Autohotkey language, notepad++ save a file ahk?

3.- How can I change the default theme?
In Style configurator It doesn't appear Autohotkey language...

Thanks in advance!
Everything is possible!
vahju
Posts: 29
Joined: 30 Sep 2013, 16:09

Re: Setup Notepad++ for AutoHotkey

27 Oct 2013, 22:35

Looks like the links are missing for the Download and preview buttons under Syntax highlighting in the first post.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Setup Notepad++ for AutoHotkey

28 Oct 2013, 01:33

All links in the first post work!
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
empardopo
Posts: 336
Joined: 06 Oct 2013, 12:50
Location: Spain
Contact:

Re: Setup Notepad++ for AutoHotkey

28 Oct 2013, 08:21

The links are OK.
Download it. Installed but I have problems I mention above.

I think that I'm going to check with Sublime. Thanks!
Everything is possible!
vahju
Posts: 29
Joined: 30 Sep 2013, 16:09

Re: Setup Notepad++ for AutoHotkey

28 Oct 2013, 22:29

jNizm sorry for the false alarm. After seeing your response I finally figured it out. Chalk this up to user error.
User avatar
wernerml
Posts: 5
Joined: 27 Nov 2013, 13:40
Location: Brazil

Re: Setup Notepad++ for AutoHotkey

27 Nov 2013, 13:58

first of all: really nice, thanks man!

but i'm having a little problem here... I use a theme (that came with NPP by default), it's: "Ruby Blue"

and it's merged with this AutoHotkey style...
http://img812.imageshack.us/img812/143/rq8x.png

I want to continue using this theme for all files, except .ahk files

maybe there's a way to do it.. but I don't know Notepad++ very much...
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Setup Notepad++ for AutoHotkey

28 Nov 2013, 09:35

try to change the bgColor="FFFFFF" to this ruby blue in userDefineLang_AHK.xml
bgColor = BackgroundColor

eg

Code: Select all

<WordsStyle name="KEYWORDS1" styleID="4" fgColor="0060FF" bgColor="FFFFFF" fontName="" fontStyle="0" nesting="0"/>
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
wernerml
Posts: 5
Joined: 27 Nov 2013, 13:40
Location: Brazil

Re: Setup Notepad++ for AutoHotkey

28 Nov 2013, 16:09

jNizM wrote:try to change the bgColor="FFFFFF" to this ruby blue
it stayed the same... I guess I've not explained myself too well:

the backgroud is "ruby blue" in autohotkey scripts... I want it to be "white??", I want your full style working...

but this "Ruby Blue Style" is overriding your style....

I guess it's more complicated...
User avatar
wernerml
Posts: 5
Joined: 27 Nov 2013, 13:40
Location: Brazil

Re: Setup Notepad++ for AutoHotkey

28 Nov 2013, 22:32

Ok, I've found an explanation, but I didn't understand if this is possible or not...
here: http://stackoverflow.com/questions/1157 ... -file-type

EDIT: Here: https://sourceforge.net/p/notepad-plus/ ... /bd2bc405/
but, again, didn't understand if they implemented this yet...

EDIT 2: OK, this is not possible after all...
explained here: https://sourceforge.net/p/notepad-plus/ ... d/0f0d47af
(on the last post)

:oops:
AHKxx
Posts: 73
Joined: 26 Feb 2014, 01:37

Re: Setup Notepad++ for AutoHotkey

26 Feb 2014, 02:47

Hey thanks. This is what I was hoping to find here. I've been using SciTE but would prefer to use NPP.

But I'm finding something odd. an ahk script that appears fine in SciTE, and that AHK loads without complaint, is showing up as an error in AHK. And it's a very simple thing too.

This...

^':: Send {LEFT 1}"{RIGHT 1}

...is causing everything to the right of the quote mark to display in red. If I put a semicolon immediately in front of the quote, everything is good.

Any idea why that might be? It's just a plain text quote mark, and again, AHK loads and runs it just fine: for example, here: "

Any insights would be appreciated.

Thanks!
RiseUp
Posts: 28
Joined: 01 Oct 2013, 21:27

Re: Setup Notepad++ for AutoHotkey

03 Mar 2014, 21:31

AHKxx wrote:This...

^':: Send {LEFT 1}"{RIGHT 1}

...is causing everything to the right of the quote mark to display in red. If I put a semicolon immediately in front of the quote, everything is good.

Any idea why that might be? It's just a plain text quote mark, and again, AHK loads and runs it just fine: for example, here: "

Any insights would be appreciated.

Thanks!
AHKxx,

Notepad++ is coloring everything after the double quotation mark (") red because it thinks that's all a string in your code. It only stops the red coloring after it encounters another double quotation mark which would normally signify the end of a string. For your particular case where the quotes are not there to mark a string, it's a bug in NP's AHK language setup, and unfortunately I do not know how to fix it.

However, I have a workaround that I use and maybe it will work for you. Change that line of code to:

Code: Select all

^':: Send {LEFT 1}"{RIGHT 1}  ;"
The second quotation mark will tell NP++ to stop coloring things red after it, and AHK will ignore it because it's commented out.

Hope that helps!
AHKxx
Posts: 73
Joined: 26 Feb 2014, 01:37

Re: Setup Notepad++ for AutoHotkey

07 Mar 2014, 00:30

RiseUp wrote:However, I have a workaround that I use and maybe it will work for you. Change that line of code to:

Code: Select all

^':: Send {LEFT 1}"{RIGHT 1}  ;"
The second quotation mark will tell NP++ to stop coloring things red after it, and AHK will ignore it because it's commented out.

Hope that helps!
Hey RiseUp.

Thanks much for your reply and the explanation... and the workaround! It worked like a charm! I will watch out for that in the future.
RiseUp
Posts: 28
Joined: 01 Oct 2013, 21:27

Re: Setup Notepad++ for AutoHotkey

19 Mar 2014, 18:25

AHKxx wrote: Hey RiseUp.

Thanks much for your reply and the explanation... and the workaround! It worked like a charm! I will watch out for that in the future.
You're welcome. :)
vangogh
Posts: 3
Joined: 16 May 2014, 06:05

Re: Setup Notepad++ for AutoHotkey

16 May 2014, 06:09

hi there,

Thanks for the scripts!

on a related note, i'd like to check if there's a black/dark theme that can be adapted directly for use? currently, the styling is pretty illegible under a dark background as seen below:

Image

i'm hoping for styling that's similar to SciTe4AHK:

Image

Thank you.!
alllala
Posts: 17
Joined: 03 Apr 2014, 05:04

Re: Setup Notepad++ for AutoHotkey

07 Aug 2014, 10:10

Does this work with NP++ 6.6.2?
Could not get it to work.

I´m still using NP++ 6.1.4 because I´m so used to the syntax Highlighting
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Setup Notepad++ for AutoHotkey

08 Aug 2014, 00:33

I use Notepad++ v6.6.8 and it works
Image
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
raron
Posts: 37
Joined: 11 Aug 2014, 00:50

Re: Setup Notepad++ for AutoHotkey

12 Aug 2014, 22:41

Using Notepad++ 6.6.7. Nice links from OP, but the "Function List" plugin don't seem to work, unfortunately.

Btw, attached is my dark themed AutoHotkey syntax highlighting atm. Bit of a mix from here and there and (tried to) fixed it up a bit now - OK, I might have gone a bit overboard with the colors maybe... (I like colors :) ) And it's not perfect, trouble with lines with a single percent sign in them for one.

Image

Also, using the font Consolas, obtainable from here: http://www.microsoft.com/en-us/download ... x?id=17879
I'm also liking the "Lucida Console", which I think I just had on my system (Win 7). Both monospaced.

I didn't set the font in the AHK syntax coloring file. Just set it in the menu Settings - Style configurator - Global styles - Default style - Font style (And no global overrides).


EDIT: Switched from Photobucket to imgur host for image.
Attachments
Notepad++ rarons AutoHotKey syntax highlighting.rar
WIP - my current AutoHotkey syntax highlight colors.
(3.19 KiB) Downloaded 4389 times
Last edited by raron on 05 Aug 2017, 21:42, edited 1 time in total.
User avatar
Congsinh
Posts: 3
Joined: 02 Sep 2014, 03:58

Re: Setup Notepad++ for AutoHotkey

02 Sep 2014, 12:15

It work, thank you!
@}-;-- Close your eyes and your will find ... The passage out of the dark
~~~: Ahk e.g | Cheat Age 3 | Cheat Plants vs Zombies 2
User avatar
berban
Posts: 97
Joined: 14 Apr 2014, 03:20

Make default ahk editor (via "edit" context menu in explorer

18 Oct 2014, 22:40

When SciTE4AutoHotkey installs, there's a prompt to ask if you want to set it as the default ahk editor. This means ahk files will open in SciTE instead of notepad when you right click > edit in windows explorer, or when you use the "Edit" command in ahk.

I changed the following keys in the registry to mimic this behavior. I'm not sure what the difference between the two is but I changed both for good measure.

Code: Select all

Computer\HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command
Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Classes\AutoHotkeyScript\Shell\Edit\Command
But do you know of any more user friendly way to accomplish this?

Also... I have been unable to get the autocomplete to work. It only completes words that have been previously entered. I followed the steps in the first post - AutoHotkey.xml is in the right dir, the autocomplete setting is checked. Any ideas? :S

Return to “Notepad++”

Who is online

Users browsing this forum: No registered users and 3 guests