我是尝试使用来学习AppleScript。你在我的第一个雄心勃勃的项目的一部分下看到了什么。如果您还打开了“文本编辑”窗口,则会对其进行修改,以便在AppleScript编辑器中进行测试。使用变量时无法对齐窗口→无法将{“string ”}转换为整型
脚本的作用:
- 从列表中选择编辑
- 对准两个打开的窗口
我的问题:
对齐窗户只能如果我解雇变量。只要我将变量从返回的列表(selectedEditor
)与字符串tell process "TextEdit"
一起使用。
我希望有人可以发现错误。从事件
错误代码日志:
System Events got an error: Can’t make {"TextEdit"} into type integer.
下面的代码:
property myEditors : {"TextEdit", "Sublime Text 2"}
set the editorList to myEditors as list
set selectedEditor to choose from list the editorList
set lngWidth to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Width")
set lngHeight to word 3 of (do shell script "defaults read /Library/Preferences/com.apple.windowserver | grep -w Height")
set lngHalf to lngWidth/2
set lngHeight to lngHeight - 22
tell application id "sevs"
tell process selectedEditor to tell window 1 to set {position, size} to {{lngHalf, 22}, {lngHalf, lngHeight}}
tell process "AppleScript Editor" to tell window 1 to set {position, size} to {{0, 22}, {lngHalf, lngHeight}}
end tell
这是问题的解决方案。谢谢@ regulus6633。 ///我的完整脚本仍然无法工作,但我设法找到了'其他错误',现在一切正常。 – pattulus