| View previous topic :: View next topic |
| Author |
Message |
Zer07even
Joined: 01 Aug 2008 Posts: 10 Location: South Africa
|
Posted: Fri Aug 01, 2008 7:56 am Post subject: Notepad++ |
|
|
Hi All. I was reading the forums yesterday when I saw that somebody(cant remember who) was complaining about not being able to run their code from inside notepad++ so it got me thinking....
| Code: | F5::
{
SetTitleMatchMode , 2
ifWinActive , - Notepad++
{
SendPlay , ^S
WinGetActiveTitle , Title
StringTrimRight, Script, Title, 12
Run , C:\Program Files\AutoHotkey\AutoHotkey.exe "%Script%"
}
else
{
Suspend , On
Send, {F5}
Suspend , Off
}
}
Return |
let me know what you think.. it works well enough for me.
Chris |
|
| Back to top |
|
 |
Krogdor
Joined: 18 Apr 2008 Posts: 1145 Location: The Interwebs
|
Posted: Fri Aug 01, 2008 8:03 am Post subject: |
|
|
Could be shortened to:
| Code: | $F5::
{
SetTitleMatchMode , 2
ifWinActive , - Notepad++
{
SendPlay , ^S
WinGetActiveTitle , Title
StringTrimRight, Script, Title, 12
Run , C:\Program Files\AutoHotkey\AutoHotkey.exe "%Script%"
}
else
Send, {F5}
}
Return |
|
|
| Back to top |
|
 |
Guest
|
Posted: Fri Aug 01, 2008 10:19 am Post subject: Re: Notepad++ |
|
|
| Zer07even wrote: | Hi All. I was reading the forums yesterday when I saw that somebody(cant remember who) was complaining about not being able to run their code from inside notepad++ so it got me thinking....
|
No script is needed at all to run a script from NotePad++. Just dig though the NopePad++ documentation. I have a (Notepad++) hotkey defined to run the current file as an AHK script.
I don't recall how I set it up, but Autohotkey is in the 'RUN' menu and the defined hotkey is listed.
As I said, Just dig though the NopePad++ documentation.  |
|
| Back to top |
|
 |
Zer07even
Joined: 01 Aug 2008 Posts: 10 Location: South Africa
|
Posted: Fri Aug 01, 2008 11:50 am Post subject: |
|
|
| Thanks guys, I tried looking in notepad++ but found nothing... not to concerned though since I have my script. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri Aug 01, 2008 11:51 am Post subject: Re: Notepad++ |
|
|
| I wrote: | | I don't recall how I set it up, but Autohotkey is in the 'RUN' menu and the defined hotkey is listed. |
Now I remember. Edit the Notepad++ config file shortcuts.xml. Add a line similar to this: | Code: | | <Command name="Autohotkey" Ctrl="yes" Alt="no" Shift="yes" Key="65">C:\PROGRA~1\UTILS\AUTOHO~1\AUTOHO~1.EXE "$(FULL_CURRENT_PATH)"</Command> | in the <UserDefinedCommands> section (replace path as it is on your system).
Before: | Code: | <NotepadPlus>
<InternalCommands />
<Macros>
<Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
<Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
</Macro>
</Macros>
<UserDefinedCommands>
<Command name="launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox "$(FULL_CURRENT_PATH)"</Command>
<Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore "$(FULL_CURRENT_PATH)"</Command>
<Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/%20$(CURRENT_WORD)</Command>
<Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">http://www.google.com/search?q=$(CURRENT_WORD)</Command>
<Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">http://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
<Command name="open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
<Command name="open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -multiInst</Command>
</UserDefinedCommands>
<PluginCommands />
<ScintillaKeys />
</NotepadPlus> | After: | Code: | <NotepadPlus>
<InternalCommands />
<Macros>
<Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
<Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
</Macro>
</Macros>
<UserDefinedCommands>
<Command name="launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox "$(FULL_CURRENT_PATH)"</Command>
<Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore "$(FULL_CURRENT_PATH)"</Command>
<Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/%20$(CURRENT_WORD)</Command>
<Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">http://www.google.com/search?q=$(CURRENT_WORD)</Command>
<Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">http://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
<Command name="open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
<Command name="open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -multiInst</Command>
<Command name="Autohotkey" Ctrl="yes" Alt="no" Shift="yes" Key="65">C:\PROGRA~1\UTILS\AUTOHO~1\AUTOHO~1.EXE "$(FULL_CURRENT_PATH)"</Command>
</UserDefinedCommands>
<PluginCommands />
<ScintillaKeys />
</NotepadPlus>
| Result looks like this:  |
|
| Back to top |
|
 |
tidbit
Joined: 09 Mar 2008 Posts: 187
|
Posted: Fri Aug 01, 2008 8:33 pm Post subject: |
|
|
sorry for stealing the thread
| Code: | <NotepadPlus>
<InternalCommands />
<Macros>
<Macro name="Trim Trailing and save" Ctrl="no" Alt="yes" Shift="yes" Key="83">
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="1" message="2170" wParam="0" lParam="0" sParam=" " />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="0" message="2327" wParam="0" lParam="0" sParam="" />
<Action type="2" message="0" wParam="42024" lParam="0" sParam="" />
<Action type="2" message="0" wParam="41006" lParam="0" sParam="" />
</Macro>
</Macros>
<UserDefinedCommands>
<Command name="launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox "$(FULL_CURRENT_PATH)"</Command>
<Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore "$(FULL_CURRENT_PATH)"</Command>
<Command name="Get php help" Ctrl="no" Alt="yes" Shift="no" Key="112">http://www.php.net/%20$(CURRENT_WORD)</Command>
<Command name="Google Search" Ctrl="no" Alt="yes" Shift="no" Key="113">http://www.google.com/search?q=$(CURRENT_WORD)</Command>
<Command name="Wikipedia Search" Ctrl="no" Alt="yes" Shift="no" Key="114">http://en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)</Command>
<Command name="open file" Ctrl="no" Alt="yes" Shift="no" Key="116">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)</Command>
<Command name="open in another instance" Ctrl="no" Alt="yes" Shift="no" Key="117">$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD) -multiInst</Command>
<Command name="Autohotkey" Ctrl="yes" Alt="no" Shift="yes" Key="65">C:\Program Files\AutoHotkey\autohotkey.exe "$(FULL_CURRENT_PATH)"</Command>
</UserDefinedCommands>
<PluginCommands />
<ScintillaKeys />
</NotepadPlus> |
doesn't work.
it seems NP++ isn't detecting the "save", or is not "refreshing"...
I even restarted my computer. renames two of them, and they didn't change either. adding " " didn't work either.
if I edit the "Application Data\Notepad++" and save, well it doesn't save. even though it isn't "hidden" or "read only"......
GOT IT. it seems to work if I edit using notepad, not notepad++ :/ _________________ rawr. be very affraid
Note: My name is all lowercase for a reason. |
|
| Back to top |
|
 |
vixay
Joined: 12 Jun 2008 Posts: 23
|
Posted: Wed Aug 06, 2008 7:57 am Post subject: NPPExec |
|
|
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. |
|
| Back to top |
|
 |
Zer07even
Joined: 01 Aug 2008 Posts: 10 Location: South Africa
|
Posted: Wed Aug 06, 2008 10:14 am Post subject: |
|
|
| Thanks for all of the replies guys! All valid but I like my ahk method.. I try to keep as much as possible in ahk.... even when I know I cant do something with it i still try figure out a way or in certain cases come check it out here! |
|
| Back to top |
|
 |
scottmattes
Joined: 21 May 2007 Posts: 98 Location: USA
|
Posted: Wed Aug 06, 2008 12:46 pm Post subject: |
|
|
The correct way (the way provided by NPP) is
F5
type in your command (like "$(FULL_CURRENT_PATH)")
then click the Save... button
give the command a name (like Run this AHK script)
click OK _________________ -------------
Scott Mattes
My small, but growing, collection of scripts. |
|
| Back to top |
|
 |
scottmattes
Joined: 21 May 2007 Posts: 98 Location: USA
|
Posted: Wed Aug 06, 2008 2:31 pm Post subject: |
|
|
To remove a Run menu item you do Settings / Shortcut Mapper, right click on the one you want to work with and choose either Modify or Delete. _________________ -------------
Scott Mattes
My small, but growing, collection of scripts. |
|
| Back to top |
|
 |
Red Hat Dude Guest
|
Posted: Wed Aug 06, 2008 9:33 pm Post subject: |
|
|
Thanks, Scott...that's pretty cool!  |
|
| Back to top |
|
 |
Serenity
Joined: 07 Nov 2004 Posts: 1276
|
Posted: Sat Aug 23, 2008 12:11 pm Post subject: |
|
|
| tidbit wrote: | | it seems NP++ isn't detecting the "save", or is not "refreshing"... |
Notepad++ overwrites the shortcuts.xml file when it closes. It's a shame you can't edit the config files natively, I liked that about SciTE and would prefer this to using the dialogs. I added this script to the Run menu as a workaround:
| Code: | ; add this to shortcuts.xml:
; <Command name="Edit shortcuts.xml" Ctrl="no" Alt="no" Shift="no" Key="0">$(NPP_DIRECTORY)\shortcuts.ahk $(NPP_DIRECTORY)</Command>
#singleinstance force
#notrayicon
winclose, ahk_class Notepad++
process, waitclose, notepad++.exe
runwait, notepad "%1%\shortcuts.xml"
run, %1%\notepad++.exe
return |
| vixay wrote: | You can also use nppexec plugin
Plugins>NPPexec>Execute.. |
The downside is you can only run one script at a time this way. :( _________________ "Anything worth doing is worth doing slowly." - Mae West
 |
|
| Back to top |
|
 |
|