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
- 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 })
- RIn reply torandy_matuszewski⬆:randy matuszewski @randy_matuszewski
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!!
- SSreejesh Nair @Sreejesh_Nair
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");
- Rrandy matuszewski @randy_matuszewski
thanks @Sreejesh_Nair could you help me with how to code the rest for the sequence, then?
- if the button is on, i'd like to turn it off, and then turn it back on.
- 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?
- In reply torandy_matuszewski⬆:SSreejesh Nair @Sreejesh_Nair
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 systemsf.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 } }