How to ask Soundflow to recognize the state of an app?
Title
How to ask Soundflow to recognize the state of an app?
What do you expect to happen when you run the script/macro?
Hi! Very new to anything like this - so sorry if this is a stupid question.
Looking to make this macro do a T/F with different outcomes around wether there is a window present.
I see an option to wait for UI... but I'm not sure how to set up an alternate chain of commands...
Idealy I'm looking for this from the Macro
Ensure that the app is running. (there is a macro for this already so that one is easy)
IF there is a "New Tab" window THEN proceed to the rest of the task
IF there IS NOT a "New Tab" windown THEN PRESS KEYS THEN proceed to the rest of the task.
Thanks in advance for helping!
Are you seeing an error?
What happens when you run this script?
It works fine under certain states of the app... but I want it to work regardless.
How were you running this script?
I clicked the "Run Script" or "Run Macro" button in SoundFlow
How important is this issue to you?
3
Details
{ "inputExpected": "Hi! Very new to anything like this - so sorry if this is a stupid question. \n\nLooking to make this macro do a T/F with different outcomes around wether there is a window present. \n\nI see an option to wait for UI... but I'm not sure how to set up an alternate chain of commands...\n\nIdealy I'm looking for this from the Macro\n\nEnsure that the app is running. (there is a macro for this already so that one is easy)\n\nIF there is a \"New Tab\" window THEN proceed to the rest of the task\n\nIF there IS NOT a \"New Tab\" windown THEN PRESS KEYS THEN proceed to the rest of the task.\n\nThanks in advance for helping!", "inputIsError": false, "inputWhatHappens": "It works fine under certain states of the app... but I want it to work regardless.", "inputHowRun": { "key": "-MpfwYA4I6GGlXgvp5j1", "title": "I clicked the \"Run Script\" or \"Run Macro\" button in SoundFlow" }, "inputImportance": 3, "inputTitle": "How to ask Soundflow to recognize the state of an app?" }
Source
//Macro converted to script
sf.ui.app('com.google.Chrome').appEnsureIsRunningAndActive({
timeout: 200,
});
sf.ui.app('com.google.Chrome').appWaitForActive();
sf.ui.app("com.google.Chrome").mainWindow.groups.whoseTitle.is("New Tab - Google Chrome").first.groups.first.groups.first.elementWaitFor({
failIfNotFound: false,
});
sf.keyboard.press({
keys: "cmd+n",
});
sf.wait({
intervalMs: 200,
});
/* sf.ui.app("com.google.Chrome").mainWindow.groups.whoseTitle.is("New Tab - Google Chrome").first.groups.first.groups.first.groups.first.children.whoseRole.is("AXToolbar").whoseDescription.is("Bookmarks").first.popupButtons.whoseDescription.is("Work").first.mouseClickElement({
isRightClick: false,
isCommand: true,
}); */
/* sf.wait({
intervalMs: 200,
}); */
/* sf.keyboard.press({
keys: "cmd+w",
}); */
//Calling command "Set Test to True" from package "undefined" (installed from user/pkg/version "srAasovvDiQacRZ2mcId4RrOA8R2/ckuxffxq80000u010m7g02u3l/ckykkhblv00005010vnzhi0gm")
sf.soundflow.runCommand({
commandId: 'user:ckuxffxq80000u010m7g02u3l:ckuxgs46b000ju010pxapxtz6#ckuxgu14y000ku0103461nr89',
props: {}
});
Links
User UID: 8viguOCyXKRe5nEEk7ymbBChxlJ2
Feedback Key: sffeedback:8viguOCyXKRe5nEEk7ymbBChxlJ2:-NMAiyHHBp_3zDvzH9-f
- Chris Shaw @Chris_Shaw2023-01-21 18:51:05.956Z2023-01-21 18:57:38.445Z
Whenever possible you should avoid using key presses in your script if there are menu items available that do the same thing.
So instead ofkeys: "cmd+n"
you should usemenuClick
and click "New Window" instead (line 15) - there's also a macro action for this ("Click Menu Item").
You can do the same thing withcmd+w
in your script above (line 32).
I didn't include the rest of your script because I'm not 100% sure what it is you're trying to do.
//Make reference to Chrome application const chrome = sf.ui.app('com.google.Chrome'); chrome.appEnsureIsRunningAndActive({ timeout: 200, }); chrome.appWaitForActive(); // make reference to "New Tab" window const newTabWindow = chrome.windows.whoseTitle.is("New Tab - Google Chrome").first //Open new window if New Tab window does not exist if (!newTabWindow.exists) { chrome.menuClick({ menuPath: ["File", "New Window"] }) } sf.wait({ intervalMs: 200, }); // Focus New Tab Window newTabWindow.elementRaise(); //New Tab window exists or is created and focused -> continue with the rest of your script below
Hope this helps
//CS//