Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Edit boxes in favorite editor


  • Please log in to reply
14 replies to this topic
savage
  • Members
  • 207 posts
  • Last active: Jul 03 2008 03:12 AM
  • Joined: 02 Jul 2004
I remember reading in some "this is my sexy desktop" thread on some linux forum about a guy who had something set up where he could edit things like forum posts, emails, etc. in vim. I thought that might be nice to have, so I whipped it up in ahk. You can easily configure it to work with any editor. The point is to have better editing control when typing long things into limited text boxes. I'm writing this post using this script :).

;Edit.AHK
;Edit contents of text boxes in favorite editor
;2/21/05 - savage

;put the path to your editor here, you may need to add some parameters if your editor needs any
editor = C:\command\vim\vim63\gvim.exe

;path to place the temp file - you'll probably want to change this
path = C:\temp.txt

;win-alt-e
;Selects all text, saves to temp file, runs editor on file, waits to exit, paste
#!E::
	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%
	RunWait, %editor% "%path%"
	;and save the clipboard again in case you copied anything in the editor
	temp = clipboard
	FileRead, clipboard, %path%
	FileDelete, %path%
	WinActivate, %wtitle%
	WinWaitActive, %wtitle%
	Send, ^a
	Send, ^v
	clipboard = %temp%
return


The one problem is that the editor window keeps coming up behind the window that you were in. Any suggestions on how to fix this?

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Sweet script; I'm using it now. It could definitely help prevent loss of data when something goes awry during a post (dropped connection, power outage, etc.) -- not to mention being much nicer and easier to edit text with your favorite editor.

Because it's so simple and useful, this script probably belongs in the Script Showcase.

the editor window keeps coming up behind the window that you were in. Any suggestions on how to fix this?

Perhaps it's editor-specific because it doesn't happen with Metapad. The next release of AutoHotkey (tomorrow hopefully) will have a method to access windows by their pid, in which case the following will probably fix it:

Run, %editor% "%path%",,, EditorPID
WinActivate, ahk_pid %EditorPID%
Process, WaitClose, %EditorPID%

savage
  • Members
  • 207 posts
  • Last active: Jul 03 2008 03:12 AM
  • Joined: 02 Jul 2004

Because it's so simple and useful, this script probably belongs in the Script Showcase.


Hooray! Another showcase script for savage!


Perhaps it's editor-specific because it doesn't happen with Metapad.

It happens for me with gvim.

The next release of AutoHotkey (tomorrow hopefully) will have a method to access windows by their pid

I was digging for that kind of functionality, but I guess I'll just wait then.

I've got another script in the works based on jonny's cmd.ahk, it will be for filtering the clipboard through pipelines - I guess you'd need unixutils or somesuch for it to be much use.

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Hey, someone noticed it! :lol:

More often then not, my "junk scripts" just pass through the system. It's nice to actually see one of them pop up later on.

savage
  • Members
  • 207 posts
  • Last active: Jul 03 2008 03:12 AM
  • Joined: 02 Jul 2004
I'm always keen to avoid work, so I'll recycle your gui :).

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
That's what it's there for. :wink:

Soapspoon
  • Members
  • 8 posts
  • Last active: Jan 19 2006 07:18 PM
  • Joined: 23 Nov 2004
This is very cool. I can even edit an Outlook email in vim if I want! Crazy stuff, thanks for sharing.

Jimmy2Times
  • Members
  • 65 posts
  • Last active: Jul 15 2014 07:56 PM
  • Joined: 07 Apr 2004

This is very cool. I can even edit an Outlook email in vim if I want! Crazy stuff, thanks for sharing.


While I've never actually used vim (www.vim.org), I can't imagine why it would be better to edit an email for example in vim rather than outlook itselft.

Could you maybe shed some light ? Thanks

jonny
  • Members
  • 2951 posts
  • Last active: Feb 24 2008 04:22 AM
  • Joined: 13 Nov 2004
Vim is not like other editors. It has entirely different concepts driving it. Most people I know who've used it love it and usually prefer it to WYSIWYG editors (any normal edit control in windows is a WYSIWYG). One of the things that makes it so unique is it's key bindings. Rather than relying on tricky, counter-intuitive hotkeys, each regular key does something in the editor. A few of the keys take you to an input method where you actually type. Personally, I prefer Emacs, which is similar, but only in that it differs completely from other editors. (for Windows, it's XEmacs) Anyway, it's your choice; generally, Linux users are more attracted to these editors than Windows users, being that they were originally console-based (they still feel more familiar in the console).

  • Guests
  • Last active:
  • Joined: --

for Windows, it's XEmacs

Just to be precise both emacsen run on Windows, not just XEmacs:

http://www.gnu.org/s...ws/ntemacs.html

  • Guests
  • Last active:
  • Joined: --

While I've never actually used vim (www.vim.org), I can't imagine why it would be better to edit an email for example in vim rather than outlook itselft.

Could you maybe shed some light ? Thanks


Have you ever copied some text from a webpage in order to send it to someone else and without the html formatting the lines were broken and stuff? Having emacs or vim at hand when a text needs be reformatted (indenting, joining lines, filling paragraphs, etc.) gives one the same power in Outlook as when editing a text directly with these editors.

And if one knows any of these editors he also knows that when I say power I mean power. :)

savage
  • Members
  • 207 posts
  • Last active: Jul 03 2008 03:12 AM
  • Joined: 02 Jul 2004
@soappoon, did you see my script that lets you use basic vim keys anywhere in windows? It's still a little dodgy, but pretty sweet. When I'm using Visual Studio it lets me use my :w save reflexes, rather than remembering to use ^s :).

Edit: Found it. My version is at the bottom. http://www.autohotke...opic.php?t=1432

Atomhrt
  • Members
  • 124 posts
  • Last active: Nov 13 2006 09:18 PM
  • Joined: 02 Sep 2004
savage, this is pretty cool! I've found another handy use for your script. I've been looking for something to do spell checking in Miranda chat windows. With two minor changes to your script it can be used with Aspell. This opens up a few clients for me to use because I needed a spell checker. I tested this with Exodus as well.

In fact, I'm using the same script to spell check this post.

Here is what I did.
1) Changed the editor to point to aspell.exe.
2) Changed the Runwait statement to this: RunWait, %editor% -c "%path%"

Basically, I think this script will work with just about any chat client. :D

I am a happy camper... Thx.

Note: nConvers has a problem with ctrl-a and this looks to be an nConvers bug. I instead used the standard SRMM plugin. (Yes, I know that nConvers has spell checking, but it does not work with Office 2003).
I am he of whom he speaks!

UweHolst
  • Members
  • 1 posts
  • Last active: Jul 26 2005 06:21 PM
  • Joined: 24 Jul 2005
Hi,

thank you. I do have to make software tests with Rational Robot. A great tool for testing with very poor editing posibilities. With your script i can use my beloved UltraEdit and have the SQA scripts ready in a very comfortable way.

Uwe

urlwolf
  • Members
  • 150 posts
  • Last active: Feb 26 2012 07:56 PM
  • Joined: 16 Mar 2006
Savage,

Thanks for a great script. I had the same idea, but 2 years later and my
implementation didn't really work. Glad I was pointed to your script.