Jump to content

Eval($variable)... How about Eval(function)?


Recommended Posts

I know that Eval in AutoIT is for variables, but in PHP it's for executing code.

Is that possible here?

For example....

For $i = 1 To StringLen($sKeys) - 1 Step 1
    HotKeySet(StringMid($sKeys, $i, 1));Clear intercept
    Send(StringMid($sKeys, $i, 1));Pass it thru
    HotKeySet(StringMid($sKeys, $i, 1), "Key_"&StringUpper(StringMid($sKeys, $i, 1)));Initiate intercept
Next

AutoIT doesn't like how I'm trying to set my hotkeys, so I was wondering if there was a way to set a function to a variable, and have autoit execute the code inside of the variable.

Kind of like this...

Func Test_1()
    ConsoleWrite("Test 1"&@CRLF)
EndFunc

Func Test_2()
    ConsoleWrite("Test 2"&@CRLF)
EndFunc

Func Test_3()
    ConsoleWrite("Test 3"&@CRLF)
EndFunc

For $i = 1 To 3 Step 1
    VarFunc("Test_"&$i)
Next

VarFunc being my made up name for this function if it exists. Does it?

Link to comment
Share on other sites

I'm trying to make AuotIT intercept the "a" key. When the "a" key is pressed, if it is not pressed again before the DelayMax, then send the "press" thru, otherwise, keep it in a cache (tree). Continue to keep it in the cache until the interval ($iTime) finally exceeds the DelayMax, and when that happens, send thru the cache.

The best way for this to work is with sethotkey, becausing using loops with ispressed would not allow me to keep proper track of milisecond intervals.

Here is my code so far...

#include <Array.au3>

Opt("SendKeyDelay", 1)
Opt("SendKeyDownDelay", 1)

Dim $bIntercept = True
Dim $aKeys[1]
Dim $aTimes[1]
Dim $iTime = 0
Dim $iMaxDelay = 5

Func _HotKeySet($sKey, $sFunction = "");This is a Call() wrapper
    If $sFunction Then
        HotKeySet($sKey, $sFunction)
    Else
        HotKeySet($sKey)
    EndIf
EndFunc

Func _Send($sKeys);This is a Call() wrapper
    Send($sKeys)
EndFunc

HotKeySet("a", "Key_A");Initiate intercept
Func Key_A()
    If Not StringLen($aTimes[0]) Then;If there is no time tree.
        $aTimes[0] = $iTime
        $aKeys[0] = "a"
        ConsoleWrite("This is step 1"&@CRLF)
    Else;If there is a time tree
        _ArrayAdd($aTimes, $iTime)
        _ArrayAdd($aKeys, "a")
        ConsoleWrite("This is step 2"&@CRLF)
    EndIf
    $iTime = 0;Reset timer
EndFunc


AdlibEnable("IncreaseTime", 1);Set a timer

Func IncreaseTime()
    $iTime += 1;Increase timer by 1
    $sKeys = StringReplace(_ArrayToString($aKeys, ","), ",", "");Convert tree to string
    If Not StringLen($sKeys) And $aKeys[0] <> "" Then;Convert tree to string
        $sKeys = $aKeys[0];Convert tree to string
    EndIf;Convert tree to string
    If $iTime > $iMaxDelay And StringLen($sKeys) Then;If timer exceeded max
        For $i = 1 To StringLen($sKeys) Step 1
            $sKey = StringMid($sKeys, $i, 1)
            Call('_HotKeySet', $sKey)
            Call('_Send', $sKey)
            Call('_HotKeySet', $sKey, 'Key_'&StringUpper($sKey))
        Next
        ReDim $aTimes[1]
        ReDim $aKeys[1]
    Else
    ;ConsoleWrite("TODO"&@CRLF)
    EndIf
EndFunc

While 1
    Sleep(250);Duh
WEnd

Pull up notepad, and run the script, and in notepad press "a", and you'll see how it continues the "a"... I'm telling the adlib timer to call a hotkey clear, send the key, then reinstate the hotkey function, but it doesn't seem to be obeying the hotkey clear, I think... I'm not sure though.

Any ideas?

Link to comment
Share on other sites

If you use a string literal when you invoke Call(), you're using Call() wrong. In your case, you're using Call() wrong. You don't need to use Call() at all in your code - so why are you?

Sorry, that was the short version of my code... Here's the full version so you can see why it's needed...

#include <Array.au3>

Opt("SendKeyDelay", 1)
Opt("SendKeyDownDelay", 1)

Dim $aKeys[1]
Dim $aTimes[1]
Dim $iTime = 0
Dim $iMaxDelay = 5

Func _HotKeySet($sKey, $sFunction = "");This is a Call() wrapper
    If StringLen($sFunction) Then
        HotKeySet($sKey, $sFunction)
    Else
        HotKeySet($sKey)
    EndIf
EndFunc

Func _Send($sKeys);This is a Call() wrapper
    Send($sKeys)
EndFunc

HotKeySet("0", "Key_0");Initiate intercept
Func Key_0()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "0"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "0")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("1", "Key_1");Initiate intercept
Func Key_1()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "1"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "1")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("2", "Key_2");Initiate intercept
Func Key_2()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "2"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "2")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("3", "Key_3");Initiate intercept
Func Key_3()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "3"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "3")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("4", "Key_4");Initiate intercept
Func Key_4()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "4"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "4")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("5", "Key_5");Initiate intercept
Func Key_5()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "5"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "5")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("6", "Key_6");Initiate intercept
Func Key_6()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "6"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "6")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("7", "Key_7");Initiate intercept
Func Key_7()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "7"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "7")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("8", "Key_8");Initiate intercept
Func Key_8()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "8"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "8")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("9", "Key_9");Initiate intercept
Func Key_9()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "9"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "9")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("a", "Key_A");Initiate intercept
Func Key_A()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "a"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "a")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("b", "Key_B");Initiate intercept
Func Key_B()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "b"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "b")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("c", "Key_C");Initiate intercept
Func Key_C()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "c"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "c")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("d", "Key_D");Initiate intercept
Func Key_D()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "d"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "d")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("e", "Key_E");Initiate intercept
Func Key_E()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "e"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "e")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("f", "Key_F");Initiate intercept
Func Key_F()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "f"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "f")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("g", "Key_G");Initiate intercept
Func Key_G()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "g"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "g")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("h", "Key_H");Initiate intercept
Func Key_H()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "h"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "h")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("i", "Key_I");Initiate intercept
Func Key_I()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "i"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "i")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("j", "Key_J");Initiate intercept
Func Key_J()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "j"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "j")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("k", "Key_K");Initiate intercept
Func Key_K()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "k"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "k")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("l", "Key_L");Initiate intercept
Func Key_L()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "l"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "l")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("m", "Key_M");Initiate intercept
Func Key_M()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "m"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "m")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("n", "Key_N");Initiate intercept
Func Key_N()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "n"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "n")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("o", "Key_O");Initiate intercept
Func Key_O()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "o"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "o")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("p", "Key_P");Initiate intercept
Func Key_P()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "p"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "p")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("q", "Key_Q");Initiate intercept
Func Key_Q()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "q"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "q")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("r", "Key_R");Initiate intercept
Func Key_R()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "r"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "r")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("s", "Key_S");Initiate intercept
Func Key_S()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "s"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "s")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("t", "Key_T");Initiate intercept
Func Key_T()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "t"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "t")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("u", "Key_U");Initiate intercept
Func Key_U()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "u"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "u")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("v", "Key_V");Initiate intercept
Func Key_V()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "v"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "v")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("w", "Key_W");Initiate intercept
Func Key_W()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "w"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "w")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("x", "Key_X");Initiate intercept
Func Key_X()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "x"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "x")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("y", "Key_Y");Initiate intercept
Func Key_Y()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "y"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "y")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc

HotKeySet("z", "Key_Z");Initiate intercept
Func Key_Z()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = "z"
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        If $iTime > $iMaxDelay Then
            $iTime = $iMaxDelay + 1
            IncreaseTime()
        Else
            _ArrayAdd($aTimes, $iTime)
            _ArrayAdd($aKeys, "z")
            ConsoleWrite("This is step 2 "&$iTime&@CRLF)
        EndIf
    EndIf
    $iTime = 0;Reset timer
EndFunc


HotKeySet(Chr(13), "Key_ENTER");Initiate intercept
Func Key_ENTER()
    If Not StringLen($aTimes[0]) Then;If there is no time tree
        $aTimes[0] = $iTime
        $aKeys[0] = Chr(13)
        ConsoleWrite("This is step 1 "&$iTime&@CRLF)
    Else;If there is a time tree
        _ArrayAdd($aTimes, $iTime)
        _ArrayAdd($aKeys, Chr(13))
        ConsoleWrite("This is step 2 "&$iTime&@CRLF)
    EndIf
    $iTime = 0;Reset timer
EndFunc

AdlibEnable("IncreaseTime", 1);Set a timer

Func IncreaseTime()
    $iTime += 1;Increase timer by 1
    $sKeys = StringReplace(_ArrayToString($aKeys, ","), ",", "");Convert tree to string
    If Not StringLen($sKeys) And $aKeys[0] <> "" Then;Convert tree to string
        $sKeys = $aKeys[0];Convert tree to string
    EndIf;Convert tree to string
    If $iTime > $iMaxDelay And StringLen($sKeys) Then;If timer exceeded max
        If StringRight($sKeys, 1) <> Chr(13) Then
            For $i = 1 To StringLen($sKeys) Step 1
                $sKey = StringMid($sKeys, $i, 1)
                Call("_HotKeySet", $sKey)
                Call("_Send", $sKey)
                Call("_HotKeySet", $sKey, "Key_"&StringUpper($sKey))
            Next
        Else
            If $sKeys == Chr(13) Then
                Call("_HotKeySet", Chr(13))
                Call("_Send", Chr(13))
                Call("_HotKeySet", Chr(13), "Key_ENTER")
            Else
                $sKeys = StringLeft($sKeys, StringLen($sKeys) - 1)
                If $sKeys = "hello" Then
                    MsgBox(0, "hello", "Hey, what's up?")
                ElseIf $sKeys = "0181682" Then
                    MsgBox(0, "Budweiser 12oz Bottle", "Always good to have a bud.")
                Else
                    ClipPut($sKeys)
                    MsgBox(0, "Huh?!", "What did you call me?!")
                EndIf
            EndIf
        EndIf
        Dim $aTimes[1]
        Dim $aKeys[1]
        $iTime = 0
    Else
    ;ConsoleWrite("TODO"&@CRLF)
    EndIf
EndFunc

While 1
    Sleep(250);Duh
WEnd
Link to comment
Share on other sites

Did you actually read what I said? The full code still shows no reason for using Call().

Maybe I'm not understanding what you mean, exactly...

For $i = 1 To StringLen($sKeys) Step 1
                $sKey = StringMid($sKeys, $i, 1)
                Call("_HotKeySet", $sKey)
                Call("_Send", $sKey)
                Call("_HotKeySet", $sKey, "Key_"&StringUpper($sKey))
            Next

When looping thru each character in key "buffer", and "sending" it out, how else would I make the above work without using calls, and the hotkeyset wrapper?

I've tried just doing HotKeySet($sKey, "Key_"&StringUpper($sKey)) in the loop, and AutoIT would report an error.

Link to comment
Share on other sites

Sigh.

First, if you want to use the wrapper, DON'T USE CALL. Whatever gave you the idea you needed Call(), I don't know. Just call the damn functions:

For $i = 1 To StringLen($sKeys) Step 1
                $sKey = StringMid($sKeys, $i, 1)
                _HotKeySet($sKey)
                _Send($sKey)
                _HotKeySet($sKey, "Key_"&StringUpper($sKey))
            Next
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...