web-dev-qa-db-ja.com

1回のキーストロークでモニター間でウィンドウを自動的に移動するにはどうすればよいですか?

Windowsには、ボタンをクリック(またはキーストローク)するだけで2台のモニター間でアプリケーションウィンドウを移動できる、このすばらしい小さなアプリがありました。

モニター内ではウィンドウの位置を変更しますが、モニター間では変更しないアプリケーションを知っています。

実際にそのようなアプリケーションがあるかどうか知っていますか?

3
btelles

私は次のAppleScriptを使用して、あなたが求めていることを実行します。現在、画面は同じサイズで並べて配置されていると想定していますが、他の場合は比較的簡単に変更できるはずです。キーストロークコマンドでAppleScriptを実行するための多くの手法が存在します。個人的には バトラー を使用しています。

tell application "Finder"
    set _bounds to bounds of window of desktop
    set _width to item 3 of _bounds
end tell

set left_width to _width / 2

tell application "System Events"
    tell (first process whose frontmost is true)
        tell first window
            set {x, y} to (get position)
            if x < left_width then
                set position to {x + left_width, y}
            else
                set position to {x - left_width, y}
            end if
        end tell
    end tell
end tell
1
Jason T. Miller

クイック検索では、探している機能を含むいくつかのアプリケーションが見つかりますが、どれも無料ではないようです。彼らには試練があります。無料のものを見つけたらお知らせします。

SizeUp最適なレイアウトWindowMover 。 SizeUpは、Cinchと同じメーカーによって製造されており、最も軽量であるように見えるため、3つの中で最高のようです。

2
Vervious

BetterTouchツールをお試しください。発売当初から使用しており、見事に動作します。何よりも、絶対に無料です!しかし、アプリは絶対に素晴らしいので、開発者に寄付してください!

0
Jose

Linuxの場合、私はまだ解決策を探しています。

UltraMonは、Windowsの問題をうまく解決するシェアウェアです。

次のスクリプトはApple Mac OSXで使用できます。ショートカットはQuicksilverで作成できます

--  Window Moving Script between multiple monitors for Apple Mac OS X 10.x
-- (something I've been doing with UltraMon for quite a while)
--  inspired by:
--     http://www.tidbits.com/webx?14@@.3c7b1ae3/5
--     http://macscripter.net/viewtopic.php?id=24511
-- and http://daringfireball.net/2006/12/display_size_applescript_the_lazy_way
-- thanx for the input ... I was looking for a solution of this quite a while
-- best to be used with a custom trigger in Quicksilver where this script is assigned to a
-- keyboard short cut (I use ALT Cursor-Right) 
-- you might want to put Quicksilver into your Autostart Objects
-- 2009-09-14 Wolfgang Fahl

--
-- get the front Window
-- 
on getFrontWindow1()
    tell application "System Events"
        set theFrontWindow to first window of (first process whose frontmost is true)
        -- set theFrontWindow to the front window
        set windowname to name of theFrontWindow as string
        say "Moving" & windowname
        --display dialog "front most windows is " & name of  theFrontWindow buttons ("Cool") giving up after 3 default button 1
        return theFrontWindow
    end tell
end getFrontWindow1
--
-- get the front Window
-- 
on getFrontWindow()
    tell application "System Events"
        repeat with theapp in (every application process whose visible is true and frontmost is true)
            repeat with ew in (every window of theapp)
                return ew
            end repeat
        end repeat
    end tell
end getFrontWindow
--
-- list all windows
--
on listWindows()
    tell application "System Events"
        repeat with theapp in (every application process whose visible is true and frontmost is true)
            repeat with ew in (every window of theapp)
                set windowname to name of ew as string
                say windowname
            end repeat
        end repeat
    end tell
end listWindows

--
-- message dialog
--
on show(aMessage)
    -- display a dialog with a message
    display dialog aMessage buttons {"Ok"} default button "Ok"
end show

--
-- get the screen information
--
on getScreenInfo(theIndex)
    -- get the Screen Information from the windowserver defaults
    -- we are using awk to go to the DisplaySets sections and assume that Active = ... is
    -- at the start of each section
    -- we'll find OriginX= ...,OriginY= ..., Width = ... and Height= ... entries
    -- and return all of them a a list like
    -- 0 0     1920 1200
    -- 0 1920  1650 1050
    set screenInfo to do Shell script "defaults read /Library/Preferences/com.Apple.windowserver | awk '
        BEGIN { FS=\"=\" }
        /Active/  { screens++ }
        { gsub(\";\",\"\",$2) }
        /^ *OriginX/ { ox[screens] = $2 }
        /^ *OriginY/ { oy[screens] = $2 }
        /^ *Width/   { w[screens]  = $2 }
        /^ *Height/  { h[screens]  = $2 }
        END       {
                for (si=1;si<=screens;si++) {
                    print ox[si],oy[si],w[si],h[si]
                    }
            }'"
    set theInfo to paragraph theIndex of screenInfo
    return {Word 1 of theInfo, Word 2 of theInfo, Word 3 of theInfo, Word 4 of theInfo}
end getScreenInfo

--
-- move the front window to another monitor
--
tell application "System Events"
    -- get the OffsetX,OffsetY,Width and Height information for the screens
    -- here we assume that two screens are present (without checking this ...)
    -- first screen info
    set theScreen1 to getScreenInfo(1) of me

    -- second screen info
    set theScreen2 to getScreenInfo(2) of me

    -- for the functionality of this script we are happy with the resolution info for the time being
    set startX to item 1 of theScreen1
    set startY to item 2 of theScreen1
    set resolutionX to item 3 of theScreen1
    set resolutionY to item 4 of theScreen1

    set startX2 to item 1 of theScreen2
    set startY2 to item 2 of theScreen2
    set resolutionX2 to item 3 of theScreen2
    set resolutionY2 to item 4 of theScreen2

    -- make some nois to let everybody know we have receive the command
    beep

    -- 1st, determine current X & Y Positions of the current front window
    set theWindow to getFrontWindow() of me
    set thePosition to position of theWindow

    -- uncomment this if you'd like to debug
    -- display alert name of theWindow & ": " & ((first item of thePosition) as string) & ", " & ((second item of thePosition) as string) & " screen1:" & (startX as string) & "," & (startY as string) & "-" & (resolutionX as string) & "," & (resolutionY as string) & " screen2:" & (startX2 as string) & "," & (startY2 as string) & "-" & (resolutionX2 as string) & "," & (resolutionY2 as string)
    set currXPos to (first item of thePosition)
    set currYPos to (second item of thePosition)

    -- are we on the first monitor?
    if currXPos < resolutionX / 2 then
        -- move right
        set newX to currXPos + resolutionX
        set newY to currYPos - startY2
    else
        -- move left
        set newX to currXPos - resolutionX
        if newX < startX then
            set newX to startX
        end if
        set newY to currYPos + startY2
    end if
    -- Now we move the window moveX pixels to the right (or left if negative)
    set position of theWindow to {(newX), (newY)}
end tell
0
Wolfgang Fahl