Dru*_*erB 10 macos cocoa applescript finder appleevents
我正在尝试使用AppleScript设置Messages.app聊天窗口的位置.
tell application "System Events"
set position of window 1 of application "Messages" to {100, 100}
end tell
Run Code Online (Sandbox Code Playgroud)
使用此代码我收到一个错误:
error "Messages got an error: Can’t set «class posn» of window 1 to {100, 100}."
number -10006 from «class posn» of window 1
Run Code Online (Sandbox Code Playgroud)
那是什么意思?
如果我使用Finder尝试相同的代码,它可以工作.但是大多数其他应用程序都不起作用.
Par*_*fna 12
tell application "System Events"
set position of first window of application process "Messages" to {100, 100}
end tell
Run Code Online (Sandbox Code Playgroud)
启用Access for assistive devices以运行此脚本.

我找到了解决方案.设置窗口的边界有效.我不知道为什么使用这个职位不起作用.
tell application "System Events"
set friendBounds to {4289, 400, 4479, 1600}
set chatBounds to {3583, 400, 4289, 1599}
set bounds of window "Buddies" of application "Messages" to friendBounds
set bounds of window "Messages" of application "Messages" to chatBounds
end tell
Run Code Online (Sandbox Code Playgroud)
截至撰写本文时,其他解决方案在 macOS 10.14 Mojave 上对我不起作用。我设法找到这个解决方案:
tell application "System Events" to tell process "Safari"
set position of window 1 to {0, 50}
set size of window 1 to {600, 650}
end tell
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14361 次 |
| 最近记录: |