Big Issue, Lua doesn't work when OBS is in the focus

Announcements, questions
Post Reply
4Sol
Posts: 3
Joined: 23 Sep 2020, 19:02

Big Issue, Lua doesn't work when OBS is in the focus

Post by 4Sol » 23 Sep 2020, 19:12

Hello there!

I actually have 2 problems:

1. When OBS is in FOCUS Lua doesn't work.
E.G. I set NUM5 to be ^+F1, but when OBS is in the FOCUS triggering Numpad's NUM5 gives just a regular NUM5 value of 5.
Like as I did this on the main keyboard. But If I press NUM5 out of OBS focus it would trigger correct combination of ^+F1.

How to solve it?
How to make OBS/Win to do not "see" NUM5 when you press it on the Lua keyboard?

2. NUM5 is NUM5.
When you use Lua NUM5 (^+F1) OBS/Win understand it as NUM5 and only then as ^+F1
So if you have a hotkey on the NUM5 of your main keyboard and you set your extra NUM5 to be ^+F1 - OBS will execute NUM5 and then ^+F1, when you trigger Extra NUM5.

Any solution?

This 2 problems existing together and I would appreciate for any feedback.

Thank you!

Code: Select all

lmc_device_set_name('streamdeck','12E34091')
lmc_print_devices()
lmc.minimizeToTray = true

lmc_set_handler('streamdeck', function(button,direction)
  if (direction == 1) then return end
  if (button == 13) then   

    elseif (button == 101) then                        -- 5
    lmc_send_keys('^+{F5}', 50)     

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

Re: Big Issue, Lua doesn't work when OBS is in the focus

Post by admin » 24 Sep 2020, 08:02

I don't have OBS (even don't know what it is) but by the description provided I would say it reads keyboard directly so blocking of original key doesn't work in this application. There's nothing I can do about it. Some explanation is here: https://github.com/me2d13/luamacros/wik ... -keyboards
Petr Medek
LUAmacros author

4Sol
Posts: 3
Joined: 23 Sep 2020, 19:02

Re: Big Issue, Lua doesn't work when OBS is in the focus

Post by 4Sol » 24 Sep 2020, 09:14

admin wrote:
24 Sep 2020, 08:02
I don't have OBS (even don't know what it is) but by the description provided I would say it reads keyboard directly so blocking of original key doesn't work in this application. There's nothing I can do about it. Some explanation is here: https://github.com/me2d13/luamacros/wik ... -keyboards
Thank you for the answer.
All the idea behind using Lua with extra Num Pad is to build a stream deck. (to change scenes in OBS, trigger some gifs in OBS, sounds, etc.)

I guess the only solution will be to buy a streamer deck, with a custom software which will program "empty" buttons to what you need. Looking like this:
Image
It would be great if windows had a bigger amount of input numbers. Like F20, F21, F22 ... but hidden

Anyway it's too expensive and unavailable in my country.

BTW OBS (Open Broadcaster Software) is a streaming software. Looking like this:
Image

The other solution will be to buy a QMK keypad, like this one:
https://aliexpress.ru/item/4000510880374.html
But I'm too stupid to programme all the stuff and I'm not even sure it will work correctly.

foggydude
Posts: 1
Joined: 06 Oct 2020, 12:50

Re: Big Issue, Lua doesn't work when OBS is in the focus

Post by foggydude » 06 Oct 2020, 12:55

I have the opposite problem

i have a second numpad and with luamacros i have remapped those keys to function keys (f13-f24 and CTRL+alt+f3 etc).
In obs i have set those keys to trigger scene switches. but

- if obs is infocus = it works
- if obs is out of focus = it does not work

NB: the leys on my other keyboard ( or if i disable luamacros) it also works when obs is out of focus. how to solve?

Code: Select all

lmc.minimizeToTray = true
lmc_minimize()


--lmc_print_devices()   -- get the ID of the second keyboard from the stack that this line creates
lmc_device_set_name('MACROS1', "ID_1010") -- substitute the ID you have found here
-- lmc_assign_keyboard('MACROS1') -- if Lua doesn't work try adding this line

-- define callback for whole device, assign each key of the keyboard to an imaginary key (usually, keyboards have F1-F12, so we start assigning keys to F13)
lmc_set_handler('MACROS1',function(button, direction)
if (direction == 1) then return end  -- ignore down; if you want to be able to type the original letters as well with the secondary keyboard, remove this line
  if     (button == 45) then lmc_send_keys('{F13}')
 elseif (button == 35) then lmc_send_keys('^x')
  --elseif (button == 35) then lmc_send_keys('{F14}')
elseif (button == 40) then lmc_send_keys('^c')
  --elseif (button == 40) then lmc_send_keys('{F15}')
elseif (button == 34) then lmc_send_keys('^v')
  --elseif (button == 34) then lmc_send_keys('{F16}')
  elseif (button == 46) then lmc_send_keys('{F17}')
  elseif (button == 13) then lmc_send_keys('{F18}')
  elseif (button == 37) then lmc_send_keys('{F19}')
  elseif (button == 12) then lmc_send_keys('{F20}')
  elseif (button == 39) then lmc_send_keys('{F21}')
  elseif (button == 8) then lmc_send_keys('{F22}')
  elseif (button == 36) then lmc_send_keys ('{F23}')
  elseif (button == 38) then lmc_send_keys('{F24}')
  elseif (button == 33) then lmc_send_keys('^+{F15}')
  elseif (button == 107) then lmc_send_keys('^+{F16}')
  elseif (button == 144) then lmc_send_keys('^+{F17}')
  elseif (button == 111) then lmc_send_input(179, 0, 0) -- Press Play/Pause
  elseif (button == 106) then lmc_send_input(176, 0, 0) -- Press Next Track
  elseif (button == 109) then lmc_spawn("spotify")
  else print('Not yet assigned: ' .. button)
  end
end)

-- if you wanted more keyboards, just repeat line 5 with its id and a assign a new name, like MACROS2.
-- then repeat the code that starts in line 9, but change the name to the one you have just assigned.
-- For exemple, to: lmc_set_handler('MACROS2', ...
                                                                                                                    

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

Re: Big Issue, Lua doesn't work when OBS is in the focus

Post by admin » 07 Oct 2020, 08:31

lmc_send_keys just simulated the keypress to it arrives to active application (in focus). How is it suppose to work if your app is not in focus?
Maybe only if it could ready "global hotkeys" (when not in focus) and I'm not sure if that would work with simulated key presses that luamacros triggers...
Petr Medek
LUAmacros author

4Sol
Posts: 3
Joined: 23 Sep 2020, 19:02

Re: Big Issue, Lua doesn't work when OBS is in the focus

Post by 4Sol » 07 Oct 2020, 10:47

foggydude
I'm using ALT+NUM1-9 and CTRL+ALT+F4 (to shut down triggered commands).
Check first with notepad (without OBS)
Like pressing 1-9 on lum-numpad should give you this: ☺☻♥♦♣♠•◘○
F11 should enlarge your browser screen, etc
Some combinations are not working, because they are originally giving you back a beep sound.

For scene switches I'm using main keyboard with CTRL+NUM 1-9

I can give you my code, If you want

Post Reply