Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

RegEx Dynamic Hotstrings


  • Please log in to reply
53 replies to this topic
Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

Original Library (outdated) : http://www.autohotke...mic-hotstrings/
 
Function: Dynamically add regular expression type hotstrings.
 
This is the fixed library from polyethene, the original version was having a lot of problems not showing some characters and returning numbers instead of characters on some cases, so I decided to work on it in order to fix all these issues.
 
So here it is. wink.png
 
Fixed Library (updated on 01/03/15):

 

Changes (Alpha Bravo contribution):

- Fixed where the trigger does not have to be removed "Back-Spaced".

- Added Options.

/*
    Function: HotStrings
        Dynamically adds regular expression hotstrings.

    Parameters:
        c - regular expression hotstring
        a - (optional) text to replace hotstring with or a label to goto,
            leave blank to remove hotstring definition from triggering an action

    Examples:
> hotstrings("(B|b)tw\s", "%$1%y the way") ; type 'btw' followed by space, tab or return
> hotstrings("i)omg", "oh my god!") ; type 'OMG' in any case, upper, lower or mixed
> hotstrings("\bcolou?r", "rgb(128, 255, 0);") ; '\b' prevents matching with anything before the word, e.g. 'multicololoured'

    License:
        - RegEx Dynamic Hotstrings: Modified version by Edd  
        - Original: <http://www.autohotkey.net/~polyethene/#hotstrings>
        - Dedicated to the public domain (CC0 1.0) <http://creativecommons.org/publicdomain/zero/1.0/>
*/

hotstrings(k, a = "", Options:="")
{
    static z, m = "~$", m_ = "*~$", s, t, w = 2000, sd, d = "Left,Right,Up,Down,Home,End,RButton,LButton", f = "!,+,^,#", f_="{,}"
    global $
    If z = ; init
    {
        RegRead, sd, HKCU, Control Panel\International, sDecimal
        Loop, 94
        {
            c := Chr(A_Index + 32)
            If A_Index between 33 and 58
                Hotkey, %m_%%c%, __hs
            else If A_Index not between 65 and 90
                Hotkey, %m%%c%, __hs
        }
        e = 0,1,2,3,4,5,6,7,8,9,Dot,Div,Mult,Add,Sub,Enter
        Loop, Parse, e, `,
            Hotkey, %m%Numpad%A_LoopField%, __hs
        e = BS,Shift,Space,Enter,Return,Tab,%d%
        Loop, Parse, e, `,
            Hotkey, %m%%A_LoopField%, __hs
        z = 1
    }
    If (a == "" and k == "") ; poll
    {
        q:=RegExReplace(A_ThisHotkey, "\*\~\$(.*)", "$1")
        q:=RegExReplace(q, "\~\$(.*)", "$1")
        If q = BS
        {
            If (SubStr(s, 0) != "}")
                StringTrimRight, s, s, 1
        }
        Else If q in %d%
            s =
        Else
        {
            If q = Shift
            return
            Else If q = Space
                q := " "
            Else If q = Tab
                q := "`t"
            Else If q in Enter,Return,NumpadEnter
                q := "`n"
            Else If (RegExMatch(q, "Numpad(.+)", n))
            {
                q := n1 == "Div" ? "/" : n1 == "Mult" ? "*" : n1 == "Add" ? "+" : n1 == "Sub" ? "-" : n1 == "Dot" ? sd : ""
                If n1 is digit
                    q = %n1%
            }
            Else If (GetKeyState("Shift") ^ !GetKeyState("CapsLock", "T"))
                StringLower, q, q
            s .= q
        }
        Loop, Parse, t, `n ; check
        {
            StringSplit, x, A_LoopField, `r
            If (RegExMatch(s, x1 . "$", $)) ; match
            {
                StringLen, l, $
                StringTrimRight, s, s, l
                if !(x3~="i)\bNB\b")        ; if No Backspce "NB"
                    SendInput, {BS %l%}
                If (IsLabel(x2))
                    Gosub, %x2%
                Else
                {
                    Transform, x0, Deref, %x2%
                    Loop, Parse, f_, `,
                        StringReplace, x0, x0, %A_LoopField%, ¥%A_LoopField%¥, All
                    Loop, Parse, f_, `,
                        StringReplace, x0, x0, ¥%A_LoopField%¥, {%A_LoopField%}, All
                    Loop, Parse, f, `,
                        StringReplace, x0, x0, %A_LoopField%, {%A_LoopField%}, All
                    SendInput, %x0%
                }
            }
        }
        If (StrLen(s) > w)
            StringTrimLeft, s, s, w // 2
    }
    Else ; assert
    {
        StringReplace, k, k, `n, \n, All ; normalize
        StringReplace, k, k, `r, \r, All
        Loop, Parse, t, `n
        {
            l = %A_LoopField%
            If (SubStr(l, 1, InStr(l, "`r") - 1) == k)
                StringReplace, t, t, `n%l%
        }
        If a !=
            t = %t%`n%k%`r%a%`r%Options%
    }
    Return
    __hs: ; event
    hotstrings("", "", Options)
    Return
}

Examples:

Spoiler



Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

well, I still see few issues, run this

HotStrings("(.)", "Label")
SendLevel, 1
var := "1234567890[]"
loop, parse, Var
	SendInput, +%A_LoopField%
return

Label:
ToolTip, % "suppose to be `n!@#$%^&*(){}`n`ninstead you get`n" out2 .= $1
return


Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

 

well, I still see few issues, run this

HotStrings("(.)", "Label")
SendLevel, 1
var := "1234567890[]"
loop, parse, Var
	SendInput, +%A_LoopField%
return

Label:
ToolTip, % "suppose to be `n!@#$%^&*(){}`n`ninstead you get`n" out2 .= $1
return

 

Ok, It's fixed now, try it out ( I already updated the library and the example on first post ):

HotStrings("(.)", "Label")
SendLevel, 1
var := "1234567890[]"
loop, parse, Var
{
Sleep, 1 ; <== on your example case needs a little time to process it correctly, the delay is not necessary in normal mode (when user is typing).
SendInput, +%A_LoopField%
}
return

Label:
ToolTip, % "suppose to be `n!@#$%^&*(){}`n`ninstead you get`n" out2 .= $1
return

ESC::ExitApp

/*
        Name: RegEx Dynamic Hotstrings

	Function: hotstrings
		Dynamically adds regular expression hotstrings.

	Parameters:
		c - regular expression hotstring
		a - (optional) text to replace hotstring with or a label to goto, 
			leave blank to remove hotstring definition from triggering an action

	Examples:
> hotstrings("(B|b)tw\s", "%$1%y the way") ; type 'btw' followed by space, tab or return
> hotstrings("i)omg", "oh my god!") ; type 'OMG' in any case, upper, lower or mixed
> hotstrings("\bcolou?r", "rgb(128, 255, 0);") ; '\b' prevents matching with anything before the word, e.g. 'multicololoured'

	License:
		- RegEx Dynamic Hotstrings: Modified version by Edd  
		- Original: <http://www.autohotkey.net/~polyethene/#hotstrings>
		- Dedicated to the public domain (CC0 1.0) <http://creativecommons.org/publicdomain/zero/1.0/>
*/

hotstrings(k, a = "")
{
	static z, m = "~$", m_ = "*~$", s, t, w = 2000, sd, d = "Left,Right,Up,Down,Home,End,RButton,LButton", f = "!,+,^,#", f_="{,}"
	global $
	If z = ; init
	{
		RegRead, sd, HKCU, Control Panel\International, sDecimal
		Loop, 94
		{
			c := Chr(A_Index + 32)
			If A_Index between 33 and 58
				Hotkey, %m_%%c%, __hs
				else
				Hotkey, %m%%c%, __hs
		}
		e = 0,1,2,3,4,5,6,7,8,9,Dot,Div,Mult,Add,Sub,Enter
		Loop, Parse, e, `,
			Hotkey, %m%Numpad%A_LoopField%, __hs
		e = BS,Shift,Space,Enter,Return,Tab,%d%
		Loop, Parse, e, `,
			Hotkey, %m%%A_LoopField%, __hs
		z = 1
	}
	If (a == "" and k == "") ; poll
	{
		q:=RegExReplace(A_ThisHotkey, "\*\~\$(.*)", "$1")
		q:=RegExReplace(q, "\~\$(.*)", "$1")
		If q = BS
		{
			If (SubStr(s, 0) != "}")
				StringTrimRight, s, s, 1
		}
		Else If q in %d%
			s =
		Else
		{
			If q = Shift
			return
			Else If q = Space
				q := " "
			Else If q = Tab
				q := "`t"
			Else If q in Enter,Return,NumpadEnter
				q := "`n"
			Else If (RegExMatch(q, "Numpad(.+)", n))
			{
				q := n1 == "Div" ? "/" : n1 == "Mult" ? "*" : n1 == "Add" ? "+" : n1 == "Sub" ? "-" : n1 == "Dot" ? sd : ""
				If n1 is digit
					q = %n1%
			}
			Else If (StrLen(q) != 1)
			q = {%q%}
			Else If (GetKeyState("Shift") ^ GetKeyState("CapsLock", "T"))
				StringUpper, q, q
			s .= q
		}
		Loop, Parse, t, `n ; check
		{
			StringSplit, x, A_LoopField, `r
			If (RegExMatch(s, x1 . "$", $)) ; match
			{
				StringLen, l, $
				StringTrimRight, s, s, l
				SendInput, {BS %l%}
				If (IsLabel(x2))
					Gosub, %x2%
				Else
				{
					Transform, x0, Deref, %x2%
					Loop, Parse, f_, `,
					StringReplace, x0, x0, %A_LoopField%, ¥%A_LoopField%¥, All
					Loop, Parse, f_, `,
					StringReplace, x0, x0, ¥%A_LoopField%¥, {%A_LoopField%}, All
					Loop, Parse, f, `,
					StringReplace, x0, x0, %A_LoopField%, {%A_LoopField%}, All
					SendInput, %x0%
				}
			}
		}
		If (StrLen(s) > w)
			StringTrimLeft, s, s, w // 2
	}
	Else ; assert
	{
		StringReplace, k, k, `n, \n, All ; normalize
		StringReplace, k, k, `r, \r, All
		Loop, Parse, t, `n
		{
			l = %A_LoopField%
			If (SubStr(l, 1, InStr(l, "`r") - 1) == k)
				StringReplace, t, t, `n%l%
		}
		If a !=
			t = %t%`n%k%`r%a%
	}
	Return
	__hs: ; event
	hotstrings("", "")
	Return
}


Wehaveall
  • Members
  • 25 posts
  • Last active: Oct 13 2014 02:40 PM
  • Joined: 08 Jun 2011

the problem is that when using this fuciton with caps lock on, it turns caps off by itself.



Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

the problem is that when using this fuciton with caps lock on, it turns caps off by itself.

 

It doesn't happen to me, please be more specific on this, or put an example.



Wehaveall
  • Members
  • 25 posts
  • Last active: Oct 13 2014 02:40 PM
  • Joined: 08 Jun 2011
;;;;;;;;;;;;;;;;;;;;;;;;;;; This is the function Iam using to call hotstrings
#NoTrayIcon
#SingleInstance, force
#Include %A_ScriptDir%\Hotstrings.ahk
global $1                
global FunNumNum        
      
hotstrings("([\d\.]+)ne\s","Numera") 
 
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
Numera:
global FunNumNum = 1
#Include %A_ScriptDir%\Numbers.ahk
return
 
 
 
If I leave caps on and begin to wirte something, the capslock will turn off after some characters written:  Ex.: AJKSSSkkjjkjkjk


Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

I still can't reproduce the probelm.. it seems not turning off capslock here.

 

Are you sure is this library the one that is giving you that problem, instead of Numbers?



Wehaveall
  • Members
  • 25 posts
  • Last active: Oct 13 2014 02:40 PM
  • Joined: 08 Jun 2011

Yes, because taking out all "SendInput" lines of this scripts, the problem disappear:

 

SendInput, {BS %l%}

SendInput, %x0%

 

some of my scripts functions still work, but the "trigger word"is no more replaced by the expression, that now is written after the trigger.

 

 

An example of number`s function below:

lobal virg:= chr(44)
global zerozeroum = 
global simples 
global milhar 
global milhao
global grana := "reais"
global Condition = True

global unidade = 0
global dezena = 0
global centena = 0
global unidademilhar = 0
global dezenamilhar = 0
global centenamilhar = 0
global unidademilhao = 0
global dezenamilhao = 0
global centenamilhao = 0
global bilhao = 0

global unidadenome
global dezenanome 
global centenanome 
global milharnome 
global unidademilharnome 
global dezenamilharnome 
global centenamilharnome 
global milhaonome 
global bilhaonome 
global unidademilhaonome 
global dezenamilhaonome 
global centenamilhaonome 
global unidadebilhao 
global dezenabilhao 
global centenabilhao 
global numero
global final = 




numero = %$1%


IfInString, numero, %virg%
{
StringRight, centavos, $1, 2
StringRight, unidade, centavos, 1	
StringLeft, dezena, centavos, 1	

duascasas()

If centavos = 00
finalcentavos = 

If centavos = 01
finalcentavos = e um centavo

If centavos > 01
finalcentavos = e %dezenanome% %unidadenome% centavos

StringTrimRight, $1, $1, 3
unidade = 
dezena = 
}

IfNotInString, numero, %virg%
{
	If FunNumDim = 1
    {
    centavos = 00	
    finalcentavos =
    numero = %numero%%virg%00
    }
}

StringReplace, conta1, $1, m,, All
StringReplace, conta2, conta1, n,, All
StringReplace, conta3, conta2, e,, All
StringReplace, conta4, conta3, .,, All
StringReplace, contador, conta4,%virg%,, All

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;Core
entrada:
If contador <> -1
	{
	StringLen, tamanho, contador
	
	If	tamanho = 1
	{
	    If contador = 0
			unidadenome = zero
		
		else if contador = 1
			unidadenome = um
		
		else if contador = 2
			unidadenome = dois
		
		else if contador = 3
			unidadenome = três
		
		else if contador = 4
			unidadenome = quatro
		
		else if contador = 5
			unidadenome = cinco
		
		else if contador = 6
			unidadenome = seis
		
		else if contador = 7
			unidadenome = sete
		
		else if contador = 8
			unidadenome = oito
		
		else if contador = 9
			unidadenome = nove
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
			If FunNumNum = 1
			Final =  %contador% (%unidadenome%)
			
			If FunNumExt = 1
			Final = %unidadenome%
			
			If FunNumDim = 1
			{
	
				If contador = 0
				{	
					
					If centavos = 00
					finalcentavos = 

					If centavos = 01
					finalcentavos = um centavo

					If centavos > 01
					StringTrimLeft, finalcentavos, finalcentavos, 2
				    
					
                }
				
				Final = R$ %numero% (%finalcentavos%)
			
				If contador = 1
			    Final = R$ %numero% (um real %finalcentavos%)
			
			    If contador > 1
			    Final = R$ %numero% (%unidadenome% %grana% %finalcentavos%)
			}
			
			TiraSpace()
			
			SendInput, %Final%
			
			
			zeratuto()
			return
	}
	
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEZENA		
	If tamanho = 2
				
{
	StringLeft, dezena, contador, 1
	StringRight, unidade, contador, 1
		
	duascasas()
		
	If FunNumNum = 1
	Final =  %numero% (%dezenanome% %unidadenome%)
			
	If FunNumExt = 1
	Final = %dezenanome% %unidadenome%
			
	If FunNumDim = 1
	Final = R$ %numero% (%dezenanome% %unidadenome% %grana% %finalcentavos%)
	
	TiraSpace()

	SendInput, %Final%
	zeratuto()
	return
}		
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CENTENA	
	
If tamanho = 3
		
{
	StringLeft, centena, contador, 1
	StringMid, dezena, contador, 2, 1
	StringRight, unidade, contador, 1
			
	ChecaCentena()
	ChecaDezena()
				
	If dezena = 0
	ChecaUnidade()
				
	If dezena = 1
	Checa10()
				
	If dezena > 1
    ChecaUnidade()
				   
	If FunNumNum = 1
	Final =  %numero% (%centenanome% %dezenanome% %unidadenome%)
			
	If FunNumExt = 1
	Final = %centenanome% %dezenanome% %unidadenome%
			
	If FunNumDim = 1
	Final = R$ %numero% (%centenanome% %dezenanome% %unidadenome% %grana% %finalcentavos%)
			
	TiraSpace()

	SendInput, %Final%
	zeratuto()
	return
}	
		


Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

Try this one:

/*
Name: RegEx Dynamic Hotstrings

    Function: hotstrings
        Dynamically adds regular expression hotstrings.

    Parameters:
        c - regular expression hotstring
        a - (optional) text to replace hotstring with or a label to goto,
            leave blank to remove hotstring definition from triggering an action

    Examples:
> hotstrings("(B|b)tw\s", "%$1%y the way") ; type 'btw' followed by space, tab or return
> hotstrings("i)omg", "oh my god!") ; type 'OMG' in any case, upper, lower or mixed
> hotstrings("\bcolou?r", "rgb(128, 255, 0);") ; '\b' prevents matching with anything before the word, e.g. 'multicololoured'

    License:
        - RegEx Dynamic Hotstrings: Modified version by Edd
        - Original: <http://www.autohotkey.net/~polyethene/#hotstrings>
        - Dedicated to the public domain (CC0 1.0) <http://creativecommons.org/publicdomain/zero/1.0/>
*/

hotstrings(k, a = "")
{
    static z, m = "~$", m_ = "*~$", s, t, w = 2000, sd, d = "Left,Right,Up,Down,Home,End,RButton,LButton", f = "!,+,^,#", f_="{,}"
    global $
    If z = ; init
    {
        RegRead, sd, HKCU, Control Panel\International, sDecimal
        Loop, 94
        {
            c := Chr(A_Index + 32)
            If A_Index between 33 and 58
                Hotkey, %m_%%c%, __hs
                else If A_Index not between 65 and 90
                Hotkey, %m%%c%, __hs
        }
        e = 0,1,2,3,4,5,6,7,8,9,Dot,Div,Mult,Add,Sub,Enter
        Loop, Parse, e, `,
            Hotkey, %m%Numpad%A_LoopField%, __hs
        e = BS,Shift,Space,Enter,Return,Tab,%d%
        Loop, Parse, e, `,
            Hotkey, %m%%A_LoopField%, __hs
        z = 1
    }
    If (a == "" and k == "") ; poll
    {
        q:=RegExReplace(A_ThisHotkey, "\*\~\$(.*)", "$1")
        q:=RegExReplace(q, "\~\$(.*)", "$1")
        If q = BS
        {
            If (SubStr(s, 0) != "}")
                StringTrimRight, s, s, 1
        }
        Else If q in %d%
            s =
        Else
        {
            If q = Shift
            return
            Else If q = Space
                q := " "
            Else If q = Tab
                q := "`t"
            Else If q in Enter,Return,NumpadEnter
                q := "`n"
            Else If (RegExMatch(q, "Numpad(.+)", n))
            {
                q := n1 == "Div" ? "/" : n1 == "Mult" ? "*" : n1 == "Add" ? "+" : n1 == "Sub" ? "-" : n1 == "Dot" ? sd : ""
                If n1 is digit
                    q = %n1%
            }
            Else If (GetKeyState("Shift") ^ !GetKeyState("CapsLock", "T"))
                StringLower, q, q
            s .= q
        }
        Loop, Parse, t, `n ; check
        {
            StringSplit, x, A_LoopField, `r
            If (RegExMatch(s, x1 . "$", $)) ; match
            {
                StringLen, l, $
                StringTrimRight, s, s, l
                SendInput, {BS %l%}
                If (IsLabel(x2))
                    Gosub, %x2%
                Else
                {
                    Transform, x0, Deref, %x2%
                    Loop, Parse, f_, `,
                    StringReplace, x0, x0, %A_LoopField%, ¥%A_LoopField%¥, All
                    Loop, Parse, f_, `,
                    StringReplace, x0, x0, ¥%A_LoopField%¥, {%A_LoopField%}, All
                    Loop, Parse, f, `,
                    StringReplace, x0, x0, %A_LoopField%, {%A_LoopField%}, All
                    SendInput, %x0%
                }
            }
        }
        If (StrLen(s) > w)
            StringTrimLeft, s, s, w // 2
    }
    Else ; assert
    {
        StringReplace, k, k, `n, \n, All ; normalize
        StringReplace, k, k, `r, \r, All
        Loop, Parse, t, `n
        {
            l = %A_LoopField%
            If (SubStr(l, 1, InStr(l, "`r") - 1) == k)
                StringReplace, t, t, `n%l%
        }
        If a !=
            t = %t%`n%k%`r%a%
    }
    Return
    __hs: ; event
    hotstrings("", "")
    Return
}

This improves and solves the capslock desactivate keys as much at it can (Library was updated to this one already), but capslock led would still blinking, doesn't matter to much because is just a little.

Anyways, when you're using this library all that you type is process it by this function, in order to detect when to do a regex replace or an action.

The faster as you type, the faster as it pass through the function.. the CapsLock blinking Led and turn it off problem is caused because of this, this is an autohotkey issue when using SendInput, try this:

SetCapsLockState, On
Run, notepad.exe
WinWait, Untitled - Notepad
MsgBox, Look at your CapsLock Led
Loop, 5000
{
GetKeyState, state, Esc
if state = D
break
SendInput, OK ; Blink CapsLock Led and turn CapsLock off while the led is off on every blinking.
}
MsgBox, You can see the problem here when using SendInput.
SetCapslockState, Off
ExitApp
return

This is not caused by the library, is caused by a issue on autohotkey SendInput command, I suggest you to report it on the issues section.



Wehaveall
  • Members
  • 25 posts
  • Last active: Oct 13 2014 02:40 PM
  • Joined: 08 Jun 2011

Thanks mate for you effort and help!!!



troywweber
  • Members
  • 2 posts
  • Last active: Oct 10 2014 07:09 PM
  • Joined: 23 Sep 2014

I sorely want the functionality added by this function, but when I include the script in another file with...

#Include, DynamicRegex.ahk

...similar to what is shown above.

 

It seems to ignore it. In fact, the only way I can get dynamic regex's to work at all is if I put them directly in the file DynamicRegex.ahk, which I had intended to only house the 'hotstrings' function.

 

I hope someone can help with this.

 

Thanks,

Troy



Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

I sorely want the functionality added by this function, but when I include the script in another file with...

#Include, DynamicRegex.ahk

...similar to what is shown above.

 

It seems to ignore it. In fact, the only way I can get dynamic regex's to work at all is if I put them directly in the file DynamicRegex.ahk, which I had intended to only house the 'hotstrings' function.

 

I hope someone can help with this.

 

Thanks,

Troy

 

Sorry, I didn't understand your point/problem at all, can you please be more specific on this?
Can you post a working example for your problem?



Alpha Bravo
  • Members
  • 1687 posts
  • Last active: Nov 07 2015 03:06 PM
  • Joined: 01 Sep 2011

Sorry, I didn't understand your point/problem at all, can you please be more specific on this?
Can you post a working example for your problem?

@Edd, your example at the top of the page shows

#Include, RegEx Dynamic Hotstrings.ahk

which could be confusing since is it not named after the function.

 

 

I sorely want the functionality added by this function, but when I include the script in another file with...

#Include, DynamicRegex.ahk

...similar to what is shown above.

 

It seems to ignore it. In fact, the only way I can get dynamic regex's to work at all is if I put them directly in the file DynamicRegex.ahk, which I had intended to only house the 'hotstrings' function.

 

I hope someone can help with this.

 

Thanks,

Troy

@troy, the function HotStrings needs to be housed in a file that you #include or named HotStrings.ahk and saved as lib



Edd
  • Members
  • 212 posts
  • Last active: Jan 06 2016 07:36 AM
  • Joined: 24 Dec 2011

@Edd, your example at the top of the page shows

#Include, RegEx Dynamic Hotstrings.ahk

which could be confusing since is it not named after the function.

 

You're right, now it should be more understandable.



irwardhana
  • Members
  • 5 posts
  • Last active: Oct 03 2014 09:57 PM
  • Joined: 26 Sep 2014

Hi, Edd
I really appreciate that you created Hotstrings Dynamic RegEx. I'm using it to create a database autoreplacement for my native language, Indonesian. I've been looking for autoreplacement program that could use regex, but couldn't find any. Your work, Hotstrings Dynamic RegEx, looks promising.
In Indonesian language there are tens of thousand of common words that use prefix 'ber', 'ter', 'mem', 'per' etc. So if an autoreplacement app can use regex, it only needs tens of code line to create a database entry for those words. If this project is successful, the app will be distributed freely to the public.
Actually, I'm new to AHK and I have 2 questions:

1. How can I assign the value of the parameter of Hotsrings function to a variabel?
example:

hotstrings("bb([a-z]+)", "berb%$1%")

so if I type 'bbatas', it becomes 'berbatas'
then I want to assign it to some variabels :
 

var1 := "bbatas"    ; <--- value of parameter 1
var2 := "berbatas"  ;<--- value of parameter 2

2. If i have code:
 

hotstrings("bbta", "babota")              ; code line A
hotstrings("bb([a-z]+)", "berb%$1%")      ; code line B

when I type 'bbta' it becomes 'berbta', but what I want is 'babota'.
I can't figure out how to do that. Maybe using 'if statement'?
Basically what I need to do is make the script to read code line A first, if the code line A is triggered (when I type ' bbta' and becomes ' babota') then the script will not read code line B, and vice versa.