let result = await runAppleScript({script: "presetfile://MCC/as/some.scpt"})
let actionDefinition = {
"BTTPredefinedActionType" : 172,
"BTTPredefinedActionName" : "Run Apple Script (blocking)",
"BTTAppleScriptFilePath" : "presetfile://MCC/as/some.scpt"",
};
let result = await callBTT('trigger_action', {json: JSON.stringify(actionDefinition)});
using preset paths for applescripts would be useful any guides for this
also i couldn find a way for activate btt then highlight a btt trigger ( with given UUID ) with applescript, i can guide user to related trigger when they want to change a setting
Good idea, I don't think it's curently possible to show/highlight a specific trigger but I can definitely add that.
Currently the runAppleScript function wants the Apple Script as string, not the path to the script. However you could use the run shellScript function like this:
( async ()=> {
let shellScriptWrapper = {
script: 'osascript "BTT_PRESET_PATH/some.scpt"', // mandatory
launchPath: '/bin/bash',
parameters: '-c'
};
let result = await runShellScript(shellScriptWrapper);
returnToBTT(result);
})()
I believe it's the same issue that I've encountered the other day. BTT_PRESET_PATH is not escaping spaces properly in AppleScript, \ is needed before spaces whereas only one \ is present.
Andreas said it would be fixed in next alpha, stay tuned
Oh I think I actually didn't see your edit where you reported that issue My reply was to the other point
To get the path escaped use BTT_PRESET_PATH_ESCAPED. Usually you can also just wrap the path that contains spaces in quotes. The situation where spaces are currently not supported is when running shell scripts and using the BTT_PRESET_PATH variable in the parameter field, which is kind of a special case.
my problem is my script working on btt interface as you suggested but not working on floating web view
this one working on web view
osascript "/Users/xxx/Library/Application\ Support/BetterTouchTool/PresetBundles/57FD4165-C9CC-4D74-ADF4-6DEE2C49A7D9MCC/MCC/as/CalendarYearView.scpt"
but these two didnt work
osascript "BTT_PRESET_PATH_ESCAPED/MCC/as/CalendarYearView.scpt"
osascript "BTT_PRESET_PATH/MCC/as/CalendarYearView.scpt"
This looks great so far! I also like the buttons on the side of the Clipboard manager as opposed to the dropdown before. I've two questions regarding this:
Can this be used to replace a lot of Automator/AppleScript Services from years ago which perform similar text modifications? Does it have performance implications?
With the Services, one didn't need to use the clipboard but just operate on text which was selected. I use Launchbar along with BTT which also allows picking up any object File/Folder/SelectedText/etc. and run scripts over it. Could BTT be instead made to operate on selected objects like that instead of first putting them in Clipboard? This could allow storing all scripts in BTT itself as opposed to some in Launchbar and some in Automator.
I would expect performance to be better than automator / apple scripts because no extra process needs to be started.
You can already run scripts on selected text without explicitly using the clipboard, however in the background BTT still uses the clipboard. I plan to integrate a service that can access the selected text, so the clipboard becomes obsolete soon.
In the latest alpha I also added a "Transform Selected Text using Java Script" action which is a bit easier to use than the Insert / Type / Paste action.
I use it to enable/disable media controls in certain apps automatically when they activate. The same code works fine in Script editor but doesn't work either automatically in BTT or even clicking Run manually.
Weird could you check whether the UUID is still correct? (in the alpha I have a database cleanup job which should remove duplicate UUIDs, which should not exist in the first place )
Yes, I checked the exact code in AppleScript Editor and it both enables/disables the button fine.
I also checked if "Specific app did activate" works by enabling the HUD and the HUD is triggered but the script fails.
Maybe for some reason the apple script runner processes are not launched. I'll check if I broke something! (maybe you can check whether activity monitor shows the BetterTouchToolAppleScriptRunner processes)
Update: I disabled "Run in background" in the script action and now it works again, both when running from the settings as well as automatically as before.