如何使用applescript滚动到窗口顶部? [英] How do I scroll to the top of a window using applescript?

查看:48
本文介绍了如何使用applescript滚动到窗口顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让 applescript 一直向上滚动一个窗口.

I want applescript to scroll a window all the way up.

我已经尝试了翻页键、主页键,并且我已经尝试寻找一种使用窗口的内置滚动功能进行滚动的方法,但到目前为止我什至无法移动滚动的位置.

I've tried the page up key, the home key, and I've tried looking for a way to scroll using the built in scrolling capabilities of the window, but I've so far been unable to even move the scrolled position at all.

推荐答案

基本上,使用 tell app "System Events" 语句来发送击键和键码.理论上,您可以使用以下内容:

Basically, use a tell app "System Events" statement to send keystrokes and key codes. In theory, you could use the following:

keystroke page up key
keystroke page down key
keystroke home key

但对我来说这是行不通的.好消息是您可以改用密钥代码.我建议使用优秀的免费 Full Key Codes 应用程序来阅读它们,虽然它有点让它读取同时按下的两个键很棘手.

But for me this doesn´t work. The good news is that you can use the key codes instead. I suggest using the excellent free Full Key Codes application to read them, though it is a bit tricky to let it read two keys pressed simultaneously.

fn+ 箭头键-组合键代码如下:

The key codes for the fn+ arrow keys-combos are as following:

Page up: fn+ up key: key code 116

Page up: fn+ up key: key code 116

Page down: fn+ down key: key code 121

Page down: fn+ down key: key code 121

首页:fn+ 左键:键码115

结束:fn+ 右键:键码119

例如,如果您在 Safari 中打开了一个长页面,并且您想滚动到它的末尾,请使用

So for example if you had a long page open in Safari, and you want to scroll to its end, use

tell application "System Events"
tell application "Safari" to activate
    — to see the animation, we wait a moment:
    delay 0.5  

    key code 119

end tell

这篇关于如何使用applescript滚动到窗口顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆