I found 2 code projects but both fail, maybe because they’re outdated. Anyway I cannot figure out how to make this code work for me. Please check both codes :
I tested script number 1) and it works, but it took on my system 6 seconds (!) for the event to execute a single scroll action.
I get errors with both handlers. (line 6 syntax error non - ASCII character xc2 - no encoding declared)
CK, did you add the first 6 lines + the last line to the 2nd code snipped?
Check appkit ans postinf an event
You’ll find events for scroll and parameters
You can set
Yes, to test code snippet 2), I substituted the function scroll_up for RelativeMouseScroll in code snippet 1), and kept the rest the same.
ObjC.import('CoreGraphics'); nil=$(); var event = $.CGEventCreateScrollWheelEvent(nil,$.kCGScrollEventUnitLine,1,-1); $.CGEventPost($.kCGHIDEventTap, event); $.CFRelease(event)
Or, if you want to call it from an existing AppleScript script, then:
These act/respond instantaneously.
Wow CK this sounds simply awesome, and is exactly what I was looking for!
I ought to have stated that my pertinent system info is[format]AppleScript version: 2.7
System version: 10.13.6[/format]As for why yours crashes, I couldn’t say without looking at your system logs at the time of the crash. It might be that your version of AppleScript (and JXA) is too early to handle the C-type data references, but that’s a total guess.
But your Python functions work, albeit in a delayed fashion. However, what I do notice is that, when run as native Python code from the terminal, the functions respond and act instanteously. Therefore, it’s the instantiation of a shell process via AppleScript by way of do shell script that is, unsurprisingly, causing the delay to occur.
Therefore, I’d recommend using these functions from within an Python script and, if you need to employ AppleScript functionality, then call AppleScript from Python instead of calling Python from AppleScript.
have a peek a Shane’s code to be able to access your java code saved as a script library.
I created a script library and put that (Java)script into: home/library/Script Libraries/
My Os : 10.11.0
Of course I’d like a solution which acts immediately, else the whole concept gets pointless. Pity that python can’t be loaded quicker. On my Os python doesn’t work at all:
Mostly I don’t need a scrolling feature… by the other hand, who knows where I’d implement that feature if I had it available ?
The solution seemed so close today
Since years I bother myself with this damn scrolling feature which is somehow ridiculous. The point is this need comes up all times. Why do I have to scroll manually for all the PDFs I read?
Auto scrolling is such a common feature on tablets and phones. Preview got just a generic AS support recently, I guess we should be happy about?
Sometimes I wished to rewrite script dictionaries by myself… Even if this sounds egoistic, but this is knowledge far from my experience.
If there are other viable options usable for my Osx, 10.11 then please let me know. (Probably not, as people are very kind to share) anyway I had to put it down. Thanks
It executed sometimes yes, sometimes no - somehow odd. Plus, I’m unable to target a specific application where the script should scroll.
I tried to add after the first paragraph: