macos - 并行运行 AppleScript 处理程序
问题描述
我想并行运行这个 AppleScript 处理程序两次(所以我希望两个调用tillSideBySideWindows("right")
异步运行而不是彼此之后),有没有办法做到这一点?
on tillSideBySideWindows(direction)
tell application "System Events"
set allVisibleProcessNames to name of processes whose visible is true
repeat with processName in allVisibleProcessNames
set windowsOfCurrentApp to every window of application process processName
repeat with currentWindow in windowsOfCurrentApp
set currentWindowsSize to size of currentWindow
set currentWindowsWidth to item 1 of currentWindowsSize
set currentWindowsPosition to position of currentWindow
set currentWindowsLeftPos to item 1 of currentWindowsPosition
if currentWindowsLeftPos = 0 then
if direction = "right" then
set currentWindowsWidth to currentWindowsWidth + 30
else
set currentWindowsWidth to currentWindowsWidth - 30
end if
set currentWindowsHeight to item 2 of currentWindowsSize
set winName to name of currentWindow
set size of window winName of application process processName to {currentWindowsWidth, currentWindowsHeight}
end if
if (currentWindowsLeftPos + currentWindowsWidth) = 1680 then
set currentWindowsHeight to item 2 of currentWindowsSize
if direction = "right" then
set currentWindowsLeftPos to currentWindowsLeftPos + 30
set currentWindowsWidth to currentWindowsWidth - 30
else
set currentWindowsLeftPos to currentWindowsLeftPos - 30
set currentWindowsWidth to currentWindowsWidth + 30
end if
set winName to name of currentWindow
set position of window winName of application process processName to {currentWindowsLeftPos, 0}
set size of window winName of application process processName to {currentWindowsWidth, currentWindowsHeight}
get currentWindowsWidth
end if
end repeat
end repeat
end tell
end tillSideBySideWindows
tillSideBySideWindows("right")
解决方案
推荐阅读
- x86-16 - 可编程中断控制器(PIC)使用主从协议最多可以保存 64 个中断向量。其他的呢?
- javascript - 如何将属性转换为布尔值(深)
- c++ - 从 std::string 中提取信息
- reactjs - 如何获取嵌套组件道具?
- mysql - 如何使用 MySql 根据时间间隔获取 id
- node.js - lambda 函数如何执行后台计时器?
- kotlin - Kotlin - 如何将字符串连接到 Int 值?
- siddhi - 如何解决 siddhi 中的“为表 id 创建索引时出错”错误?
- node.js - 如何在node js中使用then之外的promise返回数据并sequelize?
- mule - 在 mule 4 中调用 Oracle 函数