i often find that my mac - who works with 2 screens in the office - not always remembers the screen where the app was closed. I also want to switch screens sometimes for apps - e.g. with launch bar - so i started searching and cominbing an apple script but it doesn't work properly.
if an app is full screen mode, the script just changes the canvas of the app - Safari page - and not the full app, so i decided to check, the status and do exit "fullscreen" and switch afterwards. This results in the problem, that the script exits full screen and on the second attempt, the screen is switched… im a novice so I don't know what to do anymore.
Working on Mavericks…
# by kg
# Version 1.0
# Date: Do. 20. März, 2014
# isFullscreen and toggleFullscreen from http://stackoverflow.com/questions/8215501/applescript-use-lion-fullscreen
set leftScreen to {-1440, 0}
set rightScreen to {0, 0}
set wasFullScreen to false
set myParam to isFullScreen()
if myParam is equal to true then
toggleFullScreen()
set wasFullScreen to true
end if
log "end if 1 - toggle fullscreen to little"
changepos()
if wasFullScreen is equal to true then
toggleFullScreen()
end if
log "end if 2 - toggle fullscreen state to old"
on changepos()
tell application "System Events"
set theName to name of the first process whose frontmost is true
set winPos to get position of first window of application process theName
log "habe position von Fenster von " & theName & winPos
--display dialog "na supa"
if (item 1 of winPos is greater than or equal to "0") then
set position of first window of application process theName to {-1440, 0}
--display dialog "left screen"
else
set position of first window of application process theName to {0, 0}
--display dialog "right screen"
end if
end tell
--display dialog "aus"
return true
end changepos
on isFullScreen()
tell application "System Events"
try
tell front window of (first process whose frontmost is true)
return get value of attribute "AXFullScreen"
end tell
end try
end tell
return false
end isFullScreen
on toggleFullScreen()
set isFullScreenAfter to false
tell application "System Events"
try
tell front window of (first process whose frontmost is true)
set isFullScreen to get value of attribute "AXFullScreen"
set isFullScreenAfter to not isFullScreen
set value of attribute "AXFullScreen" to isFullScreenAfter
end tell
end try
end tell
return isFullScreenAfter
end toggleFullScreen