Python ctypes.wintypes.HWND Examples

The following are 30 code examples for showing how to use ctypes.wintypes.HWND(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module ctypes.wintypes , or try the search function .

Example 1
Project: gdog   Author: maldevel   File: client.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _set_argtypes(self):
        ''' Functions arguments. '''

        self.MONITORENUMPROC = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
                                           DOUBLE)
        windll.user32.GetSystemMetrics.argtypes = [INT]
        windll.user32.EnumDisplayMonitors.argtypes = [HDC, c_void_p,
                                                      self.MONITORENUMPROC,
                                                      LPARAM]
        windll.user32.GetWindowDC.argtypes = [HWND]
        windll.gdi32.CreateCompatibleDC.argtypes = [HDC]
        windll.gdi32.CreateCompatibleBitmap.argtypes = [HDC, INT, INT]
        windll.gdi32.SelectObject.argtypes = [HDC, HGDIOBJ]
        windll.gdi32.BitBlt.argtypes = [HDC, INT, INT, INT, INT, HDC, INT, INT,
                                        DWORD]
        windll.gdi32.DeleteObject.argtypes = [HGDIOBJ]
        windll.gdi32.GetDIBits.argtypes = [HDC, HBITMAP, UINT, UINT, c_void_p,
                                           POINTER(BITMAPINFO), UINT] 
Example 2
Project: gcat   Author: byt3bl33d3r   File: implant.py    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
def _set_argtypes(self):
        ''' Functions arguments. '''

        self.MONITORENUMPROC = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
                                           DOUBLE)
        windll.user32.GetSystemMetrics.argtypes = [INT]
        windll.user32.EnumDisplayMonitors.argtypes = [HDC, c_void_p,
                                                      self.MONITORENUMPROC,
                                                      LPARAM]
        windll.user32.GetWindowDC.argtypes = [HWND]
        windll.gdi32.CreateCompatibleDC.argtypes = [HDC]
        windll.gdi32.CreateCompatibleBitmap.argtypes = [HDC, INT, INT]
        windll.gdi32.SelectObject.argtypes = [HDC, HGDIOBJ]
        windll.gdi32.BitBlt.argtypes = [HDC, INT, INT, INT, INT, HDC, INT, INT,
                                        DWORD]
        windll.gdi32.DeleteObject.argtypes = [HGDIOBJ]
        windll.gdi32.GetDIBits.argtypes = [HDC, HBITMAP, UINT, UINT, c_void_p,
                                           POINTER(BITMAPINFO), UINT] 
Example 3
Project: puppet   Author: Raytone-D   File: puppet_util.py    License: MIT License 6 votes vote down vote up
def get_root(key: list =['网上股票交易系统', '通达信']) -> tuple:
    from ctypes.wintypes import BOOL, HWND, LPARAM

    @ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
    def callback(hwnd, lparam):
        user32.GetWindowTextW(hwnd, buf, 64)
        for s in key:
            if s in buf.value:
                handle.value = hwnd
                return False
        return True

    buf = ctypes.create_unicode_buffer(64)
    handle = ctypes.c_ulong()
    user32.EnumWindows(callback)
    return handle.value, buf.value 
Example 4
Project: puppet   Author: Raytone-D   File: release_puppet_unity_ths.py    License: MIT License 6 votes vote down vote up
def finder(register):
    ''' 枚举所有可用的broker交易端并实例化 '''
    team = set()
    buff = buffer(32)
    @ctypes.WINFUNCTYPE(BOOL, HWND, LPARAM)
    def check(hwnd, extra):
        if op.IsWindowVisible(hwnd):
            op.GetWindowTextW(hwnd, buff, 32)
            if '交易系统' in buff.value:
                team.add(hwnd)
        return 1
    op.EnumWindows(check, 0)
    
    def get_nickname(hwnd):
        account = hwnd
        for i in 59392, 0, 1711:
            account = op.GetDlgItem(account, i)
        op.SendMessageW(account, WM_GETTEXT, 32, buff)
        return register.get(buff.value[-3:])
        
    return {get_nickname(hwnd): unity(hwnd) for hwnd in team if hwnd} 
Example 5
Project: canisrufus   Author: maldevel   File: client.py    License: GNU General Public License v3.0 6 votes vote down vote up
def _set_argtypes(self):
        ''' Functions arguments. '''

        self.MONITORENUMPROC = WINFUNCTYPE(INT, DWORD, DWORD, POINTER(RECT),
                                           DOUBLE)
        windll.user32.GetSystemMetrics.argtypes = [INT]
        windll.user32.EnumDisplayMonitors.argtypes = [HDC, c_void_p,
                                                      self.MONITORENUMPROC,
                                                      LPARAM]
        windll.user32.GetWindowDC.argtypes = [HWND]
        windll.gdi32.CreateCompatibleDC.argtypes = [HDC]
        windll.gdi32.CreateCompatibleBitmap.argtypes = [HDC, INT, INT]
        windll.gdi32.SelectObject.argtypes = [HDC, HGDIOBJ]
        windll.gdi32.BitBlt.argtypes = [HDC, INT, INT, INT, INT, HDC, INT, INT,
                                        DWORD]
        windll.gdi32.DeleteObject.argtypes = [HGDIOBJ]
        windll.gdi32.GetDIBits.argtypes = [HDC, HBITMAP, UINT, UINT, c_void_p,
                                           POINTER(BITMAPINFO), UINT] 
Example 6
Project: ironpython2   Author: IronLanguages   File: test_callbacks.py    License: Apache License 2.0 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 7
Project: ironpython2   Author: IronLanguages   File: test_win32.py    License: Apache License 2.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 8
Project: BinderFilter   Author: dxwu   File: test_callbacks.py    License: MIT License 5 votes vote down vote up
def test_issue_8959_b(self):
            from ctypes.wintypes import BOOL, HWND, LPARAM
            global windowCount
            windowCount = 0

            @WINFUNCTYPE(BOOL, HWND, LPARAM)
            def EnumWindowsCallbackFunc(hwnd, lParam):
                global windowCount
                windowCount += 1
                return True #Allow windows to keep enumerating

            windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 9
Project: BinderFilter   Author: dxwu   File: test_win32.py    License: MIT License 5 votes vote down vote up
def test_HWND(self):
            from ctypes import wintypes
            self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 10
Project: oss-ftp   Author: aliyun   File: test_callbacks.py    License: MIT License 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 11
Project: oss-ftp   Author: aliyun   File: test_win32.py    License: MIT License 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 12
Project: Fluid-Designer   Author: Microvellum   File: test_callbacks.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 13
Project: Fluid-Designer   Author: Microvellum   File: test_win32.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 14
Project: Imogen   Author: CedricGuillemet   File: test_callbacks.py    License: MIT License 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 15
Project: Imogen   Author: CedricGuillemet   File: test_win32.py    License: MIT License 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 16
Project: ironpython3   Author: IronLanguages   File: test_callbacks.py    License: Apache License 2.0 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 17
Project: ironpython3   Author: IronLanguages   File: test_win32.py    License: Apache License 2.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 18
Project: gd.py   Author: NeKitDS   File: win.py    License: MIT License 5 votes vote down vote up
def find_window(class_name: wintypes.LPCSTR, title: wintypes.LPCSTR) -> wintypes.HWND:
    pass 
Example 19
Project: gd.py   Author: NeKitDS   File: win.py    License: MIT License 5 votes vote down vote up
def get_window_thread_process_id(
    handle: wintypes.HWND, process_id_ptr: wintypes.LPDWORD
) -> wintypes.DWORD:
    pass 
Example 20
Project: pymt5   Author: devcartel   File: ddeclient.py    License: MIT License 5 votes vote down vote up
def WinMSGLoop():
    """Run the main windows message loop."""
    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc("user32", "GetMessageW", BOOL, (LPMSG, HWND, UINT, UINT))
    TranslateMessage = get_winfunc("user32", "TranslateMessage", BOOL, (LPMSG,))
    # restype = LRESULT
    DispatchMessage = get_winfunc("user32", "DispatchMessageW", LRESULT, (LPMSG,))

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg) 
Example 21
Project: datafari   Author: francelabs   File: test_callbacks.py    License: Apache License 2.0 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 22
Project: datafari   Author: francelabs   File: test_win32.py    License: Apache License 2.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 23
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 24
Project: Project-New-Reign---Nemesis-Main   Author: ShikyoKira   File: test_win32.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 25
Project: odoo13-x64   Author: guohuadeng   File: test_callbacks.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 26
Project: odoo13-x64   Author: guohuadeng   File: test_win32.py    License: GNU General Public License v3.0 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p)) 
Example 27
Project: RebirthItemTracker   Author: Hyphen-ated   File: pygameWindowInfo.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
def __init__(self):
        """Initialize our object"""
        # Find the start x,y pos of the main pygame *screen* (the screen in the
        # window):
        sdlpos = os.getenv("SDL_VIDEO_WINDOW_POS")
        if sdlpos is None:
            raise Exception("Must have previously setup a Pygame window starting position via the 'SDL_VIDEO_WINDOW_POS' evn var.")
        self.initPygameScreenPos = [int(i) for i in sdlpos.split(",")]

        # Run our ctypes code to query window position:
        try:
            # It's said that not all systems support this dictionary key.  I'm
            # not sure what systmes those are, but might as well put a check in.
            self.hwnd = pygame.display.get_wm_info()["window"]
        except KeyError:
            raise Exception("Your system isn't accepting the code: 'pygame.display.get_wm_info()[\"window\"]', must not be supported :-(")
        self.prototype = WINFUNCTYPE(BOOL, HWND, POINTER(RECT))
        self.paramflags = (1, "hwnd"), (2, "lprect")
        self.GetWindowRect = self.prototype(("GetWindowRect", windll.user32), self.paramflags)

        # Find the initial *window* position:
        rect = self.GetWindowRect(self.hwnd)
        # Calculate the thickness of the *window* border to the *screen* object inside:
        self.borderThickness = int(self.initPygameScreenPos[0]) - rect.left
        self.titleThickness = int(self.initPygameScreenPos[1]) - rect.top
        # borderThickness is the left, right, and bottom window edges.  titleThickness
        # is th thickness of the top title-bar of the window. 
Example 28
Project: EventGhost   Author: EventGhost   File: dde.py    License: GNU General Public License v2.0 5 votes vote down vote up
def WinMSGLoop():
    """Run the main windows message loop."""
    from ctypes import POINTER, byref, c_ulong
    from ctypes.wintypes import BOOL, HWND, MSG, UINT

    LPMSG = POINTER(MSG)
    LRESULT = c_ulong
    GetMessage = get_winfunc(
        "user32",
        "GetMessageW",
        BOOL,
        (LPMSG, HWND, UINT, UINT)
    )
    TranslateMessage = get_winfunc(
        "user32",
        "TranslateMessage",
        BOOL,
        (LPMSG,)
    )
    # restype = LRESULT
    DispatchMessage = get_winfunc(
        "user32",
        "DispatchMessageW",
        LRESULT,
        (LPMSG,)
    )

    msg = MSG()
    lpmsg = byref(msg)
    while GetMessage(lpmsg, HWND(), 0, 0) > 0:
        TranslateMessage(lpmsg)
        DispatchMessage(lpmsg) 
Example 29
Project: android_universal   Author: bkerler   File: test_callbacks.py    License: MIT License 5 votes vote down vote up
def test_issue_8959_b(self):
        from ctypes.wintypes import BOOL, HWND, LPARAM
        global windowCount
        windowCount = 0

        @WINFUNCTYPE(BOOL, HWND, LPARAM)
        def EnumWindowsCallbackFunc(hwnd, lParam):
            global windowCount
            windowCount += 1
            return True #Allow windows to keep enumerating

        windll.user32.EnumWindows(EnumWindowsCallbackFunc, 0) 
Example 30
Project: android_universal   Author: bkerler   File: test_win32.py    License: MIT License 5 votes vote down vote up
def test_HWND(self):
        from ctypes import wintypes
        self.assertEqual(sizeof(wintypes.HWND), sizeof(c_void_p))