简体   繁体   English

如何编写脚本并在网页上按Enter键

[英]How to script and Enter key press on a webpage

So I am using Script Editor to open Chrome to a webpage where I have a Username and Password already saved there, so I need this script to press enter on the webpage, so that it will continue to the user home page. 因此,我正在使用脚本编辑器将Chrome打开到一个我已在其中保存了用户名和密码的网页,因此我需要此脚本在网页上按Enter键,以便它将继续进入用户主页。 This is my script without my enter key added, every time I give it a shot it just adds the word "enter" in the username field. 这是我的脚本,没有添加Enter键,每当我尝试一下时,它只会在用户名字段中添加单词“ enter”。

Question is: How do I make this script press enter on a webpage? 问题是:如何使此脚本在网页上按Enter键? Thanks for any info you can give me. 感谢您提供给我的任何信息。

shell script "open '/Applications/Google Chrome.app' https://random.website " shell脚本“打开'/应用程序/谷歌Chrome.app' https://random.website

tell application "Google Chrome" to activate 告诉应用程序“ Google Chrome浏览器”激活

tell application "System Events" keystroke "f" using {command down, shift down} 使用{command down,shift down}告诉应用程序“系统事件”按键“ f”

end tell 结束告诉

delay 3 (this is where I have been trying to get the "Enter" keypress to go) 延迟3(这是我一直试图按下“ Enter”键的地方)

tell application "System Events" keystroke "T" using {command down} 使用{command down}告诉应用程序“系统事件”按键“ T”

end tell 结束告诉

You have 2 possible methods : click on the relevant button of the web page using java script or just simulate a return (enter) key via system events. 您有2种可能的方法:使用Java脚本单击网页上的相关按钮,或仅通过系统事件模拟返回(输入)键。

Here is the second method : 这是第二种方法:

tell application "System Events" to tell process "Google Chrome" to keystroke return

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM