當前位置: 首頁>>代碼示例>>Python>>正文


Python Quartz.CGEventCreateScrollWheelEvent方法代碼示例

本文整理匯總了Python中Quartz.CGEventCreateScrollWheelEvent方法的典型用法代碼示例。如果您正苦於以下問題:Python Quartz.CGEventCreateScrollWheelEvent方法的具體用法?Python Quartz.CGEventCreateScrollWheelEvent怎麽用?Python Quartz.CGEventCreateScrollWheelEvent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Quartz的用法示例。


在下文中一共展示了Quartz.CGEventCreateScrollWheelEvent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _vscroll

# 需要導入模塊: import Quartz [as 別名]
# 或者: from Quartz import CGEventCreateScrollWheelEvent [as 別名]
def _vscroll(clicks, x=None, y=None):
    _moveTo(x, y)
    clicks = int(clicks)
    for _ in range(abs(clicks) // 10):
        scrollWheelEvent = Quartz.CGEventCreateScrollWheelEvent(
            None, # no source
            Quartz.kCGScrollEventUnitLine, # units
            1, # wheelCount (number of dimensions)
            10 if clicks >= 0 else -10) # vertical movement
        Quartz.CGEventPost(Quartz.kCGHIDEventTap, scrollWheelEvent)

    scrollWheelEvent = Quartz.CGEventCreateScrollWheelEvent(
        None, # no source
        Quartz.kCGScrollEventUnitLine, # units
        1, # wheelCount (number of dimensions)
        clicks % 10 if clicks >= 0 else -1 * (-clicks % 10)) # vertical movement
    Quartz.CGEventPost(Quartz.kCGHIDEventTap, scrollWheelEvent) 
開發者ID:asweigart,項目名稱:pyautogui,代碼行數:19,代碼來源:_pyautogui_osx.py

示例2: _hscroll

# 需要導入模塊: import Quartz [as 別名]
# 或者: from Quartz import CGEventCreateScrollWheelEvent [as 別名]
def _hscroll(clicks, x=None, y=None):
    _moveTo(x, y)
    clicks = int(clicks)
    for _ in range(abs(clicks) // 10):
        scrollWheelEvent = Quartz.CGEventCreateScrollWheelEvent(
            None, # no source
            Quartz.kCGScrollEventUnitLine, # units
            2, # wheelCount (number of dimensions)
            0, # vertical movement
            10 if clicks >= 0 else -10) # horizontal movement
        Quartz.CGEventPost(Quartz.kCGHIDEventTap, scrollWheelEvent)

    scrollWheelEvent = Quartz.CGEventCreateScrollWheelEvent(
        None, # no source
        Quartz.kCGScrollEventUnitLine, # units
        2, # wheelCount (number of dimensions)
        0, # vertical movement
        (clicks % 10) if clicks >= 0 else (-1 * clicks % 10)) # horizontal movement
    Quartz.CGEventPost(Quartz.kCGHIDEventTap, scrollWheelEvent) 
開發者ID:asweigart,項目名稱:pyautogui,代碼行數:21,代碼來源:_pyautogui_osx.py

示例3: scroll

# 需要導入模塊: import Quartz [as 別名]
# 或者: from Quartz import CGEventCreateScrollWheelEvent [as 別名]
def scroll(vertical=None, horizontal=None, depth=None):
        # Local submethod for generating Mac scroll events in one axis at a time
        def scroll_event(y_move=0, x_move=0, z_move=0, n=1):
            for _ in range(abs(n)):
                scrollWheelEvent = Quartz.CGEventCreateScrollWheelEvent(
                    None,  # No source
                    Quartz.kCGScrollEventUnitLine,  # Unit of measurement is lines
                    3,  # Number of wheels(dimensions)
                    y_move,
                    x_move,
                    z_move)
                Quartz.CGEventPost(Quartz.kCGHIDEventTap, scrollWheelEvent)

        # Execute vertical then horizontal then depth scrolling events
        if vertical is not None:
            vertical = int(vertical)
            if vertical == 0:   # Do nothing with 0 distance
                pass
            elif vertical > 0:  # Scroll up if positive
                scroll_event(y_move=1, n=vertical)
            else:  # Scroll down if negative
                scroll_event(y_move=-1, n=abs(vertical))
        if horizontal is not None:
            horizontal = int(horizontal)
            if horizontal == 0:  # Do nothing with 0 distance
                pass
            elif horizontal > 0:  # Scroll right if positive
                scroll_event(x_move=1, n=horizontal)
            else:  # Scroll left if negative
                scroll_event(x_move=-1, n=abs(horizontal))
        if depth is not None:
            depth = int(depth)
            if depth == 0:  # Do nothing with 0 distance
                pass
            elif vertical > 0:  # Scroll "out" if positive
                scroll_event(z_move=1, n=depth)
            else:  # Scroll "in" if negative
                scroll_event(z_move=-1, n=abs(depth)) 
開發者ID:AirtestProject,項目名稱:Poco,代碼行數:40,代碼來源:OSXUIFunc.py

示例4: _scroll

# 需要導入模塊: import Quartz [as 別名]
# 或者: from Quartz import CGEventCreateScrollWheelEvent [as 別名]
def _scroll(self, dx, dy):
        while dx != 0 or dy != 0:
            xval = 1 if dx > 0 else -1 if dx < 0 else 0
            dx -= xval
            yval = 1 if dy > 0 else -1 if dy < 0 else 0
            dy -= yval

            Quartz.CGEventPost(
                Quartz.kCGHIDEventTap,
                Quartz.CGEventCreateScrollWheelEvent(
                    None,
                    Quartz.kCGScrollEventUnitPixel,
                    2,
                    yval * self._SCROLL_SPEED,
                    xval * self._SCROLL_SPEED)) 
開發者ID:mass-immersion-approach,項目名稱:MIA-Dictionary-Addon,代碼行數:17,代碼來源:_darwin.py


注:本文中的Quartz.CGEventCreateScrollWheelEvent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。