AutoHotkey Community

It is currently May 26th, 2012, 10:25 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Notepad++
PostPosted: August 1st, 2008, 8:56 am 
Offline

Joined: August 1st, 2008, 8:50 am
Posts: 19
Location: South Africa
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 1st, 2008, 9:03 am 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Notepad++
PostPosted: August 1st, 2008, 11:19 am 
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. ;)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 1st, 2008, 12:50 pm 
Offline

Joined: August 1st, 2008, 8:50 am
Posts: 19
Location: South Africa
Thanks guys, I tried looking in notepad++ but found nothing... not to concerned though since I have my script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: Notepad++
PostPosted: August 1st, 2008, 12:51 pm 
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: Image


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 1st, 2008, 9:33 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
sorry for stealing the thread :P

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 afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject: NPPExec
PostPosted: August 6th, 2008, 8:57 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 11:14 am 
Offline

Joined: August 1st, 2008, 8:50 am
Posts: 19
Location: South Africa
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 1:46 pm 
Offline

Joined: May 21st, 2007, 3:44 pm
Posts: 176
Location: USA
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
Image
My small, and slowly growing, collection of scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 3:31 pm 
Offline

Joined: May 21st, 2007, 3:44 pm
Posts: 176
Location: USA
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
Image
My small, and slowly growing, collection of scripts.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 6th, 2008, 10:33 pm 
Thanks, Scott...that's pretty cool! :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 23rd, 2008, 1:11 pm 
Offline

Joined: November 8th, 2004, 12:46 am
Posts: 1271
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
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2009, 7:01 am 
Offline

Joined: February 20th, 2007, 1:37 pm
Posts: 198
Location: D.C.
Cheers for Scott's and Vixay's methods, which are both easy and effective for me. I now have "run current script" mapped to the same keys in both TextPad and NPP. Maybe when NPP grows up a little more it will take the place of TextPad in my life but until then it's the only competitor. I love NPP!


Report this post
Top
 Profile  
Reply with quote  
 Post subject: question
PostPosted: February 11th, 2011, 12:51 pm 
hi every body

I have a question. I have some codes that developed by fortran. I want to trace them by notepad++. is it possible? what's shortcut?

regards


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2011, 5:48 am 
Offline

Joined: March 10th, 2011, 7:17 pm
Posts: 374
when i try to use n++ Run command, it wont work if there is an include file

Code:
#include ./lib/LowLevel.ahk


i get an ahk error "include file could not be opened"

obv the script works fine if double clicked in explorer :(


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 7 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group