Old 01-10-2019, 03:34 PM   #1
andyp24
Human being with feelings
 
Join Date: Mar 2016
Posts: 584
Default Detect keyboard input in Lua script without GUI

Hi

Is it possible to get a Lua script to react to keyboard presses, but without a GUI?

So, for example, run a script and once it's running, if I press one key it does one thing, and if I press another key it does something else, but without a dialogue box opening, or having to confirm the key press with an OK button or the Enter key etc?

So, for example, if I held down a key on the keyboard, it would repeat the code for that key (at the kbd rpt rate) until I let go....

Thanks
Andy
andyp24 is offline   Reply With Quote
Old 01-10-2019, 07:55 PM   #2
dsyrock
Human being with feelings
 
dsyrock's Avatar
 
Join Date: Sep 2018
Location: China
Posts: 90
Default

You can try juliansander's API extension. But only the modifier keys and mouse buttons can be detected.
https://forum.cockos.com/showthread.php?t=212174
dsyrock is offline   Reply With Quote
Old 01-11-2019, 12:38 AM   #3
andyp24
Human being with feelings
 
Join Date: Mar 2016
Posts: 584
Default

Thanks for the replies....

To clarify, I mean the computer keyboard not a MIDI keyboard.

Andy
andyp24 is offline   Reply With Quote
Old 01-11-2019, 06:45 AM   #4
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 690
Default

I've suggested it to Julian, and he replied that he couldn't figure out, how to catch keyboard-inputs sent to Reaper-windows, yet.
So I think, it is impossible, at least for now.
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 01-11-2019, 07:03 AM   #5
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 2,418
Default

Keyboard input can be intercepted globally (within REAPER) using accelerator_register_t from the C++ extension API.



https://gist.github.com/cfillion/d86...fd7b2ea82f7ff6

Last edited by cfillion; 01-11-2019 at 07:24 AM.
cfillion is online now   Reply With Quote
Old 01-11-2019, 07:21 AM   #6
andyp24
Human being with feelings
 
Join Date: Mar 2016
Posts: 584
Default

Thanks again.

I'd have literally NO idea how to use that C++ thing within a Lua script, and I wouldn't be at all surprised to hear it's impossible.

I'm really quite new to this - the last time I wrote any computer code was at University in the 1980s!!

Doing OK with Lua for now, and managing to make some scripts that are really useful in my workflow, but nothing too complex :-)

The reason for asking this was to see if it might help with the Undo problem discussed here:

https://forum.cockos.com/showthread.php?t=211932

(ie if a script could intercept keyboard commands then it could continue performing an action as the key was repeatedly pressed, then after a certain "timeout" of no presses, it could exit and make an Undo point).

But it sounds like it's a blind alley.
andyp24 is offline   Reply With Quote
Old 01-11-2019, 08:32 AM   #7
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 690
Default

Quote:
Originally Posted by cfillion View Post
Keyboard input can be intercepted globally (within REAPER) using accelerator_register_t from the C++ extension API.



https://gist.github.com/cfillion/d86...fd7b2ea82f7ff6
Oh, that's great

How difficult would it be to add it to Julian's plugin?

@andyp24
You can't use C++-stuff directly from Lua, but if someone adds that as a function into an extension, you could use it, like any other ReaScript-API-function.
You would just need to install that extension that contains this new function.
__________________
Ultraschall-API: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs for Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 01-11-2019, 09:50 AM   #8
andyp24
Human being with feelings
 
Join Date: Mar 2016
Posts: 584
Default

Thanks Mespotine, I almost understood that ;-)

Andy
andyp24 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:48 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.