![Photo](http://autohotkey.com/board/uploads/profile/photo-thumb-1.jpg?_r=1372114442)
RegEx Powered Dynamic Hotstrings
Started by
polyethene
, Feb 04 2007 05:59 PM
225 replies to this topic
Nice!
One suggestion and a couple of issues, though.
When replacing the hotstring this seems to work smoother:
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)!
One suggestion and a couple of issues, though.
When replacing the hotstring this seems to work smoother:
... 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)!
#17
-
Posted 22 December 2007 - 10:21 AM
![RegEx Powered Dynamic Hotstrings: post #17](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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?
#18
-
Posted 22 December 2007 - 11:12 AM
![RegEx Powered Dynamic Hotstrings: post #18](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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!
In the meantime, happy holidays to all!
#20
-
Posted 22 December 2007 - 12:33 PM
![RegEx Powered Dynamic Hotstrings: post #20](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Nope, I tried \s; \b works! I better read up on regexps ;-}Have you tried hotstrings("\bann(a|e)" , "Ann%$1%")
#21
-
Posted 22 December 2007 - 01:21 PM
![RegEx Powered Dynamic Hotstrings: post #21](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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?
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?
![:)](http://www.autohotkey.com/board/public/style_emoticons/default/happy.png)
#23
-
Posted 28 December 2007 - 07:08 PM
![RegEx Powered Dynamic Hotstrings: post #23](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
Can't see why that is, this script only uses core functionality of AutoHotkey. Have you tried #InstallKeybdHook?
#24
-
Posted 28 December 2007 - 07:21 PM
![RegEx Powered Dynamic Hotstrings: post #24](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
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?
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?
#25
-
Posted 31 December 2007 - 01:00 PM
![RegEx Powered Dynamic Hotstrings: post #25](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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
#27
-
Posted 02 January 2008 - 01:05 PM
![RegEx Powered Dynamic Hotstrings: post #27](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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:
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?
In this example typing btw followed by two spaces produces by the ww. Bug?
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.
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:
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?
hotstrings("(B|b)tw\s", "%$1%y the way")
In this example typing btw followed by two spaces produces by the ww. Bug?
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.
#28
-
Posted 06 January 2008 - 10:15 PM
![RegEx Powered Dynamic Hotstrings: post #28](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
I've found a bug which prevents hotstrings(k) from removing k from the list of expressions (presuming it is supposed to remove k):
Additionally, I suggest changing
Else If a = t := RegExReplace(t, "\n\Q" . [color=red]a[/color] . "\E\r.*?\n")Clearly a is empty; I guess it should be k.
Additionally, I suggest changing
Else If k != t = %t%`n%k%`r%a%`nto something like
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).
#29
-
Posted 03 January 2009 - 04:32 AM
![RegEx Powered Dynamic Hotstrings: post #29](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)
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
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
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.
#30
-
Posted 03 January 2009 - 07:23 PM
![RegEx Powered Dynamic Hotstrings: post #30](http://www.autohotkey.com/board/public/style_images/ortem/icon_share.png)