Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos AppleScript单击对话框_Macos_Applescript - Fatal编程技术网

Macos AppleScript单击对话框

Macos AppleScript单击对话框,macos,applescript,Macos,Applescript,在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 & thefo

在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位于生成的包中

按下
命令+i
后,它会打开一个
“转到文件夹”
对话框,我需要单击
Go
,然后单击
Open


但是这样做,它将找不到对话框。我做错了什么?

如果Go和Open是默认按钮,请尝试:

tell application "System Events"
    keystroke return
    delay 2
    keystroke return
end tell
虽然我没有安装PCX,但这里有一个示例,说明如何从Finder的Go to Folder命令中单击Go按钮

tell application "System Events"
    tell process "Finder"
        click button "Go" of window "Go to Folder"
    end tell
end tell

您的脚本无法在AppleScript编辑器中工作的原因是“路径到我”中的“我”是运行AppleScript的应用程序。在AppleScript编辑器中运行AppleScript时,这意味着AppleScript编辑器本身。当您将AppleScript保存为脚本应用程序并运行它时,指向我的路径指向您的脚本应用程序,因为它正在运行自己的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脚本编写很复杂。

这是我为使其正常工作所做的,但出于学习目的,我想知道如何模拟单击功能。。。谢谢:)