Question about left control and F13

Announcements, questions
Post Reply
Onyxius
Posts: 3
Joined: 21 Jan 2022, 07:25

Question about left control and F13

Post by Onyxius » 21 Jan 2022, 07:55

Hello,
So I received my motospeed keybad in the mail today and started working away at installing and writing some lua scripts into LuaMacros. I have the general keybinding working so far to go up to F24. Now I would like to cycle those F 13 through F24 again with modifiers like left or right control + f13 - 24.

The issue I am having is with the num key on the keypad, while i have it set in the lua code to be left control and F13, it still turns on and off the numlock. I'm having trouble figuring out how to ignore the numlock funcion of the keypress. This is what i have so far, how do i ignore the numlock key function?

Code: Select all

-- These 2 lines will minimize the script automatically at launch.
--lmc.minimizeToTray = true
--lmc_minimize()

-- assign name to external keyboard
lmc_device_set_name ('KP', 'MyKeypadId');

-- define callback for whole device
lmc_set_handler('KP',function(button, direction)
  if (direction == 1) then return end  -- ignore down
  if     (button == 96) then lmc_send_keys('{F13}')
  elseif (button == 110) then lmc_send_keys('{F14}')
  elseif (button == 13) then lmc_send_keys('{F15}')
  elseif (button == 97) then lmc_send_keys('{F16}')
  elseif (button == 98) then lmc_send_keys('{F17}')
  elseif (button == 99) then lmc_send_keys('{F18}')
  elseif (button == 100) then lmc_send_keys('{F19}')
  elseif (button == 101) then lmc_send_keys('{F20}')
  elseif (button == 102) then lmc_send_keys('{F21}')
  elseif (button == 103) then lmc_send_keys('{F22}')
  elseif (button == 104) then lmc_send_keys('{F23}')
  elseif (button == 105) then lmc_send_keys('{F24}')
  elseif (button == 144) then lmc_send_keys('^{F13}')


  else print('Not yet assigned: ' .. button)
  end
end)

Onyxius
Posts: 3
Joined: 21 Jan 2022, 07:25

Re: Question about left control and F13

Post by Onyxius » 22 Jan 2022, 06:00

So I happened to come across another script from DX while trying to look for a solution and I think I like this script more. The same issue applies however with wanting to disable the numlock on and off ability and still be able to use it as an actual key or even a constant modifier. This way I can use all of the other keys and add more when i hit numlock and another key as well. Now, I know there are 2 options in the script, one is use setting mode and the other is USE Mode. Setting mode seems to let me use a modifier key but then the keypad on my regular keyboard activate the buttons just like the other keypad which would make having a separate keypad useless unless i'm misunderstanding the code.

Code: Select all

--By: DX
--Twitter: twitter.com/DX_Nacca
--Twitch: twitch.tv/dx___
--YouTube: youtube.com/canal0gamers


--Activates the setting [ true / false ]
setting = false

--device ID
device = 'A87484A'

--Automatically minimize [ true / false ]

--when minimize go to Tray [ true / false ]
lmc.minimizeToTray = true

keys = {}
-- Add the commands here --


-- Num Lock off --
keys[33]  = '+{F13}' --Numpad 9
keys[38]  = '+{F14}' --Numpad 8
keys[36]  = '+{F15}' --Numpad 7
keys[39]  = '+{F16}' --Numpad 6
keys[12]  = '+{F17}' --Numpad 5
keys[37]  = '+{F18}' --Numpad 4
keys[34]  = '+{F19}' --Numpad 3
keys[40]  = '+{F20}' --Numpad 2
keys[35]  = '+{F21}' --Numpad 1
keys[45]  = '+{F22}' --Numpad 0
keys[46]  = '+{F23}' --Numpad .


-- Num Lock on --
keys[105] = '+{F13}' --Numpad 9
keys[104] = '+{F14}' --Numpad 8
keys[103] = '+{F15}' --Numpad 7
keys[102] = '+{F16}' --Numpad 6
keys[101] = '+{F17}' --Numpad 5
keys[100] = '+{F18}' --Numpad 4
keys[99]  = '+{F19}' --Numpad 3
keys[98]  = '+{F20}' --Numpad 2
keys[97]  = '+{F21}' --Numpad 1
keys[96]  = '+{F22}' --Numpad 0
keys[110] = '+{F23}' --Numpad .


-- Numpad --
keys[48]  = '+{F24}' --Numpad 000
keys[13]  = '^{F13}' --Enter
keys[107] = '^{F14}' --[ + ]
keys[109] = '^{F15}' --[ - ]
keys[8]   = '^{F16}' --Backspace
keys[106] = '^{F17}' --[ * ]
keys[111] = '^{F18}' --[ / ]
keys[9]   = '^{F19}' --Tab



---------- Dont touch ----------
if( minimize ) then
    lmc_minimize()
end
inicio = false
if(device == '') then
    lmc_assign_keyboard('MACROS')
    dev = lmc_get_devices()
    for key,value in pairs(dev) do
        if( value["Name"] == 'MACROS' )   then
            id= string.sub(string.match(value["SystemId"],"#[0-9a-zA-Z]&[0-9a-zA-Z]*"),4,-1)
            print("device = '"..id.."'")
            inicio = true
        end
    end
else
	lmc_device_set_name('MACROS',device)
	inicio = true
end

if(inicio) then
	if( setting ) then
		print("-------------[ SETTING MODE ]-------------")
		temp=false
		modifire={'+','^','%'}
		lmc_set_handler('MACROS',function(button, direction)
			if (direction == 1) then return end
			if ( keys[button] == nil and temp) then
				c=0
				tt=true
				while tt do
					f=true
					t= modifire[math.floor(c/12)+1] .. "{F" .. (c%12 + 13) .. "}"
					for i,v in pairs(keys) do
						if( v == t ) and f then
							f=false
						end
					end
					if( f ) then
						tt=false
						keys[button]=t
						print("keys["..button.."]"..string.rep(" ",4-string.len(tostring(button))).. "= '"..t.."' --")
					else
						c=c+1
					end
				end
			end
			temp = true
		end)


	else
		print("-------------[ USE MODE ]-------------")
		lmc_set_handler('MACROS',function(button, direction)
		   if (direction == 1) then return end
		   if ( keys[button] == nil )  then
			  print('key undefined: ' .. button)
		   else
			   lmc_send_keys(keys[button], 10)
		   end
		end)
	end
else
	print("The device was not found")
end

Onyxius
Posts: 3
Joined: 21 Jan 2022, 07:25

Re: Question about left control and F13

Post by Onyxius » 07 Feb 2022, 05:25

Is this forum dead? Is there another location to get assistance?

admin
Site Admin
Posts: 725
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Question about left control and F13

Post by admin » 14 Feb 2022, 09:07

Almost dead.
It's not clear to me from your description what you're trying to achieve.
In general for such fine tuning I recommend use lmc_send_input over lmc_send_keys. Send keys may have bugs and you have more control with send input (down/up calls, keys with flags etc).
Petr Medek
LUAmacros author

Post Reply