2011-04-19 2 views

답변

1

애플 스크립트 사파리의 페이지를 아래로 스크롤 할 수 있습니다 확인 :
How do I scroll to the top of a window using applescript?

스크립트 :

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

단순히 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]; 

편집

,

더 나은 읽을 수있는 코드는`동일하다 "ab`"`@를 @ "는"@ "B"를`:

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

당신은 문자열 연결을 사용하여 그 읽기 쉽게 만들 수 있습니다. –

+0

동의 함 :)주의 : 첫 번째 줄만'@'을 필요로하지만 모든 줄에'@'를 사용할 수 있습니다. – Anne

+0

Objective C를 사용하는 다른 솔루션이 있습니까? –