Wie kann ich eine Anwendung mit dem Shell-Befehl in Mavericks in den Vollbildmodus versetzen?

Ich möchte sicherstellen, dass eine Anwendung mit einem Shell-Befehl (oder Skript) im Vollbildmodus ausgeführt wird. Ich habe einige Ansätze gesehen, die der Anwendung sagen, dass sie eine Tastenkombination ausführen soll ( cmd+ ctrl+ f), aber das wird den Vollbildmodus umschalten, nicht sicherstellen.

Antworten (1)

Hier ist ein AppleScript, das das kann. Pass trueoder , falseum den Modus zu wechseln. Das Skript verwendet den Wert von, AXFullScreenum festzustellen, ob sich die App gerade im Vollbildmodus befindet, und wechselt nur bei Bedarf.

Toggle an application from full screen to non full screen (or the reverse).
Parameters:
  1: application name(ie, Chrome)
  2: boolean (true/false).
     When true ensure that the application is in full screen mode (if not, make it so)
     When false ensure that the application is NOT in full screen mode (if not, make it so)
on run argv
  set theapp to item 1 of argv
    if item 2 of argv is "false"
    set toggleOnFull to true
    else
    set toggleOnFull to false
    end if

  tell application theapp
    activate
    delay 2
    (* 
      Initially from http://stackoverflow.com/questions/8215501/applescript-use-lion-fullscreen
    *)
    set isfullscreen to false
    tell application "System Events" to tell process theapp
      set isfullscreen to value of attribute "AXFullScreen" of window 1
    end tell
    --display dialog "var " & isfullscreen

    if isfullscreen is toggleOnFull then
      tell application "System Events" to keystroke "f" using { command down, control down }
      delay 2
    end if
  end tell
end run

Quelle: https://gist.githubusercontent.com/dsummersl/4175461/raw/36811eab78ca5e1a25fbd547a44b3d9c8d0d424d/makeFullScreen.applescript

Hallo @george-garside, ich habe das Skript ohne Erfolg ausprobiert. Ich bin auf Maverick und erhalte diesen Fehler: makeFullScreen.applescript:787:792: execution error: System Events got an error: osascript is not allowed assistive access. (-1719)beim Ausführen von CL osascript ~/Desktop/makeFullScreen.applescript HipChat true. Ich habe Chrome zu den Eingabehilfen-Apps in den OSX-Einstellungen hinzugefügt, erhalte aber denselben Fehler. Irgendwelche Ideen?
@dome Sie müssen osascript unterstützenden Zugriff gewähren: ausführensudo sqlite3 /Library/Application\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access VALUES('kTCCServiceAccessibility','/usr/bin/osascript',1,1,1,NULL)"
Wenn ich das getan habe, kann ich sehen, dass es das Osascript im Pref-Panel hinzufügt, aber ich bekomme immer noch den gleichen Fehler:osascript ~/Desktop/makeFullScreen.applescript HipChat true /Users/am/Desktop/makeFullScreen.applescript:787:792: execution error: System Events got an error: osascript is not allowed assistive access. (-1719)
Wenn jemand das zum Laufen gebracht hat, würde ich es als richtig markieren, aber aus irgendeinem Grund funktioniert es bei mir nicht. Irgendetwas muss mir hier fehlen :/