【问题标题】:Scroll down Chrome addon with virtual keyboard on mac在 Mac 上使用虚拟键盘向下滚动 Chrome 插件
【发布时间】:2021-12-25 16:28:48
【问题描述】:

我想用 automator mac 向下滚动 chrome(或 firefox)插件​​中的布局。 据我了解,Automator 不支持滚动。 我试过使用键盘大师。 所以我不想在虚拟键盘上制作一个按钮并在需要滚动时单击它。 我可以使用什么脚本在 chrome 中滚动插件?我需要滚动插件,而不是页面。

https://www.dropbox.com/s/5zwlx4li6xyw7bv/Scroll.png?dl=0

【问题讨论】:

  • 请不要在多个 Stack Exchange 网站上交叉发布相同的问题。您在 Ask Different apple.stackexchange.com/questions/430759/… 上发布了此内容 - 适当地编辑您的原始问题以便重新打开它。

标签: applescript automator


【解决方案1】:

尝试模仿点击和拖动动作从一个屏幕位置到另一个脚本位置,如下所示:

my mouseDrag(100, 200, 499, 400, 1) -- EDIT here 2 positions and the delay

on mouseDrag(xDown, yDown, xUp, yUp, delayTime)
    -- delayTime because the drag may fail if the UI isn't fast enough without a delay. For what I do, .1 works.
    do shell script "/usr/bin/python <<END
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventCreate
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
from Quartz.CoreGraphics import kCGEventLeftMouseDragged
import time

def mouseEvent(type, posx, posy):
  theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
  CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
  mouseEvent(kCGEventMouseMoved, posx,posy);
def mousedrag(posx,posy):
  mouseEvent(kCGEventLeftMouseDragged, posx,posy);
def mousedown(posxdown,posydown):
  mouseEvent(kCGEventLeftMouseDown, posxdown,posydown);
def mouseup(posxup,posyup):
  mouseEvent(kCGEventLeftMouseUp, posxup,posyup);

ourEvent = CGEventCreate(None);
mousedown(" & xDown & "," & yDown & ");
time.sleep(" & (delayTime as text) & "); mousedrag(" & xUp & "," & yUp & ");
time.sleep(" & (delayTime as text) & "); mouseup(" & xUp & "," & yUp & ");
END"
end mouseDrag

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-30
    • 1970-01-01
    • 2010-12-12
    • 1970-01-01
    • 2018-05-30
    • 2017-08-11
    相关资源
    最近更新 更多