首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >切换屏幕自动化脚本

切换屏幕自动化脚本
EN

Stack Overflow用户
提问于 2014-03-28 20:44:56
回答 1查看 626关注 0票数 1

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

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

使用Mavericks…

代码语言:javascript
复制
# 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
EN

回答 1

Stack Overflow用户

发布于 2015-01-20 00:09:40

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

Cheers.kg

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22713266

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档