Emerald Editor Discussion
July 24, 2017, 03:38:36 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Compile Key Support (script included)  (Read 3727 times)
0 Members and 1 Guest are viewing this topic.
DDR
Prospector
*
Posts: 1


« on: December 28, 2010, 10:17:52 am »

Hello, there. I've been using Crimson Editor on-and-off for a few years, after I lost my copy of Notetab Pro. One thing which has been bothering me lately is that I can't seem to assign a command to run when I press a key. Well. If that just isn't what the autohotkey scripting utility is for! I've written a script which runs a program with the current tab's file as the target. You can press f1 to access a bit of help.

Steps:
1) Install autohotkey.
2) Save the below code as quick-compile.ahk. It must have the .ahk extension.
3) Double-click the file in windows explorer. Now, it's running.
4) Press f9 with Crimson Editor open. It attempts to run the script as a python program, using the default python install location.

Code:
; A script to allow fast running of Starcube, when editing the source.
; F9 - Run script listed.
; Shift-F9 - quit().
; f10 - Run script and immeadiatly quit.
; (gpl) 2010, David D. Roberts (DDR)

;F1 - splashscreen

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir C:\Documents and Settings\David\My Documents\Python\Starcube b0\  ; Ensures a consistent starting directory.

;path = C:\Panda3D-1.7.0\samples\Ball-in-Maze\Tut-Ball-in-Maze.py

+F9::
Send quit(){enter}
Return

#IfWinActive Crimson Editor

F1::
SplashImage, C:\Documents and Settings\David\My Documents\My Pictures\3d pointer.JPG, w385 h460 , Released under same license as Starcube. Contact: robertsdavidddr@gmail.com, Quick-Compile - A quick compiling hotkey for Starcube. F9: Run persistant. Shift-F9: send quit(). F10: Run normal. Esc: Close this., Quick-Compile
KeyWait, Esc, D T10
SplashImage, OFF
Return

F9:: ;Save and run script.
Send, {CTRLDOWN}s{CTRLUP}
WinGetActiveTitle, Title
Title := RegExReplace(Title, "]$", "") 
Title := SubStr(Title, 19)
Run C:\Python26\python.exe -i "%Title%"
Return

F10::
Send, {CTRLDOWN}s{CTRLUP}

WinGetActiveTitle, Title
Title := RegExReplace(Title, "]$", "") 
Title := SubStr(Title, 19)
Run C:\Python26\python.exe "%Title%"
Return
To change the python executable location, change "C:\Python26\python.exe" to the python executable of your choice. Example: I'm currently using the Panda3D version of Python, so I'd replace that string with "C:\Panda3D-1.7.0\python\python.exe" to have the script use that. I imagine it's fairly simple to change the script to use another language, too. Just replace the .exe with the program of your choice. Remember, %Title% is the title of the currently open document in Crimson Editor.

Sorry for the wall of text, the forum required an odd and long password - basically, I'm not coming back. I'll watch, though, and send myself a reset email if necessary. Wink

All the best, and happy one-key compiling.
 --DDR
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.233 seconds with 18 queries.