me2d13 / luamacros

665 stars 87 forks source link

Enter issues #33

Closed jellewie closed 6 years ago

jellewie commented 6 years ago

There seems to be an enter issue, and I managed to track it down and make it consistent. Code is below.

Input given to keyboard

a b c helloworld h

Feedback from program:

data: a~ data: b~ data: c~ data: helloworld~ data: h~

What the program does:

a b c helloworld helloworld

It seems to search for an already printed string and autocomplete to that and send that instead

What I suspected that it would do: Not to autocomplete and send the string I have given with just the character 'h' with an enter

`-- get luamacros HERE: http://www.hidmacros.eu/forum/viewtopic.php?f=10&t=241#p794 -- plug in your 2nd keyboard, load this script into LUAmacros, and press the triangle PLAY button. -- Then, press any key on that keyboard to assign logical name ('MACROS') to macro keyboard clear() --clear the console from last run

local keyboardIdentifier = '2A1CBAB5'

BarCodeScanner1 = ''

print(BarCodeScanner1)

if keyboardIdentifier == '0000AAA' then --if this key is pressed by a known scanner lmc_assign_keyboard('MACROS'); --just do the input else lmc_device_set_name('MACROS', keyboardIdentifier); --execute scanner code end --This lists connected keyboards dev = lmc_get_devices() for key,value in pairs(dev) do print(key..':') for key2,value2 in pairs(value) do print(' '..key2..' = '..value2) end end
print('You need to get the identifier code for the keyboard with name "MACROS"') print('Then replace the first 0000AAA value in the code with it. This will prevent having to manually identify keyboard every time.') -- Hide window to tray to keep taskbar tidy
lmc.minimizeToTray = true --lmc_minimize()

local config = {

[65]  = "a",
[13]  = "Enter",    --Enter

[string.byte('Q')] = "q",
[string.byte('W')] = "w",
[string.byte('E')] = "e",
[string.byte('R')] = "r",
[string.byte('T')] = "t",
[string.byte('Y')] = "y",
[string.byte('U')] = "u",
[string.byte('I')] = "i",
[string.byte('O')] = "o",
[string.byte('P')] = "p",
[string.byte('A')] = "a",
[string.byte('S')] = "s",
[string.byte('D')] = "d",
[string.byte('F')] = "f",
[string.byte('G')] = "g",
[string.byte('H')] = "h",
[string.byte('J')] = "j",
[string.byte('K')] = "k",
[string.byte('L')] = "l",
[string.byte('Z')] = "z",
[string.byte('X')] = "x",
[string.byte('C')] = "c",
[string.byte('V')] = "v",
[string.byte('B')] = "b",
[string.byte('N')] = "n",
[string.byte('M')] = "m",

[string.byte('0')] = "0",
[string.byte('1')] = "1",
[string.byte('2')] = "2",
[string.byte('3')] = "3",
[string.byte('4')] = "4",
[string.byte('5')] = "5",
[string.byte('6')] = "6",
[string.byte('7')] = "7",
[string.byte('8')] = "8",
[string.byte('9')] = "9",

--[255] = "printscreen" --these keys do not work

}

function wait(seconds) local _start = os.time() local _end = _start+seconds while (_end ~= os.time()) do end end

-- define callback for whole device lmc_set_handler('MACROS', function(button, direction) if (direction == 0) then return end -- ignore key upstrokes. if type(config[button]) == "string" then --print(' ') --print('Your key ID number is: ' .. button) --print('It was assigned string: ' .. config[button])

    if button == 13 then
        BarCodeScanner1 = '' .. BarCodeScanner1 .. '~'
        print('data:    ' .. BarCodeScanner1)
        lmc_send_keys(BarCodeScanner1)
        BarCodeScanner1 = ''
    else
        BarCodeScanner1 = BarCodeScanner1 .. config[button]
    end 
else
            print(' ')
            print('Not yet assigned: ' .. button)
end

end) `

jellewie commented 6 years ago

Notepad++ functionality, my bad