AutoHotkey Community

It is currently May 27th, 2012, 10:31 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: February 21st, 2005, 9:31 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
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 :).

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?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2005, 2:09 am 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
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%


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2005, 4:07 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 22nd, 2005, 5:04 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 6:05 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
I'm always keen to avoid work, so I'll recycle your gui :).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 23rd, 2005, 6:54 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
That's what it's there for. :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 10th, 2005, 8:08 pm 
Offline

Joined: November 23rd, 2004, 5:54 pm
Posts: 8
This is very cool. I can even edit an Outlook email in vim if I want! Crazy stuff, thanks for sharing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 11:16 am 
Offline

Joined: April 7th, 2004, 2:43 pm
Posts: 62
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 5:18 pm 
Offline

Joined: November 13th, 2004, 4:08 am
Posts: 2951
Location: Minnesota
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).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 7:26 pm 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 7:34 pm 
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. :)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2005, 8:52 pm 
Offline

Joined: July 2nd, 2004, 11:53 pm
Posts: 207
@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.autohotkey.com/forum/viewtopic.php?t=1432


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 10th, 2005, 9:37 pm 
Offline

Joined: September 2nd, 2004, 1:08 am
Posts: 124
Location: Sunnyvale
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!


Report this post
Top
 Profile  
Reply with quote  
PostPosted: July 26th, 2005, 7:21 pm 
Offline

Joined: July 24th, 2005, 6:31 pm
Posts: 1
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 20th, 2006, 1:14 am 
Offline

Joined: March 16th, 2006, 5:01 pm
Posts: 150
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: specter333 and 12 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group