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 

Texter - Text replacement tool with GUI

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





PostPosted: Sat Mar 03, 2007 12:14 am    Post subject: Texter - Text replacement tool with GUI Reply with quote

Using Skrommel's AutoClip as a starting point, I put together a text replacement application called Texter. You can check it out here:

http://lifehacker.com/software/texter/lifehacker-code-texter-windows-238306.php

Here's the source:

http://lifehacker.com/assets/resources/2007/02/texter.ahk

I'd love feedback, and there are a lot of bugs that probably need fixing if anyone has any suggestions.

Thanks!
Back to top
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 301
Location: US

PostPosted: Sat Mar 03, 2007 4:29 am    Post subject: Reply with quote

I haven't tried it out, but it looks good, I really like all the effort you put into showing people how to use it and what it's uses are. I wish I were that determined for www.freewebtown.com/elevator_hazard but oh well.

Um could possibly use the Control, EditPaste command instead of Send because if someone wanted to do maybe #5 blah blah blah to send, it would send Win+5 and some other stuff, but maybe it won't... Test it with things like + and # and ^. To use editpaste, just look it up in the helpfile, you will need to use something to get the current window's focus when replacing though.
_________________
Changed siggy at request of ahklerner Very Happy
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10692

PostPosted: Sat Mar 03, 2007 1:17 pm    Post subject: Reply with quote

Your presentation is great, especially the videos.

I notice you're using the Input command to implement your own hotstring/replacement engine. Perhaps one of your reasons for doing so is AutoHotkey's inability to dynamically create hotstrings (i.e. while the script is running). If you found any other limitations that made using built-in hotstrings difficult or impossible, please let me know.

A tiny cosmetic improvement to your code: I notice you sometimes escape braces as `{ and `}. This isn't necessary except in the Send command, in which case you would use {{} and {}} (or use SendRaw to avoid the need for escaping).

Great work on Texter, especially its intuitive interface!
Back to top
View user's profile Send private message Send e-mail
AdamPash
Guest





PostPosted: Sun Mar 04, 2007 2:28 am    Post subject: Reply with quote

@Elevator_Hazard: My script doesn't suffer from that problem b/c in Text mode, I'm sending the clipboard contents. In script mode, I actually *want* to be able to send special characters like ^ as Ctrl and # and Windows key. See the documentation for more.

@Chris: Thanks a lot, that's really nice to hear! Like you said, I couldn't use AHK's built-in hotstring function b/c I can't build them on the fly. That's the main reason I didn't even start off trying to use AHK's hotstrings.

I am seeing one major problem, though, and that's re:issues with Windows clipboard incompatibilites. I haven't been able to narrow down the causes entirely (sometimes it looks to be caused by clipboard helpers), but in some XP and Vista installations Send,^v will send what was previously in the clipboard rather than what I used AHK to put into the clipboard:

Code:
EXECUTE:
SoundPlay, %A_ScriptDir%\resources\replace.wav
oldClip = %Clipboard%
ReturnTo := 0
StringLen,BSlength,input
Send {BS %BSlength%}
FileRead, Clipboard, %A_WorkingDir%\replacements\%input%.txt
IfInString,Clipboard,::scr:: {
StringReplace,Script,Clipboard,::scr::,,
Send,%Script%
oldClip = %Clipboard% ; this is to make sure that if someone scripts a copy, it is retained
return
}
else {
IfInString,Clipboard,`%c {
StringReplace, Clipboard, Clipboard, `%c, %oldClip%, All
}
IfInString,Clipboard,`%| {
StringGetPos,CursorPoint,Clipboard,`%|
StringReplace, MeasureClip,Clipboard,`n,,All
StringGetPos,CursorPoint,MeasureClip,`%|
StringReplace, Clipboard, Clipboard, `%|,, All
StringReplace, MeasureClip,Clipboard,`n,,All
StringLen,ClipLength,MeasureClip
ReturnTo := ClipLength - CursorPoint
}
Send,^v
if ReturnTo > 0
Send {Left %ReturnTo%}
Clipboard = %oldClip%
}


So I assign new value to the clipboard here:

Code:
FileRead, Clipboard, %A_WorkingDir%\replacements\%input%.txt


...and paste it with Send,^v. But it still sends the old clipboard. Can you shed any light on what's going on here?
Back to top
Elevator_Hazard



Joined: 28 Oct 2006
Posts: 301
Location: US

PostPosted: Sun Mar 04, 2007 2:42 am    Post subject: Reply with quote

I really don't know... But maybe using Clipboard as an outputvar doesn't work... Just maybe, not sure though.
_________________
Changed siggy at request of ahklerner Very Happy
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10692

PostPosted: Sun Mar 04, 2007 2:50 pm    Post subject: Reply with quote

I tried the following simple test and it works okay:
Code:
FileRead, Clipboard, %A_ScriptFullPath%
Send ^v
It's possible that some PCs have a clipboard manager installed that interferes with the script's attempts to change the clipboard. Or maybe it's a timing problem of some kind (in which case putting a Sleep somewhere might fix it).
Back to top
View user's profile Send private message Send e-mail
pepoluan_notlogin
Guest





PostPosted: Mon Mar 05, 2007 8:45 pm    Post subject: Clipboard problems Reply with quote

Deep inside the following thread: http://www.autohotkey.com/forum/topic5807.html is a discussion on how Clipboard may be too slow.

Try using a ClipboardWait as one of the post suggested.
Back to top
AdamPash
Guest





PostPosted: Tue Mar 06, 2007 8:34 am    Post subject: Reply with quote

Interesting - but I can't for the life of me find any documentation on ClipboardWait. Am I missing something?
Back to top
BETLOG



Joined: 27 Nov 2006
Posts: 219
Location: Queensland, Australia

PostPosted: Tue Mar 06, 2007 1:55 pm    Post subject: Reply with quote

Because it's getting called the wrong thing :]
http://www.autohotkey.com/docs/commands/ClipWait.htm
Back to top
View user's profile Send private message
pepoluan



Joined: 12 Jun 2006
Posts: 18
Location: Jakarta, Indonesia

PostPosted: Wed Mar 07, 2007 7:36 pm    Post subject: Reply with quote

Ooops Rolling Eyes
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
majkinetor



Joined: 24 May 2006
Posts: 3714
Location: Belgrade

PostPosted: Wed Mar 07, 2007 7:54 pm    Post subject: Reply with quote

Very nice script and interface Very Happy
_________________
Back to top
View user's profile Send private message MSN Messenger
drmurdoch



Joined: 10 Nov 2006
Posts: 101

PostPosted: Mon Mar 19, 2007 1:18 am    Post subject: New Texter Forums Reply with quote

Adam has some forums for the Program Texter

http://www.adampash.com/texter/forum/index.php
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