0

I'm trying to adapt an AppleScript that is using System Events, based on calling the front window of the application I want to control.

The script is working okay if the application is in the same Space1 as Script Editor.

The window is called Global, and the app is Capture One 11.

tell application "System Events"
    repeat with theTbarGroup in (get groups of toolbar 1 of window "Global" of application process "Capture One 11")
        ...
    end repeat
end tell

But I get an error when there's more then one Space and that application's window is in different Space then Script Editor:

error "Error in System Events : Impossible to get window \"Global\" of application process \"Capture One 11\"." number -1728 from window "Global" of application process "Capture One 11"

I've read that Spaces are not scriptable, so I wonder what could be the solution?


1The Spaces that you can define in Mission Control, which create some kind of virtual desktops.

  • I do not the Capture One app to test with; however, if you use activate application "Capture One 11" prior to tell application "System Events", it should take you to that Space, at which point the remaining code can proceed with that window being visible. You might also have to add a delay 0.5 command after the activate command to allow time for the switch to the other Space. It's not a pretty solution as it's visually disruptive, but it's a place to start. – user3439894 May 17 at 14:30
  • Thank you. Actually, I'm not sure this would be very practical because the script is logging information in itself so it might need to go back and forth between Spaces. But the main reason to decline is because you answer made me realize my main motive was to have the script work in background while I could do other things (it's a very slow script, more than a hour). Which obviously is not possible if it activates another space. Which makes me wonder if I have understood correctly how System Events works. For the record I am using System events for UI scripting because of C1 AS incompleteness – Hugues May 18 at 15:19

You must log in to answer this question.

Browse other questions tagged .