Page 1 of 1

Function keys (F1, F2, etc...) not being blocked on 2nd KB?

Posted: 26 Feb 2016, 22:13
by taran
For my second keyboard that I am setting up, I can't figure out how to block the function keys. They pass through, even while the other keystrokes do not. Here is my code:

Code: Select all

-- assign logical name to macro keyboard
lmc_assign_keyboard('MACROS');

taran = function (key)
      print(key)
      local file = io.open("C:\\Users\\TaranVanHemert\\Documents\\test2.txt", "w")
      print("we are inside the text file")
      file:write(key)
      file:flush()
      file:close()
      lmc_send_keys('{F24}')
end     


lmc_set_handler('MACROS',function(button, direction)
  if (direction == 1) then return end  -- ignore down
  --if     (button == string.byte('C')) then lmc_spawn("calc")
  if (button == 45) then taran('insert')
  elseif (button == 36) then taran('home')
  elseif (button == 33) then taran('pageup')
  elseif (button == 46) then taran('delete')
  elseif (button == 35) then taran('end')
  elseif (button == 34) then taran('pagedown')

  elseif (button == 27) then taran('escape')

  elseif (button == 112) then taran('F1')
  elseif (button == 113) then taran('F2')
  elseif (button == 114) then taran('F3')
  elseif (button == 115) then taran('F4')
  elseif (button == 116) then taran('F5')
  elseif (button == 117) then taran('F6')
  elseif (button == 118) then taran('F7')
  elseif (button == 119) then taran('F8')
  elseif (button == 120) then taran('F9')
  elseif (button == 121) then taran('F10')
  elseif (button == 122) then taran('F11')
  elseif (button == 123) then taran('F12')

  elseif (button == string.byte('Q')) then taran('q')
  elseif (button == string.byte('W')) then taran('w')
  elseif (button == string.byte('E')) then taran('e')
  elseif (button == string.byte('R')) then taran('r')
  elseif (button == string.byte('T')) then taran('t')
  elseif (button == string.byte('Y')) then taran('y')
  --and so on...
  else print('Not yet assigned: ' .. button)
  end
end)    
This will basically send a string to AutoHotkey, which will then engage the appropriate function.

I am really quite bad at code, and have only barely been able to kludge this together. Still, it seems to work for ALL other keys except the function keys.

Oh, and Prt Scr is also gettting through without being blocked.
I am not sure about Scroll lock and Pause Break. I don't know how to test those...

Bug?

Also, luamacros was letting ALL keystrokes through, yesterday... even with just the sample script. it only resolved itself when I restarted the computer.

Re: Function keys (F1, F2, etc...) not being blocked on 2nd

Posted: 29 Feb 2016, 09:00
by admin
Hmm, no idea :-(
Hard to fix something I cannot reproduce. My functional keys are blocked as well.
Maybe I can somehow improve logging to see what goes wrong.