Old 02-27-2017, 08:47 AM   #1
andyp24
Human being with feelings
 
andyp24's Avatar
 
Join Date: Mar 2016
Posts: 1,242
Default Repeat action with key held down...?

Hi all

I don't write scripts, but I'm interested in providing ideas to people who do, to provide functions that would help my workflow.

Is it possible when scripting to set an action (or series of actions) to repeat if a hotkey is held down, but at an adjustable rate? (I don't mean adjustable each time, I just mean that the script can define how many times per second the action will happen)

Thanks
Andy
andyp24 is offline   Reply With Quote
Old 02-27-2017, 10:11 AM   #2
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Short answer: "Yes, but."

1. The timing might be awkward.

When it starts up, my Radial Menu script looks for any key being held down, notes the key code, and then checks for that key code on every subsequent loop of the main function. However, it has to cheat a little bit because there's a gap between the initial keypress and when Windows starts repeating it:

D
...
...
...
...
D
D
D
D
D
D
...etc.

With your idea, as long as the timer for "how often should I run the action?" is longer than that gap it should work fine. It also might end up always running the action twice, at minimum, although I suppose that could be considered a feature to easily repeat actions.

2. Reaper doesn't offer an easy way to pass arguments to a script, like "run my script and give it this action ID: _____", so you'd need a separate .lua file for each action ID you want to use. They wouldn't all need the entire script, just the action ID and a a reference to "core" file.

However, it could include a separate "create new action" script where the user could paste an ID and have it generate the script file. Then they would just have to use the action list's Load button and find it.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 02-27-2017, 10:19 AM   #3
andyp24
Human being with feelings
 
andyp24's Avatar
 
Join Date: Mar 2016
Posts: 1,242
Default

OK thanks. At least if it's possible in principle, with some caveats, it may help someone to write the kind of functions I'm after.

Cheers
andyp24 is offline   Reply With Quote
Old 02-27-2017, 04:14 PM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

See if this tickles your fancy: http://forum.cockos.com/showthread.php?t=188632
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 02-28-2017, 10:40 AM   #5
andyp24
Human being with feelings
 
andyp24's Avatar
 
Join Date: Mar 2016
Posts: 1,242
Default

That looks really useful. Many thanks.

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 06:19 PM.


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