点击按钮了解其名称的一部分

时间:2014-11-20 11:42:06

标签: macos button applescript

我需要点击一个不时更改名称的按钮:例如。 ("购买xxxx")。

第一部分"购买"是固定的,第二个是变化的。

我已经写了这段代码,但它没有按预期工作,你能帮助我吗?

tell application "System Events" to tell process "Aycc"
    if button "Buy(.*)" of window 1 exists then
        click button "Buy(.*)" of window 1
    end if
end tell

1 个答案:

答案 0 :(得分:1)

未经测试!尝试使用every ... whose ...子句查找按钮:

set buyButtons to every button of window 1 whose name begins with "Buy"
if buyButtons ≠ {} then
    click (first item of buyButtons)
end if

也许你必须尝试 title 而不是 name

问候,迈克尔/汉堡