AppleScript - 无法单击“保存(名称)”字段

问题描述 投票:0回答:1

重复脚本在“保存”对话框中键入文件名。 有时未选择名称字段,因此我想用“单击 {1080, 188}”来单击它......但没有任何反应。 坐标是正确的,因为我也在对话框中测试了菜单,效果很好。 不适用于 Apple Preview 或 Chrome。

on run {input, parameters}
    delay 3
    tell application "System Events"
        click at {1080, 188}  -- does nothing, the save field
        delay 3
        click at {1010, 725}  -- works, clicks the menu
        delay 3
    end tell
    return input
end run

谢谢。

dialog applescript
1个回答
0
投票

答案是该对话框未命名为“另存为”,它是一个属于生成它的窗口的窗口。

    -- focus on Save As field
    tell process "((the app name))"
        -- Ensure the correct window is frontmost
        set frontmost to true
        repeat with w in windows
            if name of w is "((title of the window that sourced the Save dialog...a dialog is not a window))" then
                set index of w to 1
                exit repeat
            end if
        end repeat
        
        -- Check if the Save dialog is open
        if exists sheet 1 of window 1 then
            tell sheet 1 of window 1
                -- Focus on the "Save As" field
                if exists text field 1 then
                    set value of text field 1 to "" -- Optionally clear the field
                    set focused of text field 1 to true
                end if
            end tell
        end if
    end tell
© www.soinside.com 2019 - 2024. All rights reserved.