Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Can you run a script from within notepad++


  • Please log in to reply
9 replies to this topic
Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
I am using Textpad and I can type in some code and run it by pressing crtl 1
(had to change some settings in the registry)
can the same be done with Notepad ++ ?
"Choose your parents wisely"

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Go to menu Run, select Run, then select your AutoHotkey.exe.
Then press save and settings will pop up. Type for Name AutoHotkey and select your Hotkey here then press ok.

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009

Go to menu Run, select Run, then select your AutoHotkey.exe.
Then press save and settings will pop up. Type for Name AutoHotkey and select your Hotkey here then press ok.

I did this but nothing happened
maybe i didnt explain well
In Textpad I have a script open I am working on
I save it then press CTRL and 1 and the script runs, or doesnt if there is a fault.
I have done as you suggested, now I have a scipt open and saved but I press Ctrl Shift 1 and nothing happens the script is not run
"Choose your parents wisely"

HotKeyIt
  • Moderators
  • 7439 posts
  • Last active: Jun 22 2016 09:14 PM
  • Joined: 18 Jun 2008
Did you select Ctrl + 1 as your hotkey on save page?

Chicken Pie 4 Tea
  • Members
  • 379 posts
  • Last active: Dec 12 2014 06:46 PM
  • Joined: 18 Aug 2009
Sure, I have tried it 3 times with different hotkeys now! It must be because I have notepad++ as portable (but still on pc hard disk)

I found a post by Vixay and it worked:
You can also use nppexec plugin
Plugins>NPPexec>Execute..

Put in this:
C:\Program Files\AutoHotkey\autohotkey.exe "$(FULL_CURRENT_PATH)"

and save as a new script titled AHK.... then you can use F6 to launch...

No editing of .xml files required!

I've been using this and it works well.
"Choose your parents wisely"

maul.esel
  • Guests
  • Last active:
  • Joined: --
There's also a little plugin for Notepad++:
RunMe
It offers a button in the toolbar to run the current file. You can also automatically save your file before running it.

CodeKiller
  • Members
  • 2067 posts
  • Last active: Feb 26 2016 09:30 AM
  • Joined: 10 Jul 2008

There's also a little plugin for Notepad++:
RunMe
It offers a button in the toolbar to run the current file. You can also automatically save your file before running it.


This plugin only work in ANSI mode... Useless...

maul.esel
  • Guests
  • Last active:
  • Joined: --
wrong, there's a Unicode version too :!:
Look at the link, scroll down to RunMe. It says

RunMe (ANSI / Unicode)

:D

To 404 is Human
  • Members
  • 1 posts
  • Last active: Dec 13 2014 07:01 AM
  • Joined: 17 Sep 2014

I found a post by Vixay and it worked:
You can also use nppexec plugin
Plugins>NPPexec>Execute..

Put in this:
C:\Program Files\AutoHotkey\autohotkey.exe "$(FULL_CURRENT_PATH)"

and save as a new script titled AHK.... then you can use F6 to launch...


The following is even simpler (no plugin needed) if you can already run AHK scripts from Explorer. And it's generic, so it'll work with other types of scripts (batch files, webpages, etc.):
  • Go to menu Run > Run...
  • Put in "$(FULL_CURRENT_PATH)"
  • Either click Run to launch it now or Save it and associate it to a hotkey shortcut to reuse later.
If you can't run AHK scripts from Explorer or you want your shortcut to only run AHK scripts, put "C:\Program Files\AutoHotkey\AutoHotkey.exe" "$(FULL_CURRENT_PATH)" into the Run dialog box, with those quotes around both parts. Also, you may have to replace "Program Files" with "Program Files (x86)", depending where AutoHotkey.exe is, on your system. HotKeyIt's post was almost there but the second part of the command was left out. More help from Commands section of Notepad++'s help.

dallasw1983
  • Members
  • 1 posts
  • Last active: Feb 21 2015 04:08 PM
  • Joined: 17 Feb 2015

If you wanted to add a context menu ( when you right click ) to have a mouse click option, I've created a script that helps out. This should give anyone a good idea on how to work with notepad and ahk. I'm sure this could be improved, but it works fantastic for my use.

 

 

this is my script

 

; var 1 is the argument from the Run command

#NoTrayIcon
blockinput,on
SendInput ^s
Sleep 100
blockinput,off
IfWinActive,Save As
    {
    Msgbox,16,Notice,You have to save the file first. Then rerun the short cut.
    exitapp
    }
Sleep 20
ifexist,%1%
    {
    ifinstring,1,.ahk
     run,AutoHotkey.exe /f "%1%"
    else
     run, %1%
    }
exitapp

;Menu -> Run -> Run...
;Enter the run command and chose "Save..."
;Save the command as Run Current
;Save this script at (Inside Notepadd++ Directory)\customs\run_current.ahk
;Edit the context menu to add the right click function
;Restart Notepad++
;Note: If Notepad++ doesn't start, then the Syntax of contextMenu.xml is incorrect

;run command
;AutoHotkey.exe /f "$(NPP_DIRECTORY)\customs\run_current.ahk" "$(FULL_CURRENT_PATH)"

;ahk file path
;(Inside Notepadd++ Directory)\customs\run_current.ahk

;context menu location (Windows XP)
;C:\Documents and Settings\<username>\Application Data\Notepad++\contextMenu.xml
;add line
;<Item MenuEntryName="Run" MenuItemName="Run Current"/>