Mac:利用AppleScript移动窗口

Mac:利用AppleScript移动窗口

1. 放到/Library/Scripts里,例如用Spark设置快捷键全局启动

2. 把这些代码放到spark里面,让spark来执行速度会非常快,比放在系统里会快很多

Move Window Left.scpt:

tell application "System Events"

set _everyProcess to every process

repeat with n from 1 to count of _everyProcess

set _frontMost to frontmost of item n of _everyProcess

if _frontMost is true then set _frontMostApp to process n

end repeat

set _windowOne to window 1 of _frontMostApp

set pos to position of _windowOne

set y to item 2 of pos

set position of _windowOne to {0, y}

end tell


Move Window Right.scpt:

--set _screenWidth to 1440 -- Change this number to your screen width


tell application "Finder"

set _b to bounds of window of desktop

set _screenWidth to item 3 of _b

end tell


tell application "System Events"

set _everyProcess to every process

repeat with n from 1 to count of _everyProcess

set _frontMost to frontmost of item n of _everyProcess

if _frontMost is true then set _frontMostApp to process n

end repeat

set _windowOne to window 1 of _frontMostApp

set pos to position of _windowOne

set y to item 2 of pos

set _size to size of _windowOne

set _width to item 1 of _size

set position of _windowOne to {_screenWidth - _width, y}

end tell

 

你可能感兴趣的:(Mac:利用AppleScript移动窗口)