在PCSX中,(ps1模拟器),我试图自动执行播放iso的步骤。所以,我这样做:
set thepath to path to me
set thesecondpath to POSIX path of thepath
set thethirdpath to "Contents/PSX/ROMS/img.bin"
set thefourthpath to "/Contents/PSX/PCSX.app"
set thefifthpath to thesecondpath & thefourthpath
set theultimatepath to thesecondpath & thethirdpath
tell application thefifthpath
activate
tell application "System Events"
keystroke "i" using {command down}
keystroke theultimatepath
delay 1.0
tell process "PCSX"
click button "Go"
end tell
key code 53
end tell
end tell
从AppleScript编辑器运行将无法工作。我让它从它创建的应用程序运行。PCSX和img.bin在生成包中。
按下command+i
后会打开"Go to the folder"
对话框,我需要按下Go
再按下Open
但是这样做,它不会找到对话框。我做错了什么?
如果Go和Open是默认按钮,尝试:
tell application "System Events"
keystroke return
delay 2
keystroke return
end tell
虽然我没有安装PCX,这里有一个例子,如何从Finder的转到文件夹命令点击转按钮。
tell application "System Events"
tell process "Finder"
click button "Go" of window "Go to Folder"
end tell
end tell
你的脚本不能在AppleScript编辑器中工作的原因是" path to me "中的" me "是运行AppleScript的应用程序。当你在AppleScript编辑器中运行AppleScript时,这意味着AppleScript编辑器本身。当您将AppleScript保存为脚本应用程序并运行它时,路径指向me,因为它正在运行自己的AppleScript。
同样,这是不正确的:
tell process "Finder"
click button "Go" of window "Go to Folder"
end tell
"Go"按钮不在"Go to Folder"窗口上。它在一个表格上,附在Finder窗口上,该窗口有当前正在查看的文件夹的名称。所以你必须将按钮描述为位于窗口1的页1上:
tell application "System Events"
tell process "Finder"
click button "Go" of sheet 1 of window 1
end tell
end tell
…但请记住,在另一个应用程序中,一个类似的按钮在一个表单上可能是在第3个窗口的第2组的第1组的第1页上。UI脚本很复杂