Macos AppleScript—;按名称字符串获取应用程序
这段代码运行良好Macos AppleScript—;按名称字符串获取应用程序,macos,applescript,Macos,Applescript,这段代码运行良好 tell application "System Events" set bounds of window "File" of application "TextEdit" to {0, 0, 0, 0} end tell 这个代码不起作用。如何解决这个问题 tell application "System Events" set appName to "TextEdit" set bounds of window "File" of applicat
tell application "System Events"
set bounds of window "File" of application "TextEdit" to {0, 0, 0, 0}
end tell
这个代码不起作用。如何解决这个问题
tell application "System Events"
set appName to "TextEdit"
set bounds of window "File" of application appName to {0, 0, 0, 0}
end tell
你在谈论两件不同的事情
在这种情况下,不需要
系统事件
,但目标应用程序的名称必须是文本字符串(编译时对术语的评估)
系统事件
并指定应用程序进程。可以在变量中传递目标进程的名称
tell application "System Events"
set appName to "TextEdit"
tell process appName
set bounds of window "File" to {0, 0, 0, 0}
end tell
end tell
在这两种情况下,都不能保证目标应用程序或目标进程具有包含
bounds
属性的window
元素。您谈论的是两件不同的事情
在这种情况下,不需要
系统事件
,但目标应用程序的名称必须是文本字符串(编译时对术语的评估)
系统事件
并指定应用程序进程。可以在变量中传递目标进程的名称
tell application "System Events"
set appName to "TextEdit"
tell process appName
set bounds of window "File" to {0, 0, 0, 0}
end tell
end tell
bounds
属性的window
元素