Jump to content

Send Keys in SMS Layout


bentom
 Share

Recommended Posts

Hi all,

perhaps someone has an idea or did something like this before and can help me.

I want to write a little script that translates numbers [0-9] into keys. (Like on Mobile Phone). The idea behind is to have a possibility to use my remote control for internet browsing on my HTPC.

To give an example: You send an "2" via remote and an A appears. By repeating the "2" within 1sec it changes to B and so on. I think the best way would be with hot keys.

Did somebody here this before?

Regards,

B

Link to comment
Share on other sites

The thing is, how will you Hotkey a button that's on the remote control and not on the keyboard?

I've thought of this in the past, do you have an application that captures what's sent from the remote?

Try Event Ghost, try setting events for each of the keys or automate that application (make your script monitor it) and get the codes when they are sent in and set the hotkeys that need to be sent

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Actually, after searching a bit...

The Event Ghost app is really good, you can probably do what you want to mostly by using it!

Use the keyboard macro it has and you'll manage most, then a script shouldn't be that hard to make for the rest!

It won't do it all for you though...

You can let's say assing:

A to number 2

D to number 3

G to number 4

J to number 5

M to number 6

P to number 7

T to number 8

W to number 9

Space to number 0

If you assign more to each it'll probably just send them one after the other once you press the button so that's not good.

Then all you need is to make a script that will change the hotkeys depending on how many times you press in amount of time

hotkey for letter A should be A

you press 2, it saves A to variable and sets hotkey for A to B, if you press again it saves B in the place of A and sets hotkey for A to C

it should be possible

I was thinking of making an app to send the remote control commands to my pc because the remote control is hooked up to another computer that has IR, apparently the functionality is already there in the form of a plugin which sends the remote control commands over the network to Event Ghost running the receiver plugin, so I used that instead and didn't need to code anything! Really useful!

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

I've made some code, it should be working quite ok for such a little time I spent, I'm bored to bring the TV remote to try it out since i'll have to set it up to send the commands to my pc or put he script on the other which i'm also bored to do...

Because I found this interesting and wanted to see it work I wrote the code and will improve it by adding more things like small letters after the capitals and numbers after them, if you're interested in this as you started this topic, download the app I told you and i'll help you set it up the way I've thought of it, it should work...

My code is quite simple and there's surely an optimized way using the ascii codes, but my example is just the start...answer here so we can try this out!

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Thank you very much for your answers. I just started the code.

Unfortunatelly I have some problems with it. Attached you find my code. It would be perfect if someone colud help me with the function and timer. I'n not a specialist :-) Hopefully it's not that worde.

It would help ti have one example the others of course I can add myself

Regards,

B

#include <array.au3>

dim $sms[9][5]

$SMS[0][0] = 2
$SMS[0][1] = "{SPACE}"
$SMS[0][2] = "0"


$SMS[1][0] = 5
$SMS[1][1] = "."
$SMS[1][2] = ","
$SMS[1][3] = "?"
$SMS[1][4] = "{!}"
$SMS[1][5] = "'"

$SMS[2][0] = 5
$SMS[2][1] = "a"
$SMS[2][2] = "b"
$SMS[2][3] = "c"
$SMS[2][4] = "2"
$SMS[2][5] = "ä"

$SMS[3][0] = 4
$SMS[3][1] = "d"
$SMS[3][2] = "e"
$SMS[3][3] = "f"
$SMS[3][4] = "3"

$SMS[4][0] = 4
$SMS[4][1] = "g"
$SMS[4][2] = "h"
$SMS[4][3] = "i"
$SMS[4][4] = "4"

$SMS[5][0] = 4
$SMS[5][1] = "j"
$SMS[5][2] = "k"
$SMS[5][3] = "l"
$SMS[5][4] = "5"

$SMS[6][0] = 4
$SMS[6][1] = "m"
$SMS[6][2] = "n"
$SMS[6][3] = "o"
$SMS[6][4] = "6"

$SMS[7][0] = 5
$SMS[7][1] = "p"
$SMS[7][2] = "q"
$SMS[7][3] = "r"
$SMS[7][4] = "s"
$SMS[7][5] = "7"

$SMS[8][0] = 4
$SMS[8][1] = "t"
$SMS[8][2] = "u"
$SMS[8][3] = "v"
$SMS[8][4] = "8"

$SMS[9][0] = 5
$SMS[9][1] = "w"
$SMS[9][2] = "x"
$SMS[9][3] = "y"
$SMS[9][4] = "z"
$SMS[9][5] = "9"

dim $begin, $dif, $i
$i = 0

HotKeySet("2","two")

while 1

WEnd

Func two()
    ConsoleWrite($i & " " & $dif & @LF)

    $i = $i + 1
    HotKeySet("2")
    if $i = 1 then
        $begin = TimerInit()
        Send($SMS[2][$i])

    Else
        $dif = TimerDiff($begin)
        if $dif < 1000 Then
            Send($SMS[2][$i])
            $begin = TimerInit()
        Else

            Send($SMS[2][$i-1])

            $i = 0
        EndIf
    EndIf

    HotKeySet("2","two")

endfunc
Link to comment
Share on other sites

Something like this, it does need allot o improving, it freezes if you leave it to B:

Just run the example and press A a few times, if you let it to a or c it's somewhat ok, if you let it to B it stops working (it needs looking into) DON'T LET IT B (hahaha)

Try it out:

Global $timer

HotKeySet("{a}", "SendKeyA")

Func SendKeyA()
    Send("A")
    $timer = TimerInit()
    HotKeySet("{a}", "SendKeyB")
EndFunc   ;==>SendKeyA

Func SendKeyB()
    If TimerDiff($timer) < 800 Then
        Send("{Backspace}")
        Send("B")
        $timer1 = TimerInit()
        If TimerDiff($timer1) > 1000 Then
            HotKeySet("{a}", "SendKeyA")
        Else
            HotKeySet("{a}", "SendKeyC")
        EndIf
    Else
        HotKeySet("{a}", "SendKeyA")
    EndIf
EndFunc   ;==>SendKeyB

Func SendKeyC()
    If TimerDiff($timer) < 1000 Then
        Send("{Backspace}")
        Send("C")
        HotKeySet("{a}", "SendKeyA")
    EndIf
EndFunc   ;==>SendKeyC

While 1
    Sleep(10)
WEnd

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Something like this, it does need allot o improving, it freezes if you leave it to B:

Just run the example and press A a few times, if you let it to a or c it's somewhat ok, if you let it to B it stops working (it needs looking into) DON'T LET IT B (hahaha)

Much too complicated. He wants to bind 0 to ABC. No need for fiddling with HotKeySet and such.

Local $timer
Local $lastSentKey
HotKeySet("0", "SendKey0")
HotKeySet("{NUMPAD0}", "SendKey0")

While 1
    Sleep(500)
WEnd

Func SendKey0()
    If TimerDiff($timer) > 800 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case "a"
            Send("{BACKSPACE}")
            _send("b")
        Case "b"
            Send("{BACKSPACE}")
            _send("c")
        Case Else
            _send("a")
    EndSwitch
EndFunc

Func _send($key)
    $timer = TimerInit()
    Send($key)
    $lastSentKey = $key
EndFunc
Link to comment
Share on other sites

Hi again,

thank you so much for the input. Now I tried to do it for all numkeys. The code I have yet is this. I have the problem that i cannot give the proper key to the fuction. Can someone help.

Thank you again :-)

Regards,

B

Local $timer
Local $lastSentKey

dim $sms[10][10]

$SMS[0][0] = 2
$SMS[0][1] = "{SPACE}"
$SMS[0][2] = "0"


$SMS[1][0] = 5
$SMS[1][1] = "."
$SMS[1][2] = ","
$SMS[1][3] = "?"
$SMS[1][4] = "{!}"
$SMS[1][5] = "'"

$SMS[2][0] = 5
$SMS[2][1] = "a"
$SMS[2][2] = "b"
$SMS[2][3] = "c"
$SMS[2][4] = "2"
$SMS[2][5] = "ä"

$SMS[3][0] = 4
$SMS[3][1] = "d"
$SMS[3][2] = "e"
$SMS[3][3] = "f"
$SMS[3][4] = "3"

$SMS[4][0] = 4
$SMS[4][1] = "g"
$SMS[4][2] = "h"
$SMS[4][3] = "i"
$SMS[4][4] = "4"

$SMS[5][0] = 4
$SMS[5][1] = "j"
$SMS[5][2] = "k"
$SMS[5][3] = "l"
$SMS[5][4] = "5"

$SMS[6][0] = 4
$SMS[6][1] = "m"
$SMS[6][2] = "n"
$SMS[6][3] = "o"
$SMS[6][4] = "6"

$SMS[7][0] = 5
$SMS[7][1] = "p"
$SMS[7][2] = "q"
$SMS[7][3] = "r"
$SMS[7][4] = "s"
$SMS[7][5] = "7"

$SMS[8][0] = 4
$SMS[8][1] = "t"
$SMS[8][2] = "u"
$SMS[8][3] = "v"
$SMS[8][4] = "8"

$SMS[9][0] = 5
$SMS[9][1] = "w"
$SMS[9][2] = "x"
$SMS[9][3] = "y"
$SMS[9][4] = "z"
$SMS[9][5] = "9"



HotKeySet($i, "SendKey)


;HotKeySet("{NUMPAD0}", "SendKey0")

While 1
    Sleep(500)
WEnd

Func SendKey()
    If TimerDiff($timer) > 800 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case $SMS[$i][1]
            Send("{BACKSPACE}")
            _send($SMS[$i][2])
        Case $SMS[$i][2]
            Send("{BACKSPACE}")
            _send($SMS[$i][3])
        Case $SMS[$i][3]
            Send("{BACKSPACE}")
            _send($SMS[$i][4])
        Case $SMS[$i][4]
            Send("{BACKSPACE}")
            _send($SMS[$i][5])

        Case Else
            _send($SMS[$i][1])
    EndSwitch
EndFunc


Func _send($key)
    $timer = TimerInit()
    Send($key)
    $lastSentKey = $key
EndFunc
Link to comment
Share on other sites

After searching a bit, the functionality is already there, multitap can be done with the application I use, directly, without AutoIt...

It would be nice to be done with AutoIt only, but you'll have to somehow get the remote control events...

Anyway, the code with Hotkeys:

;based on original code by Manadar
Local $timer
Local $lastSentKey

HotKeySet("{NumPad1}", "SendKey1")
HotKeySet("{NumPad2}", "SendKey2")
HotKeySet("{NumPad3}", "SendKey3")
HotKeySet("{NumPad4}", "SendKey4")
HotKeySet("{NumPad5}", "SendKey5")
HotKeySet("{NumPad6}", "SendKey6")
HotKeySet("{NumPad7}", "SendKey7")
HotKeySet("{NumPad8}", "SendKey8")
HotKeySet("{NumPad9}", "SendKey9")
HotKeySet("{NumPad0}", "SendKey0")

While 1
    Sleep(100)
WEnd

Func SendKey1()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc(".")
            Send("{BACKSPACE}")
            _send(Asc(","))
        Case Asc(",")
            Send("{BACKSPACE}")
            _send(Asc("@"))
        Case Asc("@")
            Send("{BACKSPACE}")
            _send(Asc("."))
        Case Else
            _send(Asc("."))
    EndSwitch
EndFunc

Func SendKey2()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("A")
            Send("{BACKSPACE}")
            _send(Asc("B"))
        Case Asc("B")
            Send("{BACKSPACE}")
            _send(Asc("C"))
        Case Asc("C")
            Send("{BACKSPACE}")
            _send(Asc("a"))
        Case Asc("a")
            Send("{BACKSPACE}")
            _send(Asc("b"))
        Case Asc("b")
            Send("{BACKSPACE}")
            _send(Asc("c"))
        Case Asc("c")
            Send("{BACKSPACE}")
            _send(Asc("2"))
        Case Asc("2")
            Send("{BACKSPACE}")
            _send(Asc("A"))
        Case Else
            _send(Asc("A"))
    EndSwitch
EndFunc

Func SendKey3()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("D")
            Send("{BACKSPACE}")
            _send(Asc("E"))
        Case Asc("E")
            Send("{BACKSPACE}")
            _send(Asc("F"))
        Case Asc("F")
            Send("{BACKSPACE}")
            _send(Asc("d"))
        Case Asc("d")
            Send("{BACKSPACE}")
            _send(Asc("e"))
        Case Asc("e")
            Send("{BACKSPACE}")
            _send(Asc("f"))
        Case Asc("f")
            Send("{BACKSPACE}")
            _send(Asc("3"))
        Case Asc("3")
            Send("{BACKSPACE}")
            _send(Asc("D"))
        Case Else
            _send(Asc("D"))
    EndSwitch
EndFunc

Func SendKey4()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("G")
            Send("{BACKSPACE}")
            _send(Asc("H"))
        Case Asc("H")
            Send("{BACKSPACE}")
            _send(Asc("I"))
        Case Asc("I")
            Send("{BACKSPACE}")
            _send(Asc("g"))
        Case Asc("g")
            Send("{BACKSPACE}")
            _send(Asc("h"))
        Case Asc("h")
            Send("{BACKSPACE}")
            _send(Asc("i"))
        Case Asc("i")
            Send("{BACKSPACE}")
            _send(Asc("4"))
        Case Asc("4")
            Send("{BACKSPACE}")
            _send(Asc("G"))
        Case Else
            _send(Asc("G"))
    EndSwitch
EndFunc

Func SendKey5()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("J")
            Send("{BACKSPACE}")
            _send(Asc("K"))
        Case Asc("K")
            Send("{BACKSPACE}")
            _send(Asc("L"))
        Case Asc("L")
            Send("{BACKSPACE}")
            _send(Asc("j"))
        Case Asc("j")
            Send("{BACKSPACE}")
            _send(Asc("k"))
        Case Asc("k")
            Send("{BACKSPACE}")
            _send(Asc("l"))
        Case Asc("l")
            Send("{BACKSPACE}")
            _send(Asc("5"))
        Case Asc("5")
            Send("{BACKSPACE}")
            _send(Asc("J"))
        Case Else
            _send(Asc("J"))
    EndSwitch
EndFunc

Func SendKey6()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("M")
            Send("{BACKSPACE}")
            _send(Asc("N"))
        Case Asc("N")
            Send("{BACKSPACE}")
            _send(Asc("O"))
        Case Asc("O")
            Send("{BACKSPACE}")
            _send(Asc("m"))
        Case Asc("m")
            Send("{BACKSPACE}")
            _send(Asc("n"))
        Case Asc("n")
            Send("{BACKSPACE}")
            _send(Asc("o"))
        Case Asc("o")
            Send("{BACKSPACE}")
            _send(Asc("6"))
        Case Asc("6")
            Send("{BACKSPACE}")
            _send(Asc("M"))
        Case Else
            _send(Asc("M"))
    EndSwitch
EndFunc

Func SendKey7()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("P")
            Send("{BACKSPACE}")
            _send(Asc("Q"))
        Case Asc("Q")
            Send("{BACKSPACE}")
            _send(Asc("R"))
        Case Asc("R")
            Send("{BACKSPACE}")
            _send(Asc("S"))
        Case Asc("S")
            Send("{BACKSPACE}")
            _send(Asc("p"))
        Case Asc("p")
            Send("{BACKSPACE}")
            _send(Asc("q"))
        Case Asc("q")
            Send("{BACKSPACE}")
            _send(Asc("r"))
        Case Asc("r")
            Send("{BACKSPACE}")
            _send(Asc("s"))
        Case Asc("s")
            Send("{BACKSPACE}")
            _send(Asc("7"))
        Case Asc("7")
            Send("{BACKSPACE}")
            _send(Asc("P"))
        Case Else
            _send(Asc("P"))
    EndSwitch
EndFunc

Func SendKey8()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("T")
            Send("{BACKSPACE}")
            _send(Asc("U"))
        Case Asc("U")
            Send("{BACKSPACE}")
            _send(Asc("V"))
        Case Asc("V")
            Send("{BACKSPACE}")
            _send(Asc("t"))
        Case Asc("t")
            Send("{BACKSPACE}")
            _send(Asc("u"))
        Case Asc("u")
            Send("{BACKSPACE}")
            _send(Asc("v"))
        Case Asc("v")
            Send("{BACKSPACE}")
            _send(Asc("8"))
        Case Asc("8")
            Send("{BACKSPACE}")
            _send(Asc("T"))
        Case Else
            _send(Asc("T"))
    EndSwitch
EndFunc

Func SendKey9()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc("W")
            Send("{BACKSPACE}")
            _send(Asc("X"))
        Case Asc("X")
            Send("{BACKSPACE}")
            _send(Asc("Y"))
        Case Asc("Y")
            Send("{BACKSPACE}")
            _send(Asc("Z"))
        Case Asc("Z")
            Send("{BACKSPACE}")
            _send(Asc("w"))
        Case Asc("w")
            Send("{BACKSPACE}")
            _send(Asc("x"))
        Case Asc("x")
            Send("{BACKSPACE}")
            _send(Asc("y"))
        Case Asc("y")
            Send("{BACKSPACE}")
            _send(Asc("z"))
        Case Asc("z")
            Send("{BACKSPACE}")
            _send(Asc("9"))
        Case Asc("9")
            Send("{BACKSPACE}")
            _send(Asc("W"))
        Case Else
            _send(Asc("W"))
    EndSwitch
EndFunc

Func SendKey0()
    If TimerDiff($timer) > 1200 Then
        $lastSentKey = ""
    EndIf

    Switch $lastSentKey
        Case Asc(" ")
            Send("{BACKSPACE}")
            _send(Asc("0"))
        Case Asc("0")
            Send("{BACKSPACE}")
            _send(Asc(" "))
        Case Else
            _send(Asc(" "))
    EndSwitch
EndFunc

Func _send($key)
    $timer = TimerInit()
    Send(Chr($key))
    $lastSentKey = $key
EndFunc

try using the NumPad keys, it may not be comfortable on that keypad, but it's upside down on a remote control...

Edited by AoRaToS

s!mpL3 LAN Messenger

Current version 2.9.9.1 [04/07/2019]

s!mpL3 LAN Messenger.zip

s!mpL3

Link to comment
Share on other sites

Seemed convenient to have so I wrote it. Code to handle remote control you can write yourself, since that is probably vendor specific - and I don't have a remote of your vendor, neither do I have an IR receiver of your vendor. Now go buy Wireless mouse/keyboard. 8)

; definitions of keys to push. They go from 0-9 based on displayed order.
Local $sms[10] = [" 0", ".,?!'", "abc2ä", "def3", "ghi4", "jkl5", "mno6", "pqrs7", "tuv8", "wxyz9"]

Local $timer
Local $lastSentKey

; Set all keys 0 to 9 as the hotkey to the same function
For $i = 0 To 9
    $key = String($i)
    ; HotKeySet($key, "HotKeyHandler") ; If you want to use this, then also check out comment in _SendKey
    HotKeySet("{NUMPAD" & $key & "}", "HotKeyHandler")
Next

While 1
    Sleep(500)
WEnd

Func HotKeyHandler()
    ; Get real key that is pressed. For {NUMPAD7} the expected result is 7
    $pressedKey = @HotKeyPressed
    If StringInStr($pressedKey, "NUMPAD") Then
        $pressedKey = StringMid($pressedKey, 8, 1)
    EndIf
    ConsoleWrite("Key pressed: " & $pressedKey & @CRLF)

    ; Time out on last key sent
    If TimerDiff($timer) > 800 Then
        ; Last sent key no longer counts
        $lastSentKey = ""

        ; Simple route, just send left most key
        _SendKey(StringLeft($sms[$pressedKey], 1))
    Else
        ; If the last key sent is in the part for the current key, then pick the next
        If StringInStr($sms[$pressedKey], $lastSentKey) Then
            Send("{BACKSPACE}")

            $n = StringInStr($sms[$pressedKey], $lastSentKey) + 1
            _SendKey(StringMid($sms[$pressedKey], $n, 1))
        Else
            ; Otherwise normal route
            _SendKey(StringLeft($sms[$pressedKey], 1))
        EndIf
    EndIf
EndFunc

Func _SendKey($key)
    #cs
    ; Commented out code is not necessary until you add regular keys 0-9 to input
    ; This is untested

    $unbindHotkey = False
    If Number($key) <> $key Then
        $unbindHotkey = True
    EndIf

    If $unbindHotkey Then
        HotKeySet($key)
    EndIf
    #ce

    $lastSentKey = $key
    Send($key)
    $timer = TimerInit()

    #cs
    If $unbindHotkey Then
        HotKeySet($key, "HotkeyHandler")
    EndIf
    #ce
EndFunc
Link to comment
Share on other sites

Another interesting thought, would be to have a tooltip that shows the selected key list (etc. "pqrs7") and have the selected character in bold so that you know where you are in the list, shouldn't be hard to code...

; definitions of keys to push. They go from 0-9 based on displayed order.
Local $sms[10] = [" 0", ".,?!'", "abc2ä", "def3", "ghi4", "jkl5", "mno6", "pqrs7", "tuv8", "wxyz9"]

Local $timer
Local $lastSentKey

; Set all keys 0 to 9 as the hotkey to the same function
For $i = 0 To 9
    $key = String($i)
    ; HotKeySet($key, "HotKeyHandler") ; If you want to use this, then also check out comment in _SendKey
    HotKeySet("{NUMPAD" & $key & "}", "HotKeyHandler")
Next

While 1
    Sleep(500)
WEnd

Func HotKeyHandler()
    ; Get real key that is pressed. For {NUMPAD7} the expected result is 7
    $pressedKey = @HotKeyPressed
    If StringInStr($pressedKey, "NUMPAD") Then
        $pressedKey = StringMid($pressedKey, 8, 1)
    EndIf
    ConsoleWrite("Key pressed: " & $pressedKey & @CRLF)

    ; Time out on last key sent
    If TimerDiff($timer) > 800 Then
        ; Last sent key no longer counts
        $lastSentKey = ""

        ; Simple route, just send left most key
        _SendKey(StringLeft($sms[$pressedKey], 1), $sms[$pressedKey])
    Else
        ; If the last key sent is in the part for the current key, then pick the next
        If StringInStr($sms[$pressedKey], $lastSentKey) Then
            Send("{BACKSPACE}")

            $n = StringInStr($sms[$pressedKey], $lastSentKey) + 1
            _SendKey(StringMid($sms[$pressedKey], $n, 1), $sms[$pressedKey])
        Else
            ; Otherwise normal route
            _SendKey(StringLeft($sms[$pressedKey], 1), $sms[$pressedKey])
        EndIf
    EndIf
EndFunc

Func _SendKey($key, $keyGroup)
    #cs
    ; Commented out code is not necessary until you add regular keys 0-9 to input
    ; This is untested
g
    $unbindHotkey = False
    If Number($key) = $key Then
        $unbindHotkey = True
    EndIf

    If $unbindHotkey Then
        HotKeySet($key)
    EndIf
    #ce

    $lastSentKey = $key
    Send($key)
    $timer = TimerInit()

    $n = StringInStr($keyGroup, $key)-1
    $show = StringLeft($keyGroup, $n) & "[" & $key & "]" & StringTrimLeft($keyGroup, $n+1)
    ToolTip($show)

    #cs
    If $unbindHotkey Then
        HotKeySet($key, "HotkeyHandler")
    EndIf
    #ce
EndFunc
Edited by Manadar
Link to comment
Share on other sites

Thank you so much for help and support. I tried and tested the code you wrote for this and it works almost perfectly :-) Great. I do not really understand all steps but try to get deeper the next days.

One thing I found is that the characters are deleted after finishing one Groüp. Menas e.g. if you press 2 then a,b,c,2 appears and then backspace which deletes of course the last character. Is it possible not to do this but repeat again the characters?

Regards,

B

Link to comment
Share on other sites

Hi again,

sorry for asking again. My Remote is hard Coded to the 0-9 keys. There's no possibility to change it to the numpad keys. So I have to use it instead od numkeys. What I did is to change the hotkeyset from numbad to number keys which looks like

; definitions of keys to push. They go from 0-9 based on displayed order.
Local $sms[10] = [" 0", "1.,?!'", "abc2ä", "def3", "ghi4", "jkl5", "mno6", "pqrs7", "tuv8", "wxyz9"]

Local $timer
Local $lastSentKey

; Set all keys 0 to 9 as the hotkey to the same function
For $i = 0 To 9
    $key = String($i)
    HotKeySet($key, "HotKeyHandler") ; If you want to use this, then also check out comment in _SendKey
Next

While 1
    Sleep(500)
WEnd

Func HotKeyHandler()
    ; Get real key that is pressed. For {NUMPAD7} the expected result is 7
    $pressedKey = @HotKeyPressed
    If StringInStr($pressedKey, "NUMPAD") Then
        $pressedKey = StringMid($pressedKey, 8, 1)
    EndIf
    ConsoleWrite("Key pressed: " & $pressedKey & @CRLF)

    ; Time out on last key sent
    If TimerDiff($timer) > 800 Then
        ; Last sent key no longer counts
        $lastSentKey = ""

        ; Simple route, just send left most key
        _SendKey(StringLeft($sms[$pressedKey], 1), $sms[$pressedKey])
    Else
        ; If the last key sent is in the part for the current key, then pick the next
        If StringInStr($sms[$pressedKey], $lastSentKey) Then
            Send("{BACKSPACE}")

            $n = StringInStr($sms[$pressedKey], $lastSentKey) + 1
            _SendKey(StringMid($sms[$pressedKey], $n, 1), $sms[$pressedKey])
        Else
            ; Otherwise normal route
            _SendKey(StringLeft($sms[$pressedKey], 1), $sms[$pressedKey])
        EndIf
    EndIf
EndFunc



Func _SendKey($key, $keyGroup)

    $lastSentKey = $key
    Send($key)
    $timer = TimerInit()

    $n = StringInStr($keyGroup, $key)-1
    $show = StringLeft($keyGroup, $n) & "[" & $key & "]" & StringTrimLeft($keyGroup, $n+1)
    ToolTip($show)

EndFunc

The Problem now is that it does not work lieke the version with numpad keys and I do not find out why. If entering the number then all letters are set as they should but then there's a backspace after the last letter. Moreover sfter starting the script the 0 does not work.

Perhaps someone has an idea. Thank you again

Regards,

B

Edit:

I read the comment: ; If you want to use this, then also check out comment in _SendKey but this did not change it and I think this is only importnat if using numbad and numbers, is it?

Edited by bentom
Link to comment
Share on other sites

No, the comments were quite correct. I also commented that this method was untested. Looking back at the code, I see that this code makes no sense:

$unbindHotkey = False
    If Number($key) <> $key Then
        $unbindHotkey = True
    EndIf

The key should be unbound if it IS the same, not if it isn't. So change the above code to:

$unbindHotkey = False
    If Number($key) = $key Then
        $unbindHotkey = True
    EndIf

And it works.

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...