3

I have a dictionary that contains Letters and Digits and i can get the values of the letter keys just fine but not the ones from digits even though they're enclosed in " . It isn't important for the question but just in case you're wondering what the bluscream.ahk file that's included looks like: https://github.com/Bluscream/ahk-scripts/blob/master/Lib/bluscream.ahk

I tried what can be seen in the code. I have no idea what to do

; Version 1
; Date 02/02/2019
#Include <bluscream>
#SingleInstance Force
Process Priority,, Below Normal
SetWorkingDir %A_ScriptDir%
#Warn
#Persistent
SetKeyDelay, 150
game_name := "LEGO" ; LEGO Jurassic World
game_title := "ahk_class TTalesWindow" ; ahk_exe LEGOJurassicWorld_DX11.EXE

chars := { "B" : "{Up}", "C" : "{Up 2}", "D" : "{Up 3}", "E" : "{Up 4}", "F" : "{Up 5}", "G" : "{Up 6}", "H" : "{Up 7}", "J" : "{Up 8}", "K" : "{Up 9}", "L" : "{Up 10}", "M" : "{Up 11}", "N" : "{Up 12}", "O" : "{Up 13}", "P" : "{Up 14}", "Q" : "{Up 15}", "R" : "{Up 16}", "S" : "{Down 18}", "T" : "{Down 17}", "U" : "{Down 16}", "V" : "{Down 15}", "W" : "{Down 14}", "X" : "{Down 13}", "Y" : "{Down 12}", "Z" : "{Down 11}", "0" : "{Down 10}", "1" : "{Down 9}", "2" : "{Down 8}", "3" : "{Down 7}", "4" : "{Down 6}", "5" : "{Down 5}", "6" : "{Down 4}", "7" : "{Down 3}", "8" : "{Down 2}", "9" : "{Down}" }

file := "codes.txt"

global noui := false
scriptlog("Started logging here...")

FileRead, LoadedText, %file%
codes := StrSplit(LoadedText, "`n", "`r")


Loop, % codes.MaxIndex()
{
    if !(WinActive(game_title)) {
        TrayTip, AutoHotKey, Bringing %game_name% to front to enter code...
        Sleep, 1000
        WinWaitActive, %game_title%
    }

    code := StrStrip(codes[A_Index])
    length := StrLen(code)
    FormatTime, timestamp, A_Now, hh:mm:ss
    scriptlog("[" . timestamp . "] Now processing code: " . code . " [" . length . "] (`r`n", "", true)
    splitted_code := StrSplit(code)
    for i, char in splitted_code {
        tosend := chars[char]
        scriptlog("i:" . i . " char:" . char . " tosend:" . tosend . "`r`n", "", true)
        if (tosend){
            SendEvent, % tosend
        }
        if (i < length)
            SendInput, {Right}
    }
    scriptlog(")`r`n","",true)
    SendInput, {Enter}
}

Expected results:

[11:17:43] Started logging here...
[11:17:46] Now processing code: 28SPSR [6] (
i:1 char:2 tosend:{Down 8}
i:2 char:8 tosend:{Down 2}
i:3 char:S tosend:{Down 18}
i:4 char:P tosend:{Up 14}
i:5 char:S tosend:{Down 18}
i:6 char:R tosend:{Up 16}
)

Actual Results:

[11:17:43] Started logging here...
[11:17:46] Now processing code: 28SPSR [6] (
i:1 char:2 tosend:
i:2 char:8 tosend:
i:3 char:S tosend:{Down 18}
i:4 char:P tosend:{Up 14}
i:5 char:S tosend:{Down 18}
i:6 char:R tosend:{Up 16}
)
Bluescream
  • 261
  • 1
  • 8

1 Answers1

1

Looks like a bug of the object declaration. A problem about string vs numbers.

Using numbers without quotes removes the problem.

But also, doing this after declaring the object fixes the problem too:

for k,v in chars
    chars[k] := v

You could fill a bug on the official board: https://www.autohotkey.com/boards/

scso
  • 415
  • 7
  • 9