Old 05-19-2018, 07:41 AM   #1
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default Problem withMain_OnCommandEx

Hello,
I try to send a command via this very simple LUA script :
reaper.Main_OnCommandEx(25, 0, 0)
ID #25 : Toggle record arm for track O1
No action at all !
The same with 22 for mute
I tested the ID to close the project. It works fine.
Any idea ?
Alain

Last edited by Alain78; 05-19-2018 at 07:42 AM. Reason: No title
Alain78 is offline   Reply With Quote
Old 05-19-2018, 07:49 AM   #2
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

It works here...
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 05-19-2018, 08:05 AM   #3
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
reaper.Main_OnCommandEx(25, 0, 0)
It works here as well.

Some things to check in general:

- When creating a new ReaScript file, double-check that the file is saved with the correct file extension (.lua)
- Into which Section (selection box at the top right) in the Acton List did you add the Script?
- How/where are you triggering the Action, exactly?
solger is offline   Reply With Quote
Old 05-19-2018, 08:42 AM   #4
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

- the script is created with lua extension
- the script is created in the Main section
- the script has to be triggered via a midi message BUT even when i trigger it via the Run button : the result is the same : No Effect !
Hope this clarify the situation...
Alain
Attached Images
File Type: jpg ScreenShot452.jpg (15.4 KB, 165 views)
Alain78 is offline   Reply With Quote
Old 05-19-2018, 09:03 AM   #5
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
trigger it via the Run button : the result is the same : No Effect !
Very strange. From the screenshot I can't really see anything out of the ordinary (assuming Track 1 is visible and not locked somehow).

Have you already tried if using IDs for other Tracks (than Track #1) are working - like, for instance ID 30 (Track: Toggle mute for track 02) or ID 33 (Track: Toggle record arm for track 02)?

Otherwise also try if restarting Reaper makes any difference, just in case ...

Last edited by solger; 05-19-2018 at 09:08 AM.
solger is offline   Reply With Quote
Old 05-19-2018, 09:46 AM   #6
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Here's the full view.
I never tried to lock the track... and don't know how to do it as a beginner in Reaper...
Yes, i tried other tasks with the formula rec_toggle_comm_id = 8*track_num +14
(and with the real figures..)
I tried also with ID 22 to mute/unmute the first track

In fact, my goal is to have separate commands for arm and for unarm the tracks.
You have seen that my starting point was the code from AkeW
It looked so simple...
Attached Images
File Type: jpg ScreenShot453.jpg (60.5 KB, 141 views)
Alain78 is offline   Reply With Quote
Old 05-19-2018, 09:56 AM   #7
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

... and i restarted Reaper.
Alain78 is offline   Reply With Quote
Old 05-19-2018, 10:05 AM   #8
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

A shot in the dark, but are you trying to run it (from the action list) while Reaper's script IDE window is open with the script by chance ?

This doesn't work. Use Ctrl+S instead while IDE window is in focus (or the 'Start' button in the IDE).
Or close IDE window first and then try running again from action list (or via MIDI, don't know if same applies here).

Similar behaviour with toolbar buttons as I found the hard way.
https://forum.cockos.com/showthread.php?t=183929

Last edited by nofish; 05-19-2018 at 10:13 AM.
nofish is offline   Reply With Quote
Old 05-19-2018, 10:40 AM   #9
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78
... BUT even when i trigger it via the Run button : the result is the same : No Effect !
Quote:
Originally Posted by Alain78 View Post
... Here's the full view ...
Yeah. As nofish mentioned above, trying to [Run] the Script via the Action List while having the Script open in the IDE Editor window at the same time is mostly likely the issue here.

Last edited by solger; 05-19-2018 at 10:52 AM. Reason: typo
solger is offline   Reply With Quote
Old 05-19-2018, 10:54 AM   #10
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Thank's to nofish & solger for this good idea.. but it looks i tried all the ways to run the script
- editor closed : Button Run of the Actions window
- editor open: Button Start
- Ctrl+S with editor open
Alain78 is offline   Reply With Quote
Old 05-19-2018, 10:57 AM   #11
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Of course : Same result...
Alain78 is offline   Reply With Quote
Old 05-19-2018, 11:01 AM   #12
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
Thank's to nofish & solger for this good idea.. but it looks i tried all the ways to run the script
- editor closed : Button Run of the Actions window
- editor open: Button Start
- Ctrl+S with editor open
Just to rule out that it might perhaps be a file/folder permission problem (when trying to access the .lua file in the .. Appdata/Roaming/.. folder):

Does it make any difference when launching Reaper as admin (via Right-Click > Administrator)?


But on second thought you posted that using some other IDs is working fine:

Quote:
I tested the ID to close the project. It works fine.

At this point I would suggest to make a portable Reaper install to a separate folder (side by side to your existing install): http://lacinato.com/cm/blog/25-reaperportable
Just to check if the problem is the same there ...
solger is offline   Reply With Quote
Old 05-19-2018, 02:02 PM   #13
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

I just checked the option od running REaper as administrator : No change.
How did you know that i'm not running as admin ???
OK. Tomorrow (Paris time) I'll chek the portable install.
Thank you for your help.
Alain
Alain78 is offline   Reply With Quote
Old 05-20-2018, 02:40 AM   #14
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

I installed Reaper in portable mode and the the simple test show on the attached file... Unfortunately the result is the same : No action at all !
I imagine that as often with difficult problems to solve, the solution is simple ... but where to look now ?
The good news is that I discovered the interest of the portable mode that allows a simple backup with all the files at one place and the easy distibution of the solution to other PCs that I'll need.
Attached Images
File Type: jpg ScreenShot454.jpg (63.4 KB, 194 views)
Alain78 is offline   Reply With Quote
Old 05-20-2018, 10:00 AM   #15
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
I installed Reaper in portable mode and the the simple test show on the attached file... Unfortunately the result is the same : No action at all
That's very strange.

Have you already tried running the script in a New Project (to rule out that the issue might be somehow related to the project shown in your screenshots)?


And just to double-check (since you posted that some other IDs are working):
When changing the ID number 25 in the script in your screenshot to a different ID - as example to 40853 (Track: Toggle show/hide in TCP) or to 9 (Toggle record arm for selected Tracks), is running the Script Action working then?
solger is offline   Reply With Quote
Old 05-20-2018, 10:08 AM   #16
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

New project - Insert new track - run the script : No action for ID 25
Same project with 1 track - ID 40853 - The track toggles from visible to hidden.
Same project with 1 track - ID 9 - No action
I've already seen that action with big number work... But nothing more to say...
Alain78 is offline   Reply With Quote
Old 05-20-2018, 10:39 AM   #17
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
New project - Insert new track - run the script : No action for ID 25
Same project with 1 track - ID 40853 - The track toggles from visible to hidden.
Same project with 1 track - ID 9 - No action
I've already seen that action with big number work... But nothing more to say...
OK, I've got another idea:

Install the SWS Extensions: http://www.sws-extension.org/
Then restart Reaper and check if it's working now.
solger is offline   Reply With Quote
Old 05-20-2018, 10:53 AM   #18
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

The ID 25 command is working !!!
The same for 33. The same for 22 (mute)
But i've no idea why!
Alain78 is offline   Reply With Quote
Old 05-20-2018, 11:05 AM   #19
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
The ID 25 command is working !!!
The same for 33. The same for 22 (mute)
Great to hear that it's working now

Quote:
But i've no idea why!
Yeah, I don't know either why using lower command IDs in a lua script doesn't seem to be working without the SWS Extensions installed
solger is offline   Reply With Quote
Old 05-20-2018, 11:10 AM   #20
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

OK let's consider that the problem is solved...
Tomorrow, i'll return to my original script.
A very big thank you for your help.
Without you, I had to give up.
Alain
Alain78 is offline   Reply With Quote
Old 05-20-2018, 11:26 AM   #21
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by solger View Post
I don't know either why using lower command IDs in a lua script doesn't seem to be working without the SWS Extensions installed
Confirmed here too, without the SWS extension they don't work. "Weird".
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 05-20-2018, 12:47 PM   #22
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

Quote:
Originally Posted by solger View Post
OK, I've got another idea:

Install the SWS Extensions: http://www.sws-extension.org/
Then restart Reaper and check if it's working now.
How did you come up with this idea ?
I'd never have thought to try this.
nofish is offline   Reply With Quote
Old 05-21-2018, 01:02 AM   #23
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by nofish View Post
How did you come up with this idea ?
I'd never have thought to try this.
At some point I noticed that there was no Extensions menu in Alain78's screenshots (hence no SWS Extensions and/or ReaPack installed).

So I checked this again in a fresh portable install without the SWS Extensions installed (which I didn't do before ) and had the same issue running the LUA script.
Having the SWS Extensions installed fixes the issue (for whatever reason)

Last edited by solger; 05-21-2018 at 01:33 AM.
solger is offline   Reply With Quote
Old 05-21-2018, 08:45 AM   #24
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Me again ! My story is not quite over.

I have to explain that my goal is to drive Reaper as a black box from an external program using midi messages and as little as possible with the help of AutoIt.

I take advantage of the contact with "real experts" to explain my "last" problem.
I switched to portable mode with reinstallation of SWS.
Everything is fine with the scripts. Thanks again.

I run Reaper with this command:
"G:\MaConsole - V4\Exe\Reaper_DAW\Reaper.exe" "G:\MaConsole - V4\Exe\Enregistrements\000007000000599\00000700000 0599.rpp"

When I send the midi message corresponding to the script discussed yesterday nothing happens. The same with midi messages associated with Record, Play, Stop, ... No action is executed. Messages are of course visible with midi-ox.

Then I close the project and reload it with File, Open project, Enter ... and then all the midi commands are effective.

My level of knowledge does not allow me to go further. Any idea ?
Alain78 is offline   Reply With Quote
Old 05-21-2018, 10:13 AM   #25
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
I run Reaper with this command:
"G:\MaConsole - V4\Exe\Reaper_DAW\Reaper.exe" "G:\MaConsole - V4\Exe\Enregistrements\000007000000599\00000700000 0599.rpp"

When I send the midi message corresponding to the script discussed yesterday nothing happens. The same with midi messages associated with Record, Play, Stop, ... No action is executed. Messages are of course visible with midi-ox.

Then I close the project and reload it with File, Open project, Enter ... and then all the midi commands are effective.
Just to clarify:

- What's the MIDI device or virtual MIDI cable used as MIDI input in Reaper?
- And where is it set up in the Preferences: under Audio > MIDI Devices or under Control/OSC/web?
solger is offline   Reply With Quote
Old 05-21-2018, 10:55 AM   #26
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Virtuel MIDi is CopperLan
Midi input is setup under Audio > MIDI Devices withe the attribute Enabled+Control
What's strange is that up to now, the solution was working...
Attached Images
File Type: jpg ScreenShot455.jpg (58.7 KB, 92 views)
Alain78 is offline   Reply With Quote
Old 05-21-2018, 11:12 AM   #27
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
Virtuel MIDi is CopperLan
Midi input is setup under Audio > MIDI Devices withe the attribute Enabled+Control
What's strange is that up to now, the solution was working...
Is Reaper launched last?

Otherwise maybe try if this makes any difference:

1) In the Action List, there's an Action called Reset all MIDI devices - ID: 41175.
2) Set this one via the Extensions > Startup actions menu as Global or Project Startup Action.

Last edited by solger; 05-21-2018 at 11:33 AM. Reason: typo
solger is offline   Reply With Quote
Old 05-21-2018, 11:26 AM   #28
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Yes Reaper is lauched last after a lot of midi messages were sended thru the CopperLan network.
I put ID 41175 as Global Project Startup Action. I close Reaper when i close a project in the external program.
Sadly : no result
Alain78 is offline   Reply With Quote
Old 05-21-2018, 11:58 AM   #29
solger
Human being with feelings
 
solger's Avatar
 
Join Date: Mar 2013
Posts: 5,844
Default

Quote:
Originally Posted by Alain78 View Post
Yes Reaper is lauched last after a lot of midi messages were sended thru the CopperLan network.
I put ID 41175 as Global Project Startup Action. I close Reaper when i close a project in the external program.
Sadly : no result
OK. Doing a quick test with a different virtual MIDI cable (loopMIDI) seems to work here - although loopMIDI is a local and not a network based one like CopperLan.

I'll have to take a look at CopperLan (probably tomorrow) or will report back if something else comes into mind.
solger is offline   Reply With Quote
Old 05-22-2018, 12:00 AM   #30
Alain78
Human being with feelings
 
Join Date: Mar 2018
Posts: 19
Default

Ah ! Ah!
I've to add that i use MTC to allow my external program to get time code messages.
https://forum.cockos.com/showthread.php?t=43606
I knew that to get these messages, the track dedicated to vVIMTC should be armed for recording.
I discovered this morning that if the track is not armed for recording then all commands driven by MIDI messages will be not effective. Understand who can!
Thank you again for your help. I continue my initiatory journey in the driving of Reaper.
Alain78 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 01:51 AM.


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