Scroll Safari in background

I have just started to look at Applescript Studio, and am looking at the Apple guide Examples
http://developer.apple.com/documentation/AppleScript/Conceptual/StudioBuildingApps/
to guide me through the basics.

One Problem is I have to keep switching from Xcode or Interface Builder to safari to read the next step in the example
Project.

Annoying.

so I just quickly ran up these two script to use with my hotkey application. ( Spark ).

The scripts allow you to have the Applications Xcode or Interface Builder (or any other app) above safari.
with the part you need to read visible.

Now when I hit my hotkeys I can scroll up or down in safari while it still stays in the background.

Scroll up ( I use alt+Up arrow )

tell application "System Events"
	click button 2 of scroll bar 1 of scroll area 1 of group 4 of window 1 of application process "Safari"
end tell

Scroll Down ( I use alt+Down arrow )

tell application "System Events"
	click button 1 of scroll bar 1 of scroll area 1 of group 4 of window 1 of application process "Safari"
end tell

Safari is a Cocoa application. Hold the command key and you can operate its scroll bars while its windows are in the background.

Thanks Mikey, forgot about that.

Still like the hotkeys, It means less mouse movement

One more alternative, for the records :wink:

tell application "Safari" to ¬
	do JavaScript "window.scrollBy(0,40)" in document 1

How do you guys find this stuff. jj that is fantastic.

I actually just came back to this page to take the hint out, as it works but when the page changes
it may have different UI groupings.

But your do JavScript is PERFECT.

here then are the 2 buttons. I also changed the hotkeys I use to ctrl+z and x which I can do with one hand.

Scroll Down

tell application "Safari" to ¬
	do JavaScript "window.scrollBy(0,40)" in document 1

Scroll Up

tell application "Safari" to ¬
	do JavaScript "window.scrollBy(0,-40)" in document 1

Thanks JJ

It’s simple javascript :smiley:

This is my favorite js reference: http://www.devguru.com/Technologies/ecmascript/quickref/javascript_index.html

:slight_smile:
thanks