【问题标题】:switch screen automator script切换屏幕自动机脚本
【发布时间】:2014-03-28 12:44:56
【问题描述】:

我经常发现我的 Mac(在办公室使用 2 个屏幕)并不总是记得关闭应用程序的屏幕。我有时也想为应用程序切换屏幕 - 例如带有启动栏 - 所以我开始搜索和组合一个苹果脚本,但它不能正常工作。

如果应用程序处于全屏模式,脚本只会更改应用程序的画布 - Safari 页面 - 而不是完整的应用程序,因此我决定检查状态并退出“全屏”并随后切换。这导致了问题,脚本退出全屏并且在第二次尝试时,屏幕被切换......我是新手,所以我不知道该怎么做。

在小牛队工作……

# 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

【问题讨论】:

    标签: applescript fullscreen osx-mavericks


    【解决方案1】:

    好的,我在 applescript 中找不到方法,但我发现了一个名为 BetterSnapTool 的应用程序,它非常简洁。它可以在屏幕之间切换,为你做更多的事情!

    干杯.kg

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-02-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多