No internet connection
  1. Home
  2. How to

command to enable and disable eucon; not toggle

By randy matuszewski @randy_matuszewski
    2023-11-13 15:18:28.756Z

    i have a macro that can restart eucon, however sometimes i realize it just toggles the button instead ofd a specific on off command so i am curious if there is a script to enable and disable the button. also, is there a way for me to find out this information by myself instead of asking?

    thanks!!

    randy

    Solved in post #7, click to view
    • 5 replies
    1. Chris Shaw @Chris_Shaw2023-11-13 22:09:27.261Z2023-11-13 22:28:27.147Z

      I'm assuming you're talking about this button:

      This script will turn EuControl off. Just change `deisredState` to "on" for an on script.
      let desiredState = "off";
      
      //Open Peripherals window
      sf.ui.proTools.menuClick({
          menuPath: ["Setup", "Peripherals..."]
      })
      
      //Wait for Peripherals window
      const peripheralsWin = sf.ui.proTools.windows.whoseTitle.is("Peripherals").first;
      peripheralsWin.elementWaitFor()
      
      // Click Ethernet Controllers tab
      const ethernetControllersTab = peripheralsWin.radioButtons.whoseTitle.contains("Ethernet Controllers").first
      ethernetControllersTab.elementClick();
      
      // Define EuController checkbox
      const euconCheckbox = peripheralsWin.checkBoxes.whoseTitle.is("EUCON Control Surfaces").first
      
      //Get checkbox state
      const isEuconOn = euconCheckbox.isCheckBoxChecked
      
      //Set desired checkbox state
      if (
          (isEuconOn && desiredState == "off") || // "||"" means OR
          (!isEuconOn && desiredState == "on")
      ) {
          euconCheckbox.elementClick();
      }
      
      //Click OK
      peripheralsWin.buttons.whoseTitle.is("OK").first.elementClick()
      
      // Wait for Eucon to turn on or off
      peripheralsWin.elementWaitFor({
          waitType: "Disappear",
          timeout: 8000,
          pollingInterval: 150
      })
      
      1. R
        randy matuszewski @randy_matuszewski
          2023-11-14 02:36:42.974Z

          hey thanks for the reply! i was talking about this button in the main screen. it seems to me to be faster to click it there. only i can't figure out how to code for seeing if it is on already. thanks!!

          1. SSreejesh Nair @Sreejesh_Nair
              2023-11-14 05:02:15.595Z

              This code will help you check the status of that button

              var euconEnable = sf.ui.proTools.mainWindow.groups.whoseTitle.is("EuCon View Cluster").first.buttons.whoseTitle.is("Enable EUCON").first
              if(euconEnable.invalidate().value.value == "Selected")
              log("EuCon is Enabled");
              else log("EuCon is Disabled");
              
              1. thanks @Sreejesh_Nair could you help me with how to code the rest for the sequence, then?

                1. if the button is on, i'd like to turn it off, and then turn it back on.
                2. if it is off. i'd like to turn it on.

                i'm really trying to learn more of this coding stuff so this is really helpful. i've been converting my macros to code to see what things are called. is there another way to see what windows and buttons are called?

                1. SSreejesh Nair @Sreejesh_Nair
                    2023-11-15 06:05:24.545Z

                    Try the below code. It should work. I've used the try catch to suppress the error because it always throws a kAXErrorCannotComplete on my system

                    sf.ui.proTools.appActivateMainWindow();
                    var euconFlag = 0; // Flag to indicate if the first block has been executed. 
                    var euconEnable = sf.ui.proTools.mainWindow.groups.whoseTitle.is("EuCon View Cluster").first.buttons.whoseTitle.is("Enable EUCON").first;
                    
                    // If the button's value is "Selected", run the first block
                    if (euconEnable.invalidate().value.value == "Selected") {
                        try {
                            euconFlag = 1; // Set the flag to indicate this block has been executed. The flag is set here because for some reason soundflow exits the if loop after the below command.
                            sf.ui.proTools.mainWindow.groups.whoseTitle.is("EuCon View Cluster").first.buttons.whoseTitle.contains("EUCON").first.elementClick();
                            sf.wait({ intervalMs: 500 });
                        }
                        catch (error) {
                            // Error handling if needed
                        }
                    }
                    
                    // If the button's value is not "Selected" or the first block has been executed, run the second block
                    if (euconEnable.invalidate().value.value == "" || euconFlag == 1) {
                        try {
                            sf.wait({ intervalMs: 500 });
                            sf.ui.proTools.mainWindow.groups.whoseTitle.is("EuCon View Cluster").first.buttons.whoseTitle.contains("EUCON").first.elementClick();
                        }
                        catch (error) {
                            // Error handling if needed
                        }
                    }
                    
                    ReplySolution