AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Edit boxes in favorite editor

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Mon Feb 21, 2005 9:31 pm    Post subject: Edit boxes in favorite editor Reply with quote

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 Smile.

Code:

;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?
Back to top
View user's profile Send private message AIM Address
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Tue Feb 22, 2005 2:09 am    Post subject: Reply with quote

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.

Quote:
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%
Back to top
View user's profile Send private message Send e-mail
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Tue Feb 22, 2005 4:07 pm    Post subject: Reply with quote

Quote:

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


Hooray! Another showcase script for savage!


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

It happens for me with gvim.

Code:

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.
Back to top
View user's profile Send private message AIM Address
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Tue Feb 22, 2005 5:04 pm    Post subject: Reply with quote

Hey, someone noticed it! Laughing

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.
Back to top
View user's profile Send private message
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Wed Feb 23, 2005 6:05 pm    Post subject: Reply with quote

I'm always keen to avoid work, so I'll recycle your gui Smile.
Back to top
View user's profile Send private message AIM Address
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Wed Feb 23, 2005 6:54 pm    Post subject: Reply with quote

That's what it's there for. Wink
Back to top
View user's profile Send private message
Soapspoon



Joined: 23 Nov 2004
Posts: 8

PostPosted: Thu Mar 10, 2005 8:08 pm    Post subject: Reply with quote

This is very cool. I can even edit an Outlook email in vim if I want! Crazy stuff, thanks for sharing.
Back to top
View user's profile Send private message
Payam



Joined: 07 Apr 2004
Posts: 58

PostPosted: Fri Mar 11, 2005 11:16 am    Post subject: Reply with quote

Soapspoon wrote:
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
Back to top
View user's profile Send private message Send e-mail MSN Messenger
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Fri Mar 11, 2005 5:18 pm    Post subject: Reply with quote

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).
Back to top
View user's profile Send private message
Guest






PostPosted: Fri Mar 11, 2005 7:26 pm    Post subject: Reply with quote

jonny wrote:
for Windows, it's XEmacs

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

http://www.gnu.org/software/emacs/windows/ntemacs.html
Back to top
Guest






PostPosted: Fri Mar 11, 2005 7:34 pm    Post subject: Reply with quote

Payam wrote:
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. Smile
Back to top
savage



Joined: 02 Jul 2004
Posts: 206

PostPosted: Fri Mar 11, 2005 8:52 pm    Post subject: Reply with quote

@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 Smile.

Edit: Found it. My version is at the bottom. http://www.autohotkey.com/forum/viewtopic.php?t=1432
Back to top
View user's profile Send private message AIM Address
Atomhrt



Joined: 02 Sep 2004
Posts: 128
Location: Sunnyvale

PostPosted: Sun Jul 10, 2005 9:37 pm    Post subject: Reply with quote

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. Very Happy

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!
Back to top
View user's profile Send private message
UweHolst



Joined: 24 Jul 2005
Posts: 1

PostPosted: Tue Jul 26, 2005 7:21 pm    Post subject: Edit Boxes in favourite editor Reply with quote

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
Back to top
View user's profile Send private message Send e-mail AIM Address
urlwolf



Joined: 16 Mar 2006
Posts: 100

PostPosted: Thu Apr 20, 2006 1:14 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group