1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > MacOS 模拟鼠标点击 键盘点击

MacOS 模拟鼠标点击 键盘点击

时间:2021-03-05 20:47:55

相关推荐

MacOS 模拟鼠标点击 键盘点击

Mac OSX 鼠标键盘事件的监听和模拟

macos – 如何通过mac终端模拟鼠标点击?

或者

直接使用Mac自带的脚本编辑器来写脚本模拟。

示例

tell application "System Events"#使用Mac系统自带的数码测色计app来确定屏幕上一个点的全局坐标#打开【数码测色计】,选择【显示】菜单,勾选【显示鼠标位置】即可在测色计面板上看到鼠标指针当前坐标#模拟用户点击点击左上角苹果标志click at {28, 12} --必须是tell application 不是tell processdelay 1 --等待click at {28, 39} --点击关于本机--(*# "Safari" "Google Chrome" 可以将下面的"Google Chrome"替换为"Safari"tell application "Google Chrome"quitend telldelay 3 --延时等待tell application "Google Chrome"activate --启动谷歌浏览器end telldelay 3 --延时等待keystroke "" --模拟输入网址delay 3 --延时等待keystroke return --模拟按回车确定delay 3 --延时等待tell application "Google Chrome"tell front windowmake new tab with properties {URL:"/cn/"}end telldelay 3 --延时等待end tell#Mac键盘按键对应code一览 /complete-list-of-applescript-key-codes#command键的code=55 R键的code=15key code 15 using command down --模拟用户点击command+R进行刷新网页delay 3 --延时等待tell application "Google Chrome"quit --退出append tell--*)end tell

但是

一般的点击是可以实现,比如点击菜单,输入框,按钮,在点击Safari网页中的元素时,却由于不明原因不能实现,可能是Safari内部或者系统对这种情况有限制?

如果想继续研究实现模拟Safari元素点击,可以参考下面一篇文章。

HOW TO CLICK A BUTTON ON A WEB PAGE WITH APPLESCRIPT

里面有个配置如下图

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。