在OS X中使用AppleScript或终端重命名窗口标题

3

我正在尝试使用AppleScript更改窗口标题,但是没有成功。

告诉应用程序"Finder"将窗口"oldWinName"的名称设置为"newWinName"

也尝试了 调用(window "oldWinName")的方法"setTitle:"并带有参数{"newWinName"}

有什么想法吗?

问候


什么类型的窗口? - vadian
看起来使用Applescript不可能实现,"name"似乎是只读的:https://macosxautomation.com/applescript/firsttutorial/03.html - gwenzek
1个回答

2

哪个应用程序的窗口?

例如,对于terminal.app

tell application "Terminal"
    set custom title of window 1 to "hello world"   
end tell

或者,对于textedit.app。
tell application "TextEdit"
    set name of window 1 to "hello world"
end tell

大多数应用程序都会采用类似的方法 :)

1
osascript -e 'tell application "Terminal" to set name of front window to "hello world"' 命令并不会生效,Terminal.app 将保持原名称。 - localhostdotdev
@localhostdotdev 在“延迟1”之后你可以开始操作。 - Ivan Kramarchuk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接