Apparently I can't get Safari to auto-scroll... ideas?

My online research says there's no way to get macOS Safari to auto-scroll (which means scroll continuously without having to move the mouse wheel.) Other browsers support this (sometime requiring extensions) and it appears that Safari on iOS and iPadOS support this too. But we macOS users don't get that feature.

Can someone correct me if I'm wrong? I want this feature so that I can synchronize scrolling lyrics with a sound track (using KM to calculate the synchrony.) I managed to get synchronized lyrics working within Apple Motion but that's just too much work. I want something simpler.

I may have to switch to Chrome or Firefox to allow this.

This is how I auto scroll Safari:
KM 0 2021-08-18_22-49-38

Probably not quite what you're looking for but it may help ...

1 Like

Hi @Sleepy, unfortunately I don't have a solution with a KM macro.
I myself use Smart Scroll for automatic scrolling in Safari as well as in all other apps:

Smart Scroll offers many possibilities for individual scrolling.

2021_08_19_Support_2

That's nice to see (your video clip is worth >1000 words) but I can't tell from the clip if the app has an AppleScript dictionary to let me set the values and trigger the scrolling. And while it has many scroll speeds, I can't be sure it includes the range of speeds that I need. But I can download it and get my own answers to these questions. Thanks.

That might give me the control I'm looking for. I want to run it to understand it. I typed it in and it doesn't run for me. I get no errors, even when I include errors on the cogwheel. It's possible I mistyped it even though I read through it carefully. Can you post it as an action instead of just an image?

@Sleepy with AppleScript I haven't tried it yet, because I control scrolling with the keyboard, like in this example with ctrl + cmd.

Video

Your videos are very helpful. Thanks. Even at that slow setting it's likely too fast for my purposes. Because I'm trying to scroll as fast as people read, and people don't read very fast. And in addition, I need to calculate how fast to scroll based on how much text there is in the file being displayed in the window. I can probably estimate that because I'm the one putting the text in the window, but if there isn't some way to know when I would reach the bottom for a given speed, then this may not work for me.

It's entirely possible I'm going to have to convert my text into a giant bitmap and scroll the bitmap up myself. That way I know how big the text is, since I will generate it. But I have no idea if it's possible for KM to move images around the screen that are ten times larger than the screen itself. Nope, I just checked, and it has a small size limit of 9999x9999. And it also doesn't seem to have the ability to place an image on a specific location on the screen, let alone move it. People have told me that the Custom HTML action may do what I want, but I'm not yet sure if it can. Javascript is very powerful but I'm not yet sure if Javascript can do what I need. I already spent a day on github looking for Javascript tools that does what I want, and found very little. The only code that I've found that does what I want are Apple Motion and Apple Keynote. Most of Keynote's AppleScript dictionary is readonly so that doesn't help much.

I think my only choice is to find a full-scale programming language. Probably Swift with Metal. I've already tried that for a week and didn't make much progress. I couldn't even set up the xCode registration process correctly.

Here's the action:
Execute a JavaScript in Front Browser.kmactions (930 Bytes)

You need to enable JavaScript from Apple Events in Safari:
KM 0 2021-08-19_01-36-30

I already have "Allow JavaScript..." checked.

The file you placed in your message has an extension of webloc despite its name in the link. It wouldn't load. When I renamed it to the regular KM extension, it still wouldn't load. Please consider whether you made a mistake when you uploaded it.

I hate to sound argumentative, when you are trying to help me, but I think you made a mistake.

Here it downloads fine.
@Sleepy .webloc is the extension used by Safari’s pages. Looks like you downloaded this thread instead of the action?

1 Like

Reading on my iPad. The file downloads fine but, of course, a .kmactions file is not much use on iPadOS! Maybe you did what @hello suggested? I’ll double-check when I get back to my Mac.

This is what I see when I edit my post:

I think you’ll agree that there’s no .webloc file in sight.

It also downloads fine here.

Finger trouble, maybe?

Anyway - here's the source code for you:

var lastScrollHeight = 0;
function autoScroll() {
  var sh = document.documentElement.scrollHeight;
  if (sh != lastScrollHeight) {
    lastScrollHeight = sh;
    document.documentElement.scrollTop = sh;
  }
}
window.setInterval(autoScroll, 100);

No, since I don't even know how to download a thread, that can't be right.

I don't think so. Maybe it's a glitch with Monterey, which I'm using.

Strangely, when I click on the link it NOW downloads as a kmmacro extension, and when I click on it it NOW says "One action was imported" (it didn't say this yesterday). However even though it says it was imported, I can't find any new folder or action in KM.

Let's just assume this is a Monterey bug. You've pasted the code here, so that will be enough. I'm sorry for the trouble.

EDIT: Your code seems to be doing something. It's autoscrolling my window when I'm on the KM website. It's forcing new data to be loaded at the bottom of the page. It's very funny and delightful. I'm going to have to study how it works. Thanks.

No it’s not. This is an Action and not a Macro, so when you import it it appears directly inside whatever macro you have open in the KM editor as if you had chosen it from KM’s action list.

OK so you’ve managed to try the action somehow. Yes, I use it in a macro of mine that I call “Scroll to End”: it’s for those web pages that partially load and then, as you manually scroll down, they load up a bit more. Sometimes I need the whole page loaded so I can process it properly and this action is what I use to achieve that.

As I said originally, it may not be exactly what you need… but maybe with some tweaking it’ll get you there!

I had no idea that's how imported actions worked. Then whatever I clicked on, more than once, is probably in one of my macros. I did find some copies of your action in two of my macros, but I can't remember if I clicked on your file when those test macros were open or if I entered them manually when I typed your text in. There's no way to be sure, so I think it's time to say things are working as you expected.

If I can get your macro to scroll at a very specific and calculated rate, that could be what I need to solve my problem. I can study it for a few days.

Do a search in the All Macros group for “Execute JavaScript” to find all occurrences and you’ll be able to see if my action snuck in somewhere where it shouldn’t be.

That's exactly how I found them when I told you that I found them.

EDIT: But let me say that even so, there's no way to tell if the macro "snuck in where it shouldn't be" because all the copies were in my Test group and all the macros in that group are just test macros whose lifetime is measured in days. The first time I tried clicking on that link I got that webloc error and we don't know what happened there. So I tried entering it manually a couple of times by hand. And I certainly don't remember which of the macros in my Test group were the location where I put them when I entered them manually. I can see no way to find out what happened. Let's move forward.

Like I said - it's an Action not a macro. You need to get the terminology right!

That's true. I misspoke. I'm sorry. Glad you corrected me. I'll try to be better. I don't think I make that mistake very often.