Tuesday, March 20, 2012

Cool Script(s)

Don't know how many people who read this (people actually read this?!?) use Notepad++ extensively, but here is a really neat way to link NPP with whatever compiler or software you're using:


If you're using NPP to code for gnuplot as well, add the following lines to the appropriate sections of the specified files (mentioned in the readme(s) you get with the Autoit scripts from the link above).

In case anybody gets confused:
= !!! = You edit the .ini file, but link the Notepad++ shortcut to the .exe file = !!! =

Here's the send key list, if you need it:
http://www.autoitscript.com/autoit3/docs/appendix/SendKeys.htm

For RunScript.ini (this goes under the Extensions block):
plt = gnuplot

 

; this goes right at the bottom, just above the ; End of INI file line
[gnuplot]
path = "C:\Program Files\gnuplot\binary\wgnuplot.exe"
wintitle = "gnuplot"
command = "load '%%scriptname%%' {Enter}"


















Also remember to edit the paths to all of the other software you intend to use.The easiest way to find the path is to look at it from the shortcuts you already have. For instance:

Right click on the shortcut and select Properties:


It's here: 

 


That goes under the path = "C:\.....\whatever.exe" line.
And here's where you find wintitle - Open the programme:

 


However, "RGui" seems to work best - whether you're on 64 or 32 bit. So leave the original as it is.
When you're done editing the .ini file, hit F5.

Also note: because AutoIt uses the window name to figure out where to send your scripts, it might make mistakes if different similar window names are available. I have had this send scripts to FireFox because I was looking at a gnuplot website (the window name was "gnuplot ...") while trying to send the script to the gnuplot interface. 

You should get this: 




As mentioned above, we edit the .ini file, but link the shortcut to the .exe file, followed by "$(FULL_CURRENT_PATH)“

The .exe file is in the same directory as the .ini, and has the same name. Since we can see the path to the .ini file here, we will enter

D:\RunAnything\RunScript\RunScript.exe "$(FULL_CURRENT_PATH)"
into the box.

Click Save.

Give the command a name, and map it to the keyboard shortcut of your heart's desire (drop menu). In this case, I'm calling it RunScript, and it will be called by pressing F10.




Click OK. It will take you back to this:


Close everything. You're done.

One more time, people?

For RunLines.ini (same as above):

plt = gnuplot


[gnuplot]
path = "C:\Program Files\gnuplot\binary\wgnuplot.exe"
wintitle = "gnuplot"
run_script_command = "load '%%scriptname%%' {Enter}"
single_line_command = "^a ^c +{INS} {Enter}"


“^a ^c +{INS} {Enter}” sends the following key strokes:

Ctrl+A
Ctrl+C
Shift+Insert
Enter

Given the location of my .exe file:

in Notepad++, press F5:

Enter the path to the .exe file followed by a space, then "$(EXT_PART)". 



Hit Save.

You should get a box that looks like this:


Give the command a name, and map it to the keyboard shortcut of your heart's desire (drop menu). In this case, I'm calling it RunLines, and mapping it to F9.



When you're done, hit OK. It'll take you back to this:



Just close the window, and the window with the .ini file.

NOTE: You gotta edit the file paths as necessary. I didn't install HelpFromWeb or NppExecute. If you need the AutoIt compiler, you can get it here. Works on Windows only. 

And now you all know what my desktop looks like.