我似乎无法弄清楚为什么此代码在子例程之外仍然可以正常工作,但是将其复制到子例程并运行时却出现错误。
我已经尝试了一切,并用Google搜索了几个小时。任何帮助表示赞赏。
原始代码
tell application "iTerm"
if not (exists window 1) then reopen
tell application "iTerm" to activate --activate or open if closed
tell application "iTerm" to reopen -- un-minimize if minimized
tell application "iTerm" to set the bounds of the first window to {0,23,960,1080}
end tell
子例程代码
on MoveWindowScripted(app2move,windowPosition) -- last step not working for some reason...
tell application app2move
if not (exists window 1) then reopen
tell application app2move to activate --activate or open if closed
tell application app2move to reopen -- un-minimize if minimized
tell application app2move to set the bounds of the first window to {0,1080}
end tell
end MoveWindowScripted
MoveWindowScripted(app2,LbottomLeft)
我希望两种情况都能得到相同的结果。该窗口应激活并移至某个位置。它适用于第一个代码,但不适用于子例程。我收到消息“便笺出现错误:无法将应用程序“便笺”设置为{0,23,960,1080}。”但是,当我更新子例程并替换此行“告诉应用程序app2move将第一个窗口的边界设置为{0,23,960,1080}”时,用此“告诉应用程序”注释”来设置第一个窗口的边界到{0,23,960,1080}”,效果很好。