Hi
I am trying to retrieve the application process with name "QuickTime Player" to then run some follow up logic on every window of it.
As part of an instruction to application "System Events", the commented out method works when executed from Script Editor but seems to return nothing via BTT while the iterative method works for both.
Q1: What is the nature of the BTT limitation in this regard?
Although the iterative method does work in BTT, the follow-up action to get all the windows of the process in BTT comes back empty where again it works fine in Script Editor.
Q2: How can I get around this obstacle?
Thx
Objective 1: Get application process for QuickTime Player
--set QT to application process "QuickTime Player"
repeat with p in (every application process)
if name of p = "QuickTime Player" then
set QT to p
end if
end repeat
Objective 2: Retrieve all windows for that process
set allWindows to every window of QT
...so I think I have new insight on my own reported issues and have at least found a viable workaround.
My script runs fine directly from Script Editor but when I export it as an app, it fails as "not allowed assistive access", no matter that I have granted it access in Privacy & Security > Accessibility and set it to run local. I’ve tried every suggestion I can find about various ways of adding it to Accessibility, removing, locking and unlocking, rebooting. deleting app and re-exporting, after each edit, all to no avail exactly as described by the poster in this post .
My best guess is that I am running into some variant of the same privilege problem with the script in BTT but the error is silent.
Just as the poster in the post above, the only solution I found was to save the script as a an app in Automator and invoke the Automator app from BTT. I can live with the workaround but would prefer to run the script from BTT. Any suggestions welcome to solve this issue.
Thanks
Mhh you could try to reset your TCC database (make sure to quit BTT first), this sometimes helps with weird permission issues.
sudo tccutil reset All com.hegenberg.BetterTouchTool
You can also try this simpler script:
tell application id "com.apple.QuickTimePlayerX" to set allWidnows to (every window)
Thanks!
Switching to asking for windows from Quicktime directly instead of from "System Events' did the trick.
Result wasn't bad when I invoking a separate application but it was a little more laggy and I could get an error if I did too many things too fast on the desktop. Works better with the script in BTT
Ah maybe BTT was missing permission to automate System Events? In System Settings => Privacy & Security => Automation