使用AppleScript输入登录信息

时间:2017-10-26 00:44:37

标签: applescript

我正在使用AppleScript输入登录信息,并在脚本将信息输入密码字段并且"击键返回"即使我确信我在我的脚本中传递了正确的密码,表单也会告诉我我的密码不正确。

有谁知道为什么会这样?

tell application "Safari"
    activate
    open location "https://thewebsite.com"
end tell

delay 10
clickClassName("login", 0)
delay 2

tell application "Safari"
    tell application "System Events" to tell process "Safari"
        keystroke tab
        keystroke "MyPassword"
        keystroke return
    end tell
end tell

1 个答案:

答案 0 :(得分:0)

tell application "Safari"   
    activate   
    open location "https://thewebsite.com"   
end tell   

delay 10   
clickClassName("login", 0)   
delay 2   

tell application "Safari"   
    tell application "System Events" to tell process "Safari"   
        keystroke tab   
delay 0.2   
        keystroke "MyPassword"   
0.5 -- you need the delay because it does not type instantly and the password is probably cut short.  
        keystroke return   
    end tell   
end tell