AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Notepad++

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Zer07even



Joined: 01 Aug 2008
Posts: 10
Location: South Africa

PostPosted: Fri Aug 01, 2008 7:56 am    Post subject: Notepad++ Reply with quote

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
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1145
Location: The Interwebs

PostPosted: Fri Aug 01, 2008 8:03 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
Guest






PostPosted: Fri Aug 01, 2008 10:19 am    Post subject: Re: Notepad++ Reply with quote

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. Wink
Back to top
Zer07even



Joined: 01 Aug 2008
Posts: 10
Location: South Africa

PostPosted: Fri Aug 01, 2008 11:50 am    Post subject: Reply with quote

Thanks guys, I tried looking in notepad++ but found nothing... not to concerned though since I have my script.
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Aug 01, 2008 11:51 am    Post subject: Re: Notepad++ Reply with quote

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 &quot;$(FULL_CURRENT_PATH)&quot;</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 &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</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 &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</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 &quot;$(FULL_CURRENT_PATH)&quot;</Command>
    </UserDefinedCommands>
    <PluginCommands />
    <ScintillaKeys />
</NotepadPlus>
Result looks like this:
Back to top
tidbit



Joined: 09 Mar 2008
Posts: 187

PostPosted: Fri Aug 01, 2008 8:33 pm    Post subject: Reply with quote

sorry for stealing the thread Razz

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 &quot;$(FULL_CURRENT_PATH)&quot;</Command>
        <Command name="launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;$(FULL_CURRENT_PATH)&quot;</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 &quot;$(FULL_CURRENT_PATH)&quot;</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
View user's profile Send private message
vixay



Joined: 12 Jun 2008
Posts: 23

PostPosted: Wed Aug 06, 2008 7:57 am    Post subject: NPPExec Reply with quote

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! Smile

I've been using this and it works well.
Back to top
View user's profile Send private message
Zer07even



Joined: 01 Aug 2008
Posts: 10
Location: South Africa

PostPosted: Wed Aug 06, 2008 10:14 am    Post subject: Reply with quote

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
View user's profile Send private message
scottmattes



Joined: 21 May 2007
Posts: 98
Location: USA

PostPosted: Wed Aug 06, 2008 12:46 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
scottmattes



Joined: 21 May 2007
Posts: 98
Location: USA

PostPosted: Wed Aug 06, 2008 2:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Red Hat Dude
Guest





PostPosted: Wed Aug 06, 2008 9:33 pm    Post subject: Reply with quote

Thanks, Scott...that's pretty cool! Very Happy
Back to top
Serenity



Joined: 07 Nov 2004
Posts: 1276

PostPosted: Sat Aug 23, 2008 12:11 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group