Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Texter - Text replacement tool with GUI


  • Please log in to reply
11 replies to this topic
AdamPash
  • Guests
  • Last active:
  • Joined: --
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.co... ... 238306.php

Here's the source:

http://lifehacker.co... ... texter.ahk

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

Thanks!

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
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 <!-- w -->www.freewebtown.com/elevator_hazard<!-- w --> 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 :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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!

AdamPash
  • Guests
  • Last active:
  • Joined: --
@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:

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:

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?

Elevator_Hazard
  • Members
  • 297 posts
  • Last active: Feb 07 2011 12:10 AM
  • Joined: 28 Oct 2006
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 :D

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I tried the following simple test and it works okay:
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).

pepoluan_notlogin
  • Guests
  • Last active:
  • Joined: --
Deep inside the following thread: http://www.autohotke.../topic5807.html is a discussion on how Clipboard may be too slow.

Try using a ClipboardWait as one of the post suggested.

AdamPash
  • Guests
  • Last active:
  • Joined: --
Interesting - but I can't for the life of me find any documentation on ClipboardWait. Am I missing something?

BETLOG
  • Members
  • 222 posts
  • Last active: Apr 07 2010 01:58 PM
  • Joined: 27 Nov 2006
Because it's getting called the wrong thing :]
<!-- m -->http://www.autohotke...ds/ClipWait.htm<!-- m -->

pepoluan
  • Members
  • 18 posts
  • Last active: Jun 18 2007 07:16 PM
  • Joined: 12 Jun 2006
Ooops :roll:

majkinetor
  • Moderators
  • 4512 posts
  • Last active: Jul 29 2016 12:40 AM
  • Joined: 24 May 2006
Very nice script and interface :D
Posted Image

drmurdoch
  • Members
  • 120 posts
  • Last active: Aug 05 2015 03:27 PM
  • Joined: 10 Nov 2006
Adam has some forums for the Program Texter

http://www.adampash....forum/index.php