开发者

Mac OS X - control other window [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicate开发者_开发问答:

How do I scroll to the top of a window using applescript?

I want to control other window of other process on Mac OS X 10.6.

For example, I want to scroll down of Safari.

How can I do it?


AppleScript can scroll down pages in Safari, check:
How do I scroll to the top of a window using applescript?

Script:

tell application "System Events"
   tell application "Safari" to activate
   delay 0.5
   key code 119
end tell

Simply run this script with NSAppleScript:

NSAppleScript *scrollDownSafari = [[NSAppleScript alloc] initWithSource:@"tell application \"System Events\"\ntell application \"Safari\" to activate\ndelay 0.5\nkey code 119\nend tell"];
[scrollDownSafari executeAndReturnError:nil];

EDIT

Better readable code:

NSString *script =
@"tell application \"System Events\"\n"
 "tell application \"Safari\" to activate\n"
 "delay 0.5\n"
 "key code 119\n"
 "end tell";

NSAppleScript *scrollDownSafari = [[NSAppleScript alloc] initWithSource:script];
[scrollDownSafari executeAndReturnError:nil];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜