Hi everyone! My first post, and my first applescript. Definitely have the feeling of having stumbled into the rabbit hole
My problem is this: I am using Alfred to trigger an applescript by a hotkey to activate Terminal. Simple enough, but I like to use spaces and apps in fullscreen mode, so my terminal windows are usually assigned to their own space. I’m trying to get the following behaviour:
If my secondary screen is connected, and I have two terminal windows open, activate the terminal spaces on both screens. Otherwise, simply activate Terminal.
The following script almost does the job. However, not all the time. I haven’t been able to figure what the problem is in those cases when it doesn’t work. It will always display both terminal spaces if I press the hotkey twice
tell application "Image Events"
launch
set countDisplays to count displays
quit
end tell
if countDisplays > 1 then
tell application "Terminal"
repeat with aWindow in (get every window)
set frontmost of aWindow to true
activate
end repeat
activate
end tell
else
activate application "Terminal"
end if
I added the second activate, which caused the script to sometimes get the result I want, although I don’t really understand why…
I am running OSX Mavericks by the way.
Much appreciated.
Model: Macbook Pro
Browser: Safari 537.36
Operating System: Mac OS X (10.8)
Welcome to Macscripter. I didn’t know that windows in full screen mode open in their own windows. That’s nice! I’m trying to figure out how you make them full screen besides manually. It must be in the preferences or something.
Edited: oh I see. You already have the windows in full screen. I managed to duplicate your two windows moving to one space.
Still not sure what you’re trying to do. I don’t have two displays. But this show the cycling through the windows.
tell application "Terminal"
activate -- bring Terminal to front
set theWindows to every window
-- cycle through the windows
repeat with aWindow in theWindows
set frontmost of aWindow to true
delay 3 -- so you can see the cycling every three seconds
end repeat
end tell
Don’t know if you’re still there, but I got my new display and see what you’re trying to do.
There is no way you can have the same window in two different spaces. However, something like this would be to turn on mirroring which would mirror everything and not just the Terminal window. I think there is a way to turn on mirroring through script if you want to do that.