RPR NamedCommandLookup

From CockosWiki

Jump to: navigation, search

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR NamedCommandLookup
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR NamedCommandLookup

Contents

NamedCommandLookup()

int NamedCommandLookup(const char* command_name)

This function allows you to call an extension command from within a ReaScript. Use the value returned by this function as the paramater wheb you call Main or MIDIEditor_OnCommand

The names of extension commands are available from the REAPER Action/Show Action List. Display the Action List and scroll right to see command IDs and names.

The command IDs (the numbers) for REAPER standard commands don't change but the command IDs for extension commands will probably be different for each user.

Parameters

const char* command_name     # e.g. "_SWS_ABOUT"

Returns

int

Examples

C++

 


Perl

#
# NamedCommandLookup.pl
#
 
# This example script copies its results to the Windows Clipboard, 
# run the script from within REAPER as normal, open up notepad and 
# Paste the clipboard into notepad to look at the result. Normally 
# you would use the $cmd_id returned to call Main_OnCommand so that 
# you can call an extension command from within a ReaScript.
 
use strict;
use warnings;
 
use Win32::Clipboard;
my $Clipboard = Win32::Clipboard();
 
my $cmd_id;
 
$cmd_id = RPR_NamedCommandLookup('_SWS_ABOUT');
 
$Clipboard -> Set("cmd_id=$cmd_id");


Python

This is a slight modification of the color tinting script on the RPR Main OnCommand page. It uses NamedCommandLookup() to trigger the color tinting action. It is also slightly altered in function, because the last line is deleted. This script will tint only selected items when items and tracks are selected. When only tracks or only items are selected, it tints those.

import warnings;
 
SWS_ITEM_COLOR_1 = RPR_NamedCommandLookup('_SWS_ITEMCUSTCOL1')
SWS_TRACK_COLOR_1 = RPR_NamedCommandLookup('_SWS_TRACKCUSTCOL1')
selTracks =RPR_CountSelectedTracks(0)
selItems = RPR_CountSelectedMediaItems(0)
 
if (selTracks>0 and selItems==0):
  RPR_Main_OnCommand(SWS_TRACK_COLOR_1, 0)
if (selTracks==0 and selItems>0):
  RPR_Main_OnCommand(SWS_ITEM_COLOR_1, 0)
if (selTracks>0 and selItems>0):
  RPR_Main_OnCommand(SWS_ITEM_COLOR_1, 0)

See Also

oncommand: Main_OnCommand, Main_OnCommandEx, MIDIEditor_OnCommand, NamedCommandLookup

(Section automatically generated, edits may be overwritten.)

Stuff

Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR NamedCommandLookup
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR NamedCommandLookup

Personal tools