No internet connection
  1. Home
  2. Macro and Script Help

Exporting a file from RX. Trouble getting at UI elements.

By Brenden @nednednerb
    2023-01-31 20:55:49.237Z

    Title

    Exporting a file from RX. Trouble getting at UI elements.

    What do you expect to happen when you run the script/macro?

    Export current file to same directory the RXDoc file is. It should use menu Export and UI elements to confirm location for the saved file.

    Are you seeing an error?

    AXUIElementException In the "backend log" and I see the text above in a popup message when I ran the command at 12:48:10.11

    What happens when you run this script?

    The windows popup as they should, then on the last window and UI element click, I get the error message, but I can see the button, and it doesn't complete the last step in the macro. It doesn't hit "Save."

    How were you running this script?

    I used a Stream Deck button

    How important is this issue to you?

    3

    Details

    {
        "inputExpected": "Export current file to same directory the RXDoc file is. It should use menu Export and UI elements to confirm location for the saved file.",
        "inputIsError": true,
        "inputError": "AXUIElementException\nIn the \"backend log\" and I see the text above in a popup message when I ran the command at 12:48:10.11",
        "inputWhatHappens": "The windows popup as they should, then on the last window and UI element click, I get the error message, but I can see the button, and it doesn't complete the last step in the macro. It doesn't hit \"Save.\"",
        "inputHowRun": {
            "key": "-MpfwmPg-2Sb-HxHQAff",
            "title": "I used a Stream Deck button"
        },
        "inputImportance": 3,
        "inputTitle": "Exporting a file from RX. Trouble getting at UI elements."
    }

    Source

    //Macro converted to script
    
    
    sf.ui.izotope.appActivateMainWindow();
    
    sf.ui.izotope.menuClick({
        menuPath: ["File","Export..."],
    });
    
    sf.ui.izotope.windows.whoseTitle.is("Export File").first.groups.whoseDescription.is("ExportPanel Module Wrapper").first.elementWaitFor({
        waitType: "Appear",
        pollingInterval: 500,
        timeout: 15000,
    });
    
    sf.wait({
        intervalMs: 250,
    });
    
    sf.ui.izotope.windows.whoseTitle.is("Export File").first.groups.whoseDescription.is("ExportPanel Module Wrapper").first.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first.buttons.whoseDescription.is("OK").first.elementClick();
    
    sf.wait({
        intervalMs: 500,
    });
    
    sf.ui.izotope.focusedWindow.buttons.whoseTitle.is("Save").first.elementClick();
    
    
    

    Links

    User UID: hMEBO84NZbXqVbqYJzU5ZyTNHGN2

    Feedback Key: sffeedback:hMEBO84NZbXqVbqYJzU5ZyTNHGN2:-NN8bJklfkI5jIO6O-ur

    Feedback ZIP

    Solved in post #16, click to view
    • 18 replies

    There are 18 replies. Estimated reading time: 23 minutes

    1. Brenden @nednednerb
        2023-02-06 21:40:23.087Z

        bump

        Hey there, I don't mind if this issue is low priority, but did it happen to slip by attention totally?

        I seem to be having issues in general with RX UI element picking. Is that just for me, or are others handling it differently? I've tried variations of "ExportPanel" and 'whoseTitle.is("XXX")' etc options from the Picker drop down. Mostly I don't get the results I desire. I have not changed this script hoping it can get figured out, accessing the errors in the logs, etc.

        Thanks!

        1. In reply tonednednerb:
          Brenden @nednednerb
            2023-02-14 19:07:03.200Z

            @chrscheuer No rush, but I wonder if someone has a spot of attention for this issue. Thanks!

            1. Let me cc @Kitch to see if there's something we can do to work around this bug.

              This may be related to what Matt is saying here:
              Izotope RX: Render & Spot Back Into Pro Tools won't work when there's more than one tab in RX #post-9

              1. Related to:

                1. In reply tochrscheuer:
                  Kitch Membery @Kitch2023-02-14 20:45:45.696Z

                  I'll take a look.

                2. In reply tonednednerb:
                  Kitch Membery @Kitch2023-02-14 21:53:57.794Z

                  Hi @nednednerb

                  I see, there are a few things causing the issue. The biggest being the save dialog has the same name (ie "Export File").

                  The second is that it seems that iZotope may not always be reporting information back to SoundFlow, but I'll need to investigate this further to confirm the issue.

                  Here is a workaround for now.

                  sf.ui.izotope.appActivateMainWindow();
                  sf.ui.izotope.invalidate();
                  
                  sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                  
                  let exportFileWindow = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                  let saveDialog = sf.ui.izotope.windows.whoseTitle.is("Export File").allItems[2];
                  let exportPanelModuleWrapper = exportFileWindow.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                  let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first
                  let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                  let saveButton = saveDialog.buttons.whoseTitle.is("Save").first;
                  
                  //Wait fro Export File Window
                  exportFileWindow.elementWaitFor();
                  
                  //Click the OK Button (ignore error)
                  okButton.elementClick({ onError: "Continue" });
                  
                  let fileNameSplit = sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.value.value.split(".");
                  let fileName = fileNameSplit[0];
                  let fileExtension = fileNameSplit[1];
                  let fileNameSuffix = "_Edit";
                  
                  sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.elementSetTextFieldWithAreaValue({
                      value: `${fileName}${fileNameSuffix}.${fileExtension}`,
                  });
                  
                  //Click the Save Button in the save dialog (ignore error)
                  sf.ui.izotope.windows.whoseTitle.is("Export File").first.buttons.whoseTitle.is("Save").first.elementClick({ onError: "Continue" });
                  

                  Note I've added "_Edit" to the file otherwise you'd overwrite the file you are working on.

                  I hope that helps.

                  1. Brenden @nednednerb
                      2023-02-23 20:29:03.682Z

                      The first time I tried the script, I had no luck. Who knows why hah!

                      However, I tried again today, and it worked just as intended/described! Hmmm, if I changed = "_Edit"; to = prompt(); will something nice happen and let me add -1 or -b etc as I whimsy?? I will test that myself ;)

                      Thanks @Kitch!

                      edit: My switch of the string for the prompt function worked totally perfectly in line with the rest of your script, and (since I usually rename an RXDOC before export) simply pressing return inserts an empty string and I get my single, non overwritten custom name wav based on my RXDOC name. Your addition of the "_edit" was initially something I considered "oh I don't need that, I often export more than once anyway" but switching it to the prompt() makes it quite useful and flexible for me. Just in case it's not clear to anyone following along for their own purposes:

                      sf.ui.izotope.appActivateMainWindow();
                      sf.ui.izotope.invalidate();
                      
                      sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                      
                      let exportFileWindow = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                      let saveDialog = sf.ui.izotope.windows.whoseTitle.is("Export File").allItems[2];
                      let exportPanelModuleWrapper = exportFileWindow.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                      let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first
                      let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                      let saveButton = saveDialog.buttons.whoseTitle.is("Save").first;
                      
                      //Wait fro Export File Window
                      exportFileWindow.elementWaitFor();
                      
                      //Click the OK Button (ignore error)
                      okButton.elementClick({ onError: "Continue" });
                      
                      let fileNameSplit = sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.value.value.split(".");
                      let fileName = fileNameSplit[0];
                      let fileExtension = fileNameSplit[1];
                      
                      // One small change from Kitch's script
                      let fileNameSuffix = prompt();
                      
                      sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.elementSetTextFieldWithAreaValue({
                          value: `${fileName}${fileNameSuffix}.${fileExtension}`,
                      });
                      
                      //Click the Save Button in the save dialog (ignore error)
                      sf.ui.izotope.windows.whoseTitle.is("Export File").first.buttons.whoseTitle.is("Save").first.elementClick({ onError: "Continue" });
                      
                  2. In reply tonednednerb:
                    Brenden @nednednerb
                      2023-02-26 20:03:10.733Z

                      @Kitch
                      Hey there. When I tried to run the script today, it is failing on line 19, and the log is saying something about not finding the Array Element Ax something something beyond my comprehension!
                      Is there a reason this line might fail today, but have worked yesterday?

                      let fileNameSplit = sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.value.value.split(".");
                      

                      I last ran the script just before noon PST. (26.02.2023 11:58:57.96 in fact)

                      1. Brenden @nednednerb
                          2023-02-26 20:05:47.352Z

                          Hey, that was all it took!! I tried one thing, putting a 300 ms wait between clicking okButton and before the fileNameSplit.

                          Then it worked just fine!

                        • In reply tonednednerb:
                          Brenden @nednednerb
                            2023-02-27 23:40:37.253Z

                            @Kitch Thank you for helping. Though today when I tried to run the script it's having trouble on the same line again, with this reported in the backend log:

                            Command Error: RX-Export-Wav [user:cl9bu1wpr0000y1105pdkz5gf:cl9q6thry0001hc10mmcrkl12]:
                            Couldn't locate AxElementArrayIndexedItem (RX-Export-Wav: Line 23)
                            

                            My whole script as currently not working:

                            sf.ui.izotope.appActivateMainWindow();
                            sf.ui.izotope.invalidate();
                            
                            sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                            
                            let exportFileWindow = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                            let saveDialog = sf.ui.izotope.windows.whoseTitle.is("Export File").allItems[2];
                            let exportPanelModuleWrapper = exportFileWindow.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                            let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first
                            let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                            let saveButton = saveDialog.buttons.whoseTitle.is("Save").first;
                            
                            //Wait fro Export File Window
                            exportFileWindow.elementWaitFor();
                            
                            //Click the OK Button (ignore error)
                            okButton.elementClick({ onError: "Continue" });
                            
                            sf.wait({
                                intervalMs: 500,
                            });
                            
                            let fileNameSplit = sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.value.value.split(".");
                            let fileName = fileNameSplit[0];
                            let fileExtension = fileNameSplit[1];
                            
                            // One small change from Kitch's script
                            let fileNameSuffix = prompt('Give export a suffix', '');
                            
                            sf.ui.izotope.windows.whoseTitle.is("Export File").first.textFields.first.elementSetTextFieldWithAreaValue({
                                value: `${fileName}${fileNameSuffix}.${fileExtension}`,
                            });
                            
                            //Click the Save Button in the save dialog (ignore error)
                            sf.ui.izotope.windows.whoseTitle.is("Export File").first.buttons.whoseTitle.is("Save").first.elementClick({ onError: "Continue" });
                            

                            It stops on line 23. How would I best troubleshoot this to figure it out?

                            Thanks!

                            1. Kitch Membery @Kitch2023-02-27 23:45:26.391Z

                              This script is already a workaround so I'll have to investigate further to see what's going on. I'll let you know how I go with it.

                              If you can do a screen recording of it failing that would be helpful.

                              1. Brenden @nednednerb
                                  2023-02-28 00:02:58.310Z
                                  1. Kitch Membery @Kitch2023-02-28 00:04:44.261Z

                                    Thanks. I'll take a look when I get a chance.

                                • In reply tonednednerb:
                                  Kitch Membery @Kitch2023-02-28 10:09:26.727Z2023-03-01 00:36:05.496Z

                                  Hi @nednednerb,

                                  Here is the fix. :-)

                                  // Prompt user for file name suffix
                                  let fileNameSuffix = sf.interaction.displayDialog({
                                      prompt: "Please enter the suffix you'd like to add to the file name.",
                                      defaultAnswer: "",
                                      buttons: ["Continue", "Cancel"],
                                      cancelButton: "Cancel",
                                      defaultButton: "Continue",
                                  }).text;
                                  
                                  sf.ui.izotope.appActivateMainWindow();
                                  sf.ui.izotope.invalidate();
                                  
                                  sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                                  
                                  let pageTitle = sf.ui.izotope.mainWindow.getElement("AXTitleUIElement").value.invalidate().value;
                                  
                                  let exportFileWin = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                                  let exportPanelModuleWrapper = exportFileWin.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                                  let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first;
                                  let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                                  
                                  exportFileWin.elementWaitFor({}, `The "Export File" window did not appear`);
                                  
                                  // Click the OK button (ignore error)
                                  okButton.elementClick({ onError: "Continue" }, `Could not click the "OK" button.`);
                                  
                                  let fileName = pageTitle.slice(0, pageTitle.lastIndexOf(","));
                                  
                                  let newFileName = `${fileName}${fileNameSuffix}`;
                                  
                                  let saveAsWin = sf.ui.izotope.windows.whoseTitle.is("Export File").filter(win => win.getString("AXIdentifier") === "save-panel")[0];
                                  let saveButton = saveAsWin.buttons.whoseTitle.is("Save").first;
                                  let saveAsTextField = saveAsWin.textFields.first;
                                  
                                  saveAsTextField.elementSetTextFieldWithAreaValue({ value: newFileName, });
                                  
                                  // Click the Save button in the save dialog (ignore error)
                                  saveButton.elementClick();
                                  

                                  Updated.

                                  1. Brenden @nednednerb
                                      2023-02-28 23:20:03.461Z2023-03-01 00:11:50.763Z

                                      Hey there @Kitch . I think this will be easy fix for you, but I am unsure... What about "Test.wav" in line 15?

                                      My RX main window has the title "/random/.rxdoc". I'm very generally always working with an RXDoc file.

                                      Actually..... I did some poking at your script and customized it to my situation a bit more directly, and I got something working!

                                      // Prompt user for file name suffix
                                      let fileNameSuffix = sf.interaction.displayDialog({
                                          prompt: "Please enter the suffix you'd like to add to the file name.",
                                          defaultAnswer: "",
                                          buttons: ["Continue", "Cancel"],
                                          cancelButton: "Cancel",
                                          defaultButton: "Continue",
                                      }).text;
                                      
                                      sf.ui.izotope.appActivateMainWindow();
                                      sf.ui.izotope.invalidate();
                                      
                                      // Get the window title using the getElement object
                                      let pageTitle = sf.ui.izotope.mainWindow.getElement("AXTitleUIElement").value.invalidate().value;
                                      
                                      sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                                      
                                      let exportFileWin = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                                      let exportPanelModuleWrapper = exportFileWin.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                                      let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first;
                                      let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                                      
                                      exportFileWin.elementWaitFor({}, `The "Export File" window did not appear`);
                                      
                                      // Click the OK button (ignore error)
                                      okButton.elementClick({ onError: "Continue" }, `Could not click the "OK" button.`);
                                      
                                      let fileName = pageTitle.slice(0, pageTitle.lastIndexOf("."));
                                      
                                      // My export is always wav, default setting
                                      let fileExtension = "wav";
                                      
                                      let newFileName = `${fileName}${fileNameSuffix}.${fileExtension}`;
                                      
                                      let saveAsWin = sf.ui.izotope.windows.whoseTitle.is("Export File").filter(win => win.getString("AXIdentifier") === "save-panel")[0];
                                      let saveButton = saveAsWin.buttons.whoseTitle.is("Save").first;
                                      let saveAsTextField = saveAsWin.textFields.first;
                                      
                                      saveAsTextField.elementSetTextFieldWithAreaValue({ value: newFileName, });
                                      
                                      // Click the Save button in the save dialog (ignore error)
                                      saveButton.elementClick();
                                      
                                      ReplySolution
                                      1. Kitch Membery @Kitch2023-03-01 00:12:49.521Z

                                        Oops, I'll fix that shortly.

                                        1. Kitch Membery @Kitch2023-03-01 00:40:44.376Z

                                          Here is an updated version.

                                          // Prompt user for file name suffix
                                          let fileNameSuffix = sf.interaction.displayDialog({
                                              prompt: "Please enter the suffix you'd like to add to the file name.",
                                              defaultAnswer: "",
                                              buttons: ["Continue", "Cancel"],
                                              cancelButton: "Cancel",
                                              defaultButton: "Continue",
                                          }).text;
                                          
                                          sf.ui.izotope.appActivateMainWindow();
                                          sf.ui.izotope.invalidate();
                                          
                                          sf.ui.izotope.menuClick({ menuPath: ["File", "Export..."], });
                                          
                                          let pageTitle = sf.ui.izotope.mainWindow.getElement("AXTitleUIElement").value.invalidate().value;
                                          
                                          let exportFileWin = sf.ui.izotope.windows.whoseTitle.is("Export File").first;
                                          let exportPanelModuleWrapper = exportFileWin.groups.whoseDescription.is("ExportPanel Module Wrapper").first;
                                          let exportPanelModuleWrapperFooter = exportPanelModuleWrapper.groups.whoseDescription.is("ExportPanel Module Wrapper Footer Background").first;
                                          let okButton = exportPanelModuleWrapperFooter.buttons.whoseDescription.is("OK").first;
                                          
                                          exportFileWin.elementWaitFor({}, `The "Export File" window did not appear`);
                                          
                                          // Click the OK button (ignore error)
                                          okButton.elementClick({ onError: "Continue" }, `Could not click the "OK" button.`);
                                          
                                          let fileName = pageTitle.slice(0, pageTitle.lastIndexOf(","));
                                          
                                          let newFileName = `${fileName}${fileNameSuffix}`;
                                          
                                          let saveAsWin = sf.ui.izotope.windows.whoseTitle.is("Export File").invalidate().filter(win => win.getString("AXIdentifier") === "save-panel")[0];
                                          
                                          let saveButton = saveAsWin.buttons.whoseTitle.is("Save").first;
                                          let saveAsTextField = saveAsWin.textFields.first;
                                          
                                          saveAsTextField.elementSetTextFieldWithAreaValue({ value: newFileName, });
                                          
                                          // Click the Save button in the save dialog (ignore error)
                                          saveButton.elementClick();
                                          

                                          Hopefully this works as expected.

                                          1. Brenden @nednednerb
                                              2023-03-01 03:20:50.310Z

                                              Sorry, my last message was a bit of a Franken edit. I solved my problem (now marked as Solution) using the script I last posted. I'm not sure what you changed, but it might be a bit of a refactor that does the same thing in the end as what I ended up with.. I realize there might be something redundant in my script above, but it manages to successfully export the RXDOC I have open as a Wav file with a name I can increment by prompting the suffix.

                                              THANK YOU SO MUCH. You did solve my problem, but via my rushing to edit the last trial before hearing back. I will copy down this refactor and see if it does the same as the other working version I have now.

                                              I like to understand problems by considering multiple solutions, so this is helpful.