Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 12-08-2019, 06:49 AM   #1
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default When using InsertMedia, how to programmatically click "ok" on import tempo map

Whenever I import a midi file, I want to explicitly use the tempo specified in the midi file. A prompt window shows up for this. I am now automating this using the InsertMedia api call. How can I parameterize that I want to import the tempo map? API documentation says I can use mode parameter 8

"&8=try to match tempo 1x"

However, I don't think this means the same thing as importing the tempo map, as it does not have the same effect (item gets imported as wrong tempo if I disable the "always prompt for tempo map" option in preferences).

Thanks!
darnskewered is offline   Reply With Quote
Old 12-08-2019, 11:59 AM   #2
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

Don't tell me I have to write a vb script to click this button for me! Haha, I'll do it if I have to...
darnskewered is offline   Reply With Quote
Old 12-09-2019, 08:47 PM   #3
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

Can you use
reaper.CF_ShellExecute

%SendKeys% "{ENTER}"

You can set the check boxes with
reaper.SNM_SetIntConfigVar('midiimport', 2)

__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 12-09-2019 at 08:57 PM.
MusoBob is offline   Reply With Quote
Old 12-12-2019, 07:11 PM   #4
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

Quote:
Originally Posted by MusoBob View Post
Can you use
reaper.CF_ShellExecute

%SendKeys% "{ENTER}"

You can set the check boxes with
reaper.SNM_SetIntConfigVar('midiimport', 2)

CF_ShellExecute doesn't get highlighted in the script editor inside Reaper...also I don't see this function in the api documentation?
darnskewered is offline   Reply With Quote
Old 12-12-2019, 07:14 PM   #5
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

I found this:
https://forum.cockos.com/showpost.ph...22&postcount=5

What is SWS? How do I get it?
darnskewered is offline   Reply With Quote
Old 12-12-2019, 07:21 PM   #6
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

http://www.standingwaterstudios.com
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 12-12-2019, 08:11 PM   #7
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

What is the the proper syntax here?

Quote:
Originally Posted by MusoBob View Post
Can you use
reaper.CF_ShellExecute

%SendKeys% "{ENTER}"
darnskewered is offline   Reply With Quote
Old 12-13-2019, 12:12 AM   #8
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

https://www.extremraym.com/cloud/rea...c/#ExecProcess
https://www.extremraym.com/cloud/rea...2_ShellExecute
https://www.extremraym.com/cloud/rea...F_ShellExecute
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak
MusoBob is offline   Reply With Quote
Old 12-14-2019, 10:37 AM   #9
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

I was able to use SWS and AutohotKey from within ReaScript, however, the problem I'm now running into is that the midi import modal blocks, and so does running the autohotkey process--but I need the autohotkey process to be running concurrently when the midi import modal is up. I think as a workaround for now I'm just going to run an autohotkey script on infinite loop separate from reaper or something and see if that works.

Kind of shocking with all the scripting capability of this software there's no (obvious) way to script that midi import tempo window.
darnskewered is offline   Reply With Quote
Old 12-14-2019, 12:20 PM   #10
darnskewered
Human being with feelings
 
Join Date: Nov 2019
Posts: 16
Default

Ah I got everything working by running autohotkey outside of reaper with an infinite loop conditionally checking the title of the active window. The script can be ended with esc. I have my midi rendering automation working exactly as I meed it now. Still surprising to me that that midi tempo import option is not scriptable to begin with though.
darnskewered is offline   Reply With Quote
Old 12-14-2019, 02:56 PM   #11
MusoBob
Human being with feelings
 
MusoBob's Avatar
 
Join Date: Sep 2014
Posts: 2,643
Default

If you save this as ReaperSendEnter.vbs in the same folder as the Lua script.

Code:
Set Processes = GetObject("winmgmts:").InstancesOf("Win32_Process")

For Each Process In Processes
    If StrComp(Process.Name, "reaper.exe", vbTextCompare) = 0 Then

        ' Activate the window using its process ID...
        With CreateObject("WScript.Shell")
            .AppActivate Process.ProcessId
            .SendKeys "{ENTER}"
        End With

        ' We found our process. No more iteration required...
        Exit For

    End If
Next
In your Lua script add
Code:
local info = debug.getinfo(1,'S');
script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]

reaper.CF_ShellExecute(script_path .. "ReaperSendEnter.vbs")
and see if it works.
EDIT: you can also create an apple script for Mac.
__________________
ReaTrakStudio Chord Track for Reaper forum
www.reatrak.com
STASH Downloads https://stash.reaper.fm/u/ReaTrak

Last edited by MusoBob; 12-14-2019 at 07:07 PM.
MusoBob 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 07:50 AM.


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