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

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

问题描述

我要的AppleScript滚动窗口一路上涨。

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

我试过Page Up键,Home键,以及我试着寻找一种方式,使用内置的滚动窗口的功能,以滚动,但我迄今甚至无法移动滚动位置都没有。

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.

推荐答案

基本上,使用告诉应用程序系统事件语句来发送键击和键codeS 。
从理论上讲,你可以使用下列内容:

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

不过,这对我来说doesn't工作。好消息是,你可以使用键codeS来代替。我建议使用优秀的免费全键codeS 应用阅读虽然这是一个有点棘手让它读两个键$ p $同时pssed。

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.

关键codeS的<大骨节病> FN + <大骨节病>箭头 -combos如下:

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

页起来:<大骨节病> FN + <大骨节病>向上键键code 116

下一条:<大骨节病> FN + <大骨节病>向下键键code 121

首页<大骨节病> FN + <大骨节病>左键键code 115

结束:<大骨节病> FN + <大骨节病>右键键code 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天全站免登陆