In command mod: how to launch a specific external program depending on the current selected filename

For this logic you need a script. Try this command:

function OnInit(initData) {
    initData.name = 'LaunchMSFSLayoutGenerator';
    initData.version = '2023-06-03';
    initData.url = 'https://resource.dopus.com/t/in-command-mod-how-to-launch-a-specific-external-program-depending-on-the-current-selected-filename/44554';
    initData.default_enable = true;
    initData.min_version = '12.0';
}

function OnAddCommands(addCmdData) {
    var cmd = addCmdData.AddCommand();
    cmd.name = 'LaunchMSFSLayoutGenerator';
    cmd.method = 'OnLaunchMSFSLayoutGenerator';
    cmd.hide = false;
    cmd.icon = 'script';
}

function OnLaunchMSFSLayoutGenerator(scriptCmdData) {
    var cmd = scriptCmdData.func.command;
    var tab = scriptCmdData.func.sourcetab;
    cmd.deselect = false;
    if (tab.selected_files.count == 0) return;
    var item = tab.selected_files(0);
    if (item.name != 'layout.json') return;
    cmd.RunCommand('J:\\MSFSLayoutGenerator.exe "' + item + '"');
}

CommandLaunchMSFSLayoutGenerator.js.txt (952 Bytes)


https://resource.dopus.com/t/how-to-use-buttons-and-scripts-from-this-forum/3546

1 Like