title: Luamacros for autohotkey
body: <p>i'm currently using a lua script by taran van hemert,where it save every keypress on text file and autohotkey will detect every keypress based on that text file, and i'm just wondering how i can make shift work on other keys, i mean when i press shift+2 it will display &quot;@&quot; at the text file. does anyone know how to do it?</p>
  <pre><code>-- note that some of the code has changed since then (it works better now!)
  -- Though, I have since abandoned luamacros, in favor of Interception... which i will abandon in favor of QMK.
  -- get luamacros HERE: http://www.hidmacros.eu/forum/viewtopic.php?f=10&amp;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 = '0000AAA'
  
  
  --You need to get the identifier code for the keyboard with name &quot;MACROS&quot;
  --This appears about halfway through the SystemID item and looks like 1BB382AF or some other alphanumeric combo.
  -- It's usually 7 or 8 characters long.
  --Once you have this identifier, replace the value of keyboardIdentifier with it
  
  --Don't ask for keyboard assignment help if the user has manually entered a keyboard identifier
  if keyboardIdentifier == '0000AAA' then
      lmc_assign_keyboard('MACROS');
  else lmc_device_set_name('MACROS', keyboardIdentifier);
  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 &quot;MACROS&quot;')
  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()
  
  --Start Script
  sendToAHK = function (key)
        --print('It was assigned string:    ' .. key)
        local file = io.open(&quot;C:\\Users\\Jhon Ryven\\Desktop\\2nd keyboard macros\\keypressed.txt&quot;, &quot;w&quot;) -- writing this string to a text file on disk is probably NOT the best method. Feel free to program something better!
        --If you didn't put your AutoHotKey scripts into C:/AHK, Make sure to substitute the path that leads to your own &quot;keypressed.txt&quot; file, using the double backslashes.
        --print(&quot;we are inside the text file&quot;)
        file:write(key)
        file:flush() --&quot;flush&quot; means &quot;save.&quot; Lol.
        file:close()
        lmc_send_keys('{F24}')  -- This presses F24. Using the F24 key to trigger AutoHotKey is probably NOT the best method. Feel free to program something better!
  end
  
  local config = {
      [45]  = &quot;insert&quot;,
      [36]  = &quot;home&quot;,
      [33]  = &quot;pageup&quot;,
      [46]  = &quot;delete&quot;,
      [35]  = &quot;end&quot;,
      [34]  = &quot;pagedown&quot;,
      [27]  = &quot;escape&quot;,
      [112] = &quot;F1&quot;,
      [113] = &quot;F2&quot;,
      [114] = &quot;F3&quot;,
      [115] = &quot;F4&quot;,
      [116] = &quot;F5&quot;,
      [117] = &quot;F6&quot;,
      [118] = &quot;F7&quot;,
      [119] = &quot;F8&quot;,
      [120] = &quot;F9&quot;,
      [121] = &quot;F10&quot;,
      [122] = &quot;F11&quot;,
      [123] = &quot;F12&quot;,
      [8]   = &quot;backspace&quot;,
      [220] = &quot;backslash&quot;,
      [13]  = &quot;enter&quot;,
      [16]  = &quot;rShift&quot;,
      [17]  = &quot;rCtrl&quot;,
      [38]  = &quot;up&quot;,
      [37]  = &quot;left&quot;,
      [40]  = &quot;down&quot;,
      [39]  = &quot;right&quot;,
      [32]  = &quot;space&quot;,
      [186] = &quot;semicolon&quot;,
      [222] = &quot;singlequote&quot;,
      [190] = &quot;period&quot;,
      [191] = &quot;slash&quot;,
      [188] = &quot;comma&quot;,
      [219] = &quot;leftbracket&quot;,
      [221] = &quot;rightbracket&quot;,
      [189] = &quot;minus&quot;,
      [187] = &quot;equals&quot;,
      [96]  = &quot;num0&quot;,
      [97]  = &quot;num1&quot;,
      [98]  = &quot;num2&quot;,
      [99]  = &quot;num3&quot;,
      [100] = &quot;num4&quot;,
      [101] = &quot;num5&quot;,
      [102] = &quot;num6&quot;,
      [103] = &quot;num7&quot;,
      [104] = &quot;num8&quot;,
      [105] = &quot;num9&quot;,
  
      [106] = &quot;numMult&quot;,
      [107] = &quot;numPlus&quot;,
      [108] = &quot;numEnter&quot;, --sometimes this is different, check your keyboard
      [109] = &quot;numMinus&quot;,
      [110] = &quot;numDelete&quot;,
      [111] = &quot;numDiv&quot;,
      [144] = &quot;numLock&quot;, --probably it is best to avoid this key. I keep numlock ON, or it has unexpected effects
  
      [192] = &quot;Sc029&quot;,  --this is the tilde key just before the number row
      [9]   = &quot;tab&quot;,
      [20]  = &quot;capslock&quot;,
      [18]  = &quot;alt&quot;,
      [91]  = &quot;winkey&quot;,
  
      [string.byte('Q')] = &quot;q&quot;,
      [string.byte('W')] = &quot;w&quot;,
      [string.byte('E')] = &quot;e&quot;,
      [string.byte('R')] = &quot;r&quot;,
      [string.byte('T')] = &quot;t&quot;,
      [string.byte('Y')] = &quot;y&quot;,
      [string.byte('U')] = &quot;u&quot;,
      [string.byte('I')] = &quot;i&quot;,
      [string.byte('O')] = &quot;o&quot;,
      [string.byte('P')] = &quot;p&quot;,
      [string.byte('A')] = &quot;a&quot;,
      [string.byte('S')] = &quot;s&quot;,
      [string.byte('D')] = &quot;d&quot;,
      [string.byte('F')] = &quot;f&quot;,
      [string.byte('G')] = &quot;g&quot;,
      [string.byte('H')] = &quot;h&quot;,
      [string.byte('J')] = &quot;j&quot;,
      [string.byte('K')] = &quot;k&quot;,
      [string.byte('L')] = &quot;l&quot;,
      [string.byte('Z')] = &quot;z&quot;,
      [string.byte('X')] = &quot;x&quot;,
      [string.byte('C')] = &quot;c&quot;,
      [string.byte('V')] = &quot;v&quot;,
      [string.byte('B')] = &quot;b&quot;,
      [string.byte('N')] = &quot;n&quot;,
      [string.byte('M')] = &quot;m&quot;,
  
      [string.byte('0')] = &quot;0&quot;,
      [string.byte('1')] = &quot;1&quot;,
      [string.byte('2')] = &quot;2&quot;,
      [string.byte('3')] = &quot;3&quot;,
      [string.byte('4')] = &quot;4&quot;,
      [string.byte('5')] = &quot;5&quot;,
      [string.byte('6')] = &quot;6&quot;,
      [string.byte('7')] = &quot;7&quot;,
      [string.byte('8')] = &quot;8&quot;,
      [string.byte('9')] = &quot;9&quot;,
      [255+44] = &quot;printscreen&quot;,
          [145] = &quot;scrolllock&quot;,
  
  }
  
  -- define callback for whole device
  lmc_set_handler('MACROS', function(button, direction)
      --Ignoring upstrokes ensures keystrokes are not registered twice, but activates faster than ignoring downstrokes. It also allows press and hold behaviour
          if (direction == 0) then return end -- ignore key upstrokes.
      if type(config[button]) == &quot;string&quot; then
                  print(' ')
                  print('Your key ID number is:   ' .. button)
                  print('It was assigned string:    ' .. config[button])
                  sendToAHK(config[button])
      else
                  print(' ')
                  print('Not yet assigned: ' .. button)
      end
  end) ```
  </code></pre>