我希望applescript选择窗口第1页的文本字段2" App Store"申请流程" App Store"但它不起作用,为什么?

时间:2016-11-28 04:12:53

标签: macos applescript

我希望Applecript选择窗口第1页的文本字段2" App Store"申请流程" App Store" ,但它不起作用,为什么?怎么了?请帮我。谢谢! 当Apple ID已经存在时,我想选择文本字段2(Apple ID的文本字段),然后清除旧的应用程序ID,按键"另一个app id" enter image description here

这是我的苹果:

tell application "App Store" to activate
    delay 1
    tell application "System Events"
        try
            click menu item 12 of menu 1 of menu bar item 4 of menu bar 1 of application process "App Store"
        end try
    end tell
    delay 1

    tell application "System Events"
        delay 2
        select text field 2 of sheet 1 of window "App Store" of application process "App Store"
        key code 51 using {command down, shift down}
        keystroke " another app id"
        keystroke tab
        keystroke "password"
        key code 36
    end try
end tell

2 个答案:

答案 0 :(得分:0)

我认为你不需要先选择它。我可以设置字段的值。 但是现在我的机器上的密码字段索引是1而不是2(这里是osx 10.10.5)。登录字段是索引2.

我可以执行以下操作将字段2设置为我想要的任何内容,只要以下内容位于“App Store”的tell块中,该“App Store”位于“系统事件”的tell块中:

set value of text field 1 of sheet 1 of window "App Store" to someValue

答案 1 :(得分:0)

您的初始脚本非常接近。这些更改应该适合您。

tell application "App Store" to activate
delay 1
tell application "System Events"
    try
        click menu item 12 of menu 1 of menu bar item 4 of menu bar 1 of application process "App Store"
    end try
end tell
delay 1
tell application "System Events"
    delay 2
    set value of text field 2 of sheet 1 of window "App Store" of application process "App Store" to "enter_the_account_you_want_to_use" -- put the account name in between those quotes
    keystroke tab
    keystroke "password"
    delay 1
    key code 36
end tell