avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 5, 2021, 11:24 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: MODx CMS helper: using favourite text editor instead of dirty textarea.  (Read 9792 times)


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 73
    • View Profile
    • @insert_nick
    • Donate to Member
MODx is a nice opensource CMS and PHP framework. A very annoying thing when using it is that you edit templates, code snippets, etc. in a small textarea. Of course it's really dirty, so I think everyone like me uses his favourite text editor, and paste into the textarea.

This process believe me is time-consuming and boring, you have to try it. So here it is what I'd like to have:

an AutoHotKey script which triggers when I press a hotkey: I press it when there is a textarea in the browser, in a MODx manager instance, and I want that the actions taken are:
  • copy the text found in the textarea into the clipboard
  • make a temporary file somewhere with .php extension
  • load this file into my favourite text editor (which will syntax-highlight the code because we've set the right extension for it)

Ok then I make my changes to the file, and when I'm done I press another hotkey, so that the actions taken by the script are:
  • save the file (Ctrl-S, or other user defined keystrokes, depending on the text editor... hey it's a script, so I can easily modify it by myself ;)
  • copy the text into the textarea in the browser, where the MODx manager instance is
  • optional, for the very lazy: submit the changes pressing the "save" button for me into the MODx manager interface :)

That's all, isn't it useful? The MODx community would rejoice... Btw it could be easily adapted to whatever CMS out there, if needed.
« Last Edit: August 30, 2006, 05:37 AM by insert_nick »


  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 1,133
    • View Profile
    • Donate to Member
If I understand you correctly, there's an AHK-script that does this on -> http://www.autohotke...viewtopic.php?t=2456

hope that helps

edit: the script would need a little modification to get php-highlighting, but that should be pretty easy (even for me ;) )


  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 73
    • View Profile
    • @insert_nick
    • Donate to Member
Woah, thanks, almost exactly what I wanted! Even if this is my first experience with AutoHotKey coding, I've successfully modified the script to my like. Here it is in case someone other can find it useful as I do:

;Edit contents of text boxes in favourite editor
;2/21/05 - savage -- modified 30/08/06 insert_nick

; Usage: Configure the following two paths with your preferred text-editor and temp file (if doesn't exist then it's created). If you have a cursor active into a textarea (e.g. in a browser window) you can press CTRL-ALT-C to load its content into the text editor; make your changes, and press CTRL-ALT-V to transfer the modified content back into the original textarea. The text editor is still open with the temp file loaded, so you can edit it again and again, committing changes into the original textarea by pressing CTRL-ALT-V from the editor (because it saves the document to make sure it is updated with edits).
; Summing up:
; CTRL-ALT-C to transfer a textarea content into the text editor
; CTRL-ALT-V to transfer the active document of the text editor into the original source textarea
; Make sure you adapt the script to let it work with your favourite text editor, e.g. the one considered here saves with CTRL-S, but maybe your one uses a different keyboard shortcut.

;put the path to your editor here, you may need to add some parameters if your editor needs any
editor = F:\path\to\favourite\text\editor.exe

;path to place the temp file - you'll probably want to change this. The extension doesn't matter, but it's useful if you know what type of files you're going to edit and your editor can syntax-highlight the code reading the extension
path = F:\tmp\textarea_temp.php

;Selects all text in the textarea, saves to temp file, runs editor on file
   SetKeyDelay, 1
   WinGetActiveTitle, wtitle
   temp = %clipboard%
   Send, ^a
   Send, ^c
   ;if the clipboard didn't change then the box was empty
   If clipboard = %temp%
       clipboard =
   ;In case it wasn't properly deleted
   FileDelete, %path%
   FileAppend, %clipboard%, %path%
   ;refill the clipboard so you can paste things in the editor
   clipboard = %temp%
   Run, %editor% "%path%"   

;Paste content of the temp file into the textarea
   ;save the clipboard again in case you copied anything in the editor
   temp = clipboard
   Send, ^s  ;(the text editor's save command)
   Sleep, 500
   FileRead, clipboard, %path%
   WinActivate, %wtitle%
   WinWaitActive, %wtitle%
   Send, ^a
   Send, ^v
   clipboard = %temp%

-- EDIT: I've now changed the hotkeys because before they interfered with Opera commands, and added a "Sleep, 500" to give the OS the time to complete writing the file.[/code]
« Last Edit: August 30, 2006, 11:41 AM by insert_nick »