AutoHotkey Community

It is currently May 24th, 2012, 7:25 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: March 3rd, 2007, 12:14 am 
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/l ... 238306.php

Here's the source:

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

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

Thanks!


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2007, 4:29 am 
Offline

Joined: October 28th, 2006, 2:14 am
Posts: 297
Location: US
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 :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 3rd, 2007, 1:17 pm 
Offline

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2007, 2:28 am 
@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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2007, 2:42 am 
Offline

Joined: October 28th, 2006, 2:14 am
Posts: 297
Location: US
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2007, 2:50 pm 
Offline

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Clipboard problems
PostPosted: March 5th, 2007, 8:45 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2007, 8:34 am 
Interesting - but I can't for the life of me find any documentation on ClipboardWait. Am I missing something?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2007, 1:55 pm 
Offline

Joined: November 27th, 2006, 7:41 am
Posts: 222
Location: Queensland, Australia
Because it's getting called the wrong thing :]
http://www.autohotkey.com/docs/commands/ClipWait.htm


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2007, 7:36 pm 
Offline

Joined: June 12th, 2006, 9:14 pm
Posts: 18
Location: Jakarta, Indonesia
Ooops :roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2007, 7:54 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
Very nice script and interface :D

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: New Texter Forums
PostPosted: March 19th, 2007, 1:18 am 
Offline

Joined: November 10th, 2006, 5:10 am
Posts: 110
Adam has some forums for the Program Texter

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


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: tic and 8 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