Scrolling Problem

Wrote a simple macro that opens URL in Safari, moves and sizes the window on a monitor but cannot get the window to scroll so the first entry is at the top of the window. Some tests work. Others do nothing. Action seems inconsistent.

I myself went to "" and when the page loaded, I couldn't figure out what you meant by "first item." All I see is a series of images and words. What do you mean by "item"? Are you talking about after you login?

EDIT: My latest thoughts are that you have a cookie that essentially auto-logs you into that website. So maybe that's why I can't see what you are seeing. If there's nothing private on the site when you are logged in, perhaps you could take a screen snapshot so we can see what you mean by "items." We don't need to see anything private like emails or people's names or things like that.

What happens if you add an action that ensures the mouse cursor is in the middle of the Feedly window before scrolling?

Maybe that's what the problem is.

I found a video of Feedly online, and it is visually similar to an RSS reader which lets you display results. And it allows you to merge multiple RSS feeds into a single feed. Feedly says this is a way to reduce "information overload" but in my opinion it does the exact opposite of that. No matter.

When @tommcin says he wants to scroll up "so the first entry is at the top of the window" I think what he means is that he wants the page to scroll up an inch or two, since Feedly shows a lot of useless space at the top of each page. If so, the number 200 may mean he just wants it to scroll up a fixed amount. That's eminently doable. Although it would be better if Feedly would just fix the problem.

If he wanted KM to figure out how far to scroll up, that would probably be a lot more work. For example, many RSS feeds contain ad entires. Maybe he wants KM to figure out which ones are ads and which ones aren't, and scroll past the ads to the first real entry. That might be doable, but it's going to be considerably more work. Since he didn't really explain what he meant, we are just guessing for now.

I have specified a number of feeds that Feedly retrieves in groups and displays. The first feeds on opening the URL are preceded by a header I want to scroll up off the display. After that Page Down keys bring me up additional items of sources. Being a KM newbie, I will use something very simple and add features after.

While developing this macro, I have run many tests on Simulate Scroll Wheel and find it very inconsistant in when it works and when it does not in many applications. Am I doing something wrong since I cannot get it to work consistently.

Okay, thanks for clarifying that you just want to move the window up a fixed amount. That will make things much easier than making a decision on how much to scroll based on the window's content.

Even if it's just for testing, have you tried sending the Down arrow key to your browser instead of the scroll wheel? That works very reliably. Based on your comment about reliability, you should try this solution: Try sending "5 down keys" to your browser and see if you are satisfied with the results. If you still want to use the Scroll Wheel after that, we can still try to help. There's nothing wrong with wanting to use the mouse, but why not just try a simpler, very reliable method first? It might save you time and effort.

Another problem with the mouse is that the amount it scrolls is probably affected by things like the Scrolling Speed setting in the System Preferences (Accessibility). The keyboard arrows are always a fixed amount of scrolling, but the amount of scrolling you want would be affected by the zoom level of your page. But as long as you keep your settings constant, these shouldn't be issues.

Hey Tom,

I suspect this is a timing problem.

Test scroll on the page after it's fully loaded. If it works then you'll have to manage the loading issue.


Tryed a Repeat Action 50 times that simulates a keystroke of Down Arrow. Saw only some of them were scrolling the screen. Put a .5 second pause as the last action in the loop and saw the individual scrolls.

Without the pauses, KM seems to run an actions as fast as it can with no waiting for the action to complete and KM is much faster than the system.

The pauses work but need to look for other ways to synchronize KM with the system.

I'm glad you found a solution. If you post your solution here, we might be able to find ideas to improve it a bit. But you don't have to post it.

I've seen that issue on occasion, but usually I find that this is not a problem.

There are often ways to use KM to not work too fast. I've learned a few tricks. Some of the tricks involve inserting pause statements, but some of the tricks involve other techniques.

Hey Tom,

What did I say in post #7? Something about a timing issue?

macOS does not provide feedback for UI actions in most cases, so there's frequently no way for Keyboard Maestro to automatically wait until your simulated user-action completes.

Keyboard Maestro is often faster than macOS, therefore you must always be cognizant of timing issues.

See the Pause Until action. It won't help you with the scroll issue, but using it is frequently better than using a timed pause.

Your task can be done with JavaScript.

Here's an AppleScript from my library that runs the JavaScript in Safari. You can do the same with pure JavaScript in an Execute a JavaScript in Front Browser action or an Execute a JavaScript in Safari action.

This gives you far more direct control over the scroll position than simulating user-actions with Keyboard Maestro.

# Auth: Christopher Stone { Heavy Lifting by Shane Stanley }
# dCre: 2016/09/01 17:13 +1000
# dMod: 2021/11/29 21:36
# Appl: Safari
# Task: Scroll Web Page of Front Window Using JavaScript.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @Safari, @JavaScript, @Scroll, @Page

tell application id "" --
   set theTab to current tab of window 1
   set jumpSize to (do JavaScript "window.innerHeight;" in theTab) / 2
   do JavaScript "window.scrollTo(0,0);" in theTab
   set docHt to do JavaScript "document.body.clientHeight;" in theTab
   repeat with i from 1 to (docHt div jumpSize) + 1
      do JavaScript "window.scrollTo(0," & i * jumpSize & ");" in theTab
      delay 0.2 -- whatever
   end repeat
end tell



1 Like