AutoHotkey Community

It is currently May 26th, 2012, 2:17 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 12  Next
Author Message
 Post subject:
PostPosted: December 21st, 2007, 10:46 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Thanks for the ideas and solutions, I forgot about this script. Anyway I've completely rewrote it and uploaded the new version.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 11:21 am 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Nice!
One suggestion and a couple of issues, though.

When replacing the hotstring this seems to work smoother:
Code:
...
  If (IsLabel(ct2)) {
    SendInput, {BS %rl%}
    Gosub, %ct2%
  }
  Else {
    Transform, ctr, Deref, %ct2%
    SendInput, {BS %rl%}%ctr%
}
...


Trying the rjwilmsi example I found that anna is correctly, automagically changed to Anna, but nanna is wrongly changed to nAnna.
Try hotstrings("ann(a|e)" , "Ann%$1%") and type nAnne - try to correct the A to a ({left 4}{bs}a)!

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 12:12 pm 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
tonne wrote:
Trying the rjwilmsi example I found that anna is correctly, automagically changed to Anna, but nanna is wrongly changed to nAnna.


I'm not sure if that's a bug as such as I would want text within words to be corrected, e.g. correcting 'sss' to 'ss'. Perhaps my Anna example was a bad one to choose, or could we introduce a third argument to specify whole word/within word correction?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 12:29 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Have you tried hotstrings("\bann(a|e)" , "Ann%$1%")

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 1:33 pm 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
Thanks for the very helpful posts guys (and girls?). I'll take a proper look at version 2 of the script and the suggestions in this topic when I'm back on Windows at work in the new year. I'll then post back with further examples to help others using the script. Probably this script should then be promoted to the sample list in the AHK help.

In the meantime, happy holidays to all!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 2:21 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
Titan wrote:
Have you tried hotstrings("\bann(a|e)" , "Ann%$1%")

Nope, I tried \s; \b works! I better read up on regexps ;-}

_________________
RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 22nd, 2007, 2:30 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Glad it does :)
I've included an example with \b in scripts comments for anybody who hasn't read these posts.

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 8:08 pm 
Offline

Joined: December 18th, 2007, 1:47 pm
Posts: 11
I've been trying to get this function to work for me for a few days with no luck. Just for the heck of it, I tried it on my other PC and it works just fine.

Both pc's have the same version of AHK, and my ahk files are identical.

Only real difference is one is windows 2000, and the other is XP.

Can anyone shed some light on the matter? :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 28th, 2007, 8:21 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Can't see why that is, this script only uses core functionality of AutoHotkey. Have you tried #InstallKeybdHook?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2007, 2:00 pm 
Offline

Joined: December 18th, 2007, 1:47 pm
Posts: 11
I just tried #InstallKeybdHook, still no luck.

Going to do some more digging, there's gotta be something running on this machine preventing it from working..

Should it matter if AHK is installed or just unzipped into it's own folder in program files?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 31st, 2007, 2:04 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
scoob8000 wrote:
Should it matter if AHK is installed or just unzipped into it's own folder in program files?
I highly doubt it.

Can anyone else with <XP use this script?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 2nd, 2008, 2:05 pm 
Offline

Joined: December 18th, 2007, 1:47 pm
Posts: 11
Titan wrote:
Can anyone else with <XP use this script?


I couldn't find anything running on my W2K workstation, so I'll give it a shot in a vmware box at home if I remember.


Nonetheless, I'm just going to work with this on my XP machine for now..

I've pretty much got things figured out.

After my hotstring matches I want to send a {tab} without replacing the text the hotstring matched.

I'm drawing a blank here, I've tried using a seperate label but that still replaces the text with the tab.

#Hotstring b0 doesn't seem to do the trick either.



-Mike


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 6th, 2008, 11:15 pm 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
Two comments on version 2 of the script:

First of all let me say that version 2 of the script is an improvement on the first version, as the second version resolved a couple of issues I had.
However, I've found a couple of further/unresolved issues with version 2 of the script, so would like to post them for help / discussion:

Code:
hotstrings("([hwHW]a|i)(s?sn|ns)(['s])?t(\s)" , "%$1%sn't%$4%")


In this example isnt is replaced by isn't (etcetera) after a further space is pressed. However, typing isnt followed by a tab produces iisn't. Bug?

Code:
hotstrings("(B|b)tw\s", "%$1%y the way")


In this example typing btw followed by two spaces produces by the ww. Bug?

Code:
Send, %ctr%


Performance of the script seems better if this line uses SendInput rather than Send. Is that okay?

I will post a selection of examples once these issues are resolved/I understand I've gone wrong. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2009, 5:32 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7501
Location: Australia
I've found a bug which prevents hotstrings(k) from removing k from the list of expressions (presuming it is supposed to remove k):
Code:
   Else If a =
      t := RegExReplace(t, "\n\Q" . a . "\E\r.*?\n")
Clearly a is empty; I guess it should be k.

Additionally, I suggest changing
Code:
   Else If k !=
      t = %t%`n%k%`r%a%`n
to something like
Code:
   Else If k !=
        t := RegExReplace(t, "\n\Q" . k . "\E\r.*?\n|$", "`n" k "`r" a "`n", _, 1)
to automatically replace any identical expressions (or append, as appropriate).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 3rd, 2009, 8:23 pm 
Offline

Joined: May 18th, 2005, 11:03 am
Posts: 30
Lexikos, thank you for posting on this topic. I use this function/code every day and still have some issues with it, so any input is much appreciated.

First of all I've found that my bug with the "isn't" example I give in my post above is actually only a problem when using Notepad++ and setting 'replace tabs with spaces', so there's no bug in this script in that case.

Regarding your post, I don't understand the bug you mention? What is the problem, could you post a couple of examples (changing my script I can't see a difference in behaviour).

Your second change breaks entries like
Code:
hotstrings("\bann(a|e)" , "Ann%$1%")
as it replaces 'anna' --> 'Ann' i.e. the variable is not included. If possible please post back on the problem there and what difference changing that line should make. Thanks.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 171 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 12  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol, Stigg and 16 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