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


Python wintypes.SHORT屬性代碼示例

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


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

示例1: _register_mouse_hook

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import SHORT [as 別名]
def _register_mouse_hook(self):
        def low_level_callback(code, wparam, lparam):
            if wparam == 512:
                self.event_handler(MouseEvent(
                    MouseEvents.MOVE,
                    x=lparam.contents.pt.x,
                    y=lparam.contents.pt.y
                ))
            elif wparam == 522:
                self.event_handler(MouseEvent(
                    MouseEvents.SCROLL,
                    direction="UP" if (wintypes.SHORT(lparam.contents.mouseData >> 16).value // 120) == 1 else "DOWN",
                    velocity=1,
                    x=lparam.contents.pt.x,
                    y=lparam.contents.pt.y
                ))
            elif wparam in [513, 514, 516, 517, 519, 520]:
                self.event_handler(MouseEvent(
                    MouseEvents.CLICK,
                    button=mouse_button_mapping[wparam],
                    direction="DOWN" if wparam in [513, 516, 519] else "UP",
                    x=lparam.contents.pt.x,
                    y=lparam.contents.pt.y
                ))

            return CallNextHookEx(None, code, wparam, lparam)

        callback = LowLevelMouseProc(low_level_callback)

        self.mouse_hook = SetWindowsHookEx(14, callback, None, None)
        atexit.register(UnhookWindowsHookEx, callback) 
開發者ID:SerpentAI,項目名稱:sneakysnek,代碼行數:33,代碼來源:windows_recorder.py

示例2: get_console_width

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import SHORT [as 別名]
def get_console_width():
    """Return width of available window area. Autodetection works for
       Windows and POSIX platforms. Returns 80 for others

       Code from http://bitbucket.org/techtonik/python-pager
    """

    if os.name == 'nt':
        STD_INPUT_HANDLE  = -10
        STD_OUTPUT_HANDLE = -11
        STD_ERROR_HANDLE  = -12

        # get console handle
        from ctypes import windll, Structure, byref
        try:
            from ctypes.wintypes import SHORT, WORD, DWORD
        except ImportError:
            # workaround for missing types in Python 2.5
            from ctypes import (
                c_short as SHORT, c_ushort as WORD, c_ulong as DWORD)
        console_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)

        # CONSOLE_SCREEN_BUFFER_INFO Structure
        class COORD(Structure):
            _fields_ = [("X", SHORT), ("Y", SHORT)]

        class SMALL_RECT(Structure):
            _fields_ = [("Left", SHORT), ("Top", SHORT),
                        ("Right", SHORT), ("Bottom", SHORT)]

        class CONSOLE_SCREEN_BUFFER_INFO(Structure):
            _fields_ = [("dwSize", COORD),
                        ("dwCursorPosition", COORD),
                        ("wAttributes", WORD),
                        ("srWindow", SMALL_RECT),
                        ("dwMaximumWindowSize", DWORD)]

        sbi = CONSOLE_SCREEN_BUFFER_INFO()
        ret = windll.kernel32.GetConsoleScreenBufferInfo(
            console_handle, byref(sbi))
        if ret == 0:
            return 0
        return sbi.srWindow.Right+1

    elif os.name == 'posix':
        from fcntl import ioctl
        from termios import TIOCGWINSZ
        from array import array

        winsize = array("H", [0] * 4)
        try:
            ioctl(sys.stdout.fileno(), TIOCGWINSZ, winsize)
        except IOError:
            pass
        return (winsize[1], winsize[0])[0]

    return 80 
開發者ID:meiqua,項目名稱:patch_linemod,代碼行數:59,代碼來源:t-less_download.py

示例3: get_console_width

# 需要導入模塊: from ctypes import wintypes [as 別名]
# 或者: from ctypes.wintypes import SHORT [as 別名]
def get_console_width():
    """Return width of available window area. Autodetection works for
       Windows and POSIX platforms. Returns 80 for others

       Code from http://bitbucket.org/techtonik/python-pager
    """

    if os.name == 'nt':
        STD_INPUT_HANDLE  = -10
        STD_OUTPUT_HANDLE = -11
        STD_ERROR_HANDLE  = -12

        # get console handle
        from ctypes import windll, Structure, byref
        try:
            from ctypes.wintypes import SHORT, WORD, DWORD
        except ImportError:
            # workaround for missing types in Python 2.5
            from ctypes import (
                c_short as SHORT, c_ushort as WORD, c_ulong as DWORD)
        console_handle = windll.kernel32.GetStdHandle(STD_OUTPUT_HANDLE)

        # CONSOLE_SCREEN_BUFFER_INFO Structure
        class COORD(Structure):
            _fields_ = [("X", SHORT), ("Y", SHORT)]

        class SMALL_RECT(Structure):
            _fields_ = [("Left", SHORT), ("Top", SHORT),
                        ("Right", SHORT), ("Bottom", SHORT)]

        class CONSOLE_SCREEN_BUFFER_INFO(Structure):
            _fields_ = [("dwSize", COORD),
                        ("dwCursorPosition", COORD),
                        ("wAttributes", WORD),
                        ("srWindow", SMALL_RECT),
                        ("dwMaximumWindowSize", DWORD)]

        sbi = CONSOLE_SCREEN_BUFFER_INFO()
        ret = windll.kernel32.GetConsoleScreenBufferInfo(console_handle, byref(sbi))
        if ret == 0:
            return 0
        return sbi.srWindow.Right+1

    elif os.name == 'posix':
        from fcntl import ioctl
        from termios import TIOCGWINSZ
        from array import array

        winsize = array("H", [0] * 4)
        try:
            ioctl(sys.stdout.fileno(), TIOCGWINSZ, winsize)
        except IOError:
            pass
        return (winsize[1], winsize[0])[0]

    return 80 
開發者ID:einstein95,項目名稱:crunchy-xml-decoder,代碼行數:58,代碼來源:wget.py


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