def init(hwnd, wm):
    """
    This function should be called to use other functions in iMON Display API.
    When the caller application calls this function, API tries to request Display Plug-in Mode to iMON.

    Parameters
    ---------
    hwnd : HWND
        API will send/post message to this handle. hwnd is a reference to a win32 window, specifically
    wm : UINT
        API will send/post message to hwndNoti with this message identifier, such as that created by the win32 api
        RegisterWindowMessage("IMON_DISPLAY")

    Returns
    -------
    DSPResult : EnumMember
        This function will return one of DSPResult DSP_SUCCEEDED enum on success.
        only returned if succeeded.

    Raises
    ------
    Exception
        Raised when any response is return from IMON that is not a success.
        This can includeDSP_E_INVALIDARG or DSP_E_OUTOFMEMORY errors from the
        DSPResult Enumorater.

    """
    result = imonDll.IMON_Display_Init(HWND(hwnd), UINT(wm))
    if (result == DSPResult.DSP_SUCCEEDED):
        return result
    raise Exception, result.name
def GetProcessName(hwnd):
    if not isinstance(hwnd, HWND):
        hwnd = HWND(hwnd)

    lpdwProcessId = DWORD()
    _GetWindowThreadProcessId(hwnd, ctypes.byref(lpdwProcessId))

    hProcess = _OpenProcess(DWORD(PROCESS_QUERY_INFORMATION), BOOL(False),
                            lpdwProcessId)

    lpdwSize = DWORD(MAX_PATH)

    lpExeName = ctypes.create_string_buffer(MAX_PATH)
    _QueryFullProcessImageName(hProcess, DWORD(0), lpExeName,
                               ctypes.byref(lpdwSize))

    if sys.version_info[0] == 2:
        res = ''
    else:
        res = b''

    for i in range(260):
        if sys.version_info[0] == 2:
            if lpExeName[i] == '\x00':
                continue
        else:
            if lpExeName[i] == b'\x00':
                continue

        res += lpExeName[i]

    if res:
        res = os.path.split(res)[-1]
    return res
Example #3
0
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)
 def __init__(self, camera_id=0):
     #self.id = camera_id
     HCAM.__init__(self, 0)
     self.h = CALL('InitCamera', ctypes.byref(self), HWND(0))
     self.width = 1024
     self.height = 768
     self.data = np.zeros((self.height, self.width), dtype=np.int8)
Example #5
0
def get_dc():
    hdc = GetDC(HWND(None))

    if not hdc:
        raise RuntimeError('GetDC(HWND(NULL)) returned NULL')

    return hdc
Example #6
0
    def get_client_id(self, protocol, deviceID, speed):
        """
        Loads the DLL in to Python and assignes self.nClientID. This is used to reference the DLL client in the app.
        Saves successful clients to a json file so it doesn't ask the user for input each time.
        """
        QCoreApplication.processEvents()
        nClientID = None
        if len(speed) > 0 and (protocol == "J1939" or protocol == "CAN"
                               or protocol == "ISO15765"):
            protocol_bytes = bytes(protocol + ":Baud={}".format(speed),
                                   'ascii')
        else:
            protocol_bytes = bytes(protocol, 'ascii')
        logger.debug("Connecting with ClientConnect using " +
                     repr(protocol_bytes))
        try:
            nClientID = self.ClientConnect(HWND(None), c_short(deviceID),
                                           protocol_bytes, 0, 0, 0)
            logger.debug("The Client ID is: {}, which means {}".format(
                nClientID, self.get_error_code(nClientID)))

        except Exception as e:
            logger.warning("Client Connect did not work.")
            logger.debug(traceback.format_exc())

        if nClientID is None:
            logger.debug("An RP1210 device is not connected properly.")
            return None
        elif nClientID < 128:
            return nClientID
        else:
            return None
Example #7
0
 def __initWidget(self):
     """ 初始化小部件 """
     self.resize(60, 800)
     self.setAttribute(Qt.WA_TranslucentBackground)
     self.setWindowFlags(Qt.NoDropShadowWindowHint | Qt.Popup)
     self.hWnd = HWND(int(self.winId()))
     self.windowEffect.setAcrylicEffect(self.hWnd, 'F2F2F299')
Example #8
0
 def setWindowEffect(self):
     """ 设置窗口特效 """
     self.hWnd = HWND(int(self.winId()))
     # 开启窗口动画
     self.windowEffect.setWindowAnimation(int(self.winId()))
     # 开启亚克力效果和阴影效果
     self.windowEffect.setAcrylicEffect(self.hWnd, 'F2F2F299', True)
Example #9
0
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)


#Go
#if __name__ == "__main__":

#get connect with server SPnet
#dde = DDEClient("Spserver", "G41")

#while True:
#print dde.request("R(56,40)")
#time.sleep(1)

#WinMSGLoop()
Example #10
0
def GetProcessName(hwnd):
    if not isinstance(hwnd, HWND):
        hwnd = HWND(hwnd)

    lpdwProcessId = DWORD()
    _GetWindowThreadProcessId(hwnd, ctypes.byref(lpdwProcessId))

    hProcess = _OpenProcess(
        DWORD(PROCESS_QUERY_INFORMATION),
        BOOL(False),
        lpdwProcessId
    )

    lpdwSize = DWORD(MAX_PATH)
    lpExeName = ctypes.create_string_buffer(MAX_PATH)

    _QueryFullProcessImageName(
        hProcess,
        DWORD(0),
        lpExeName,
        ctypes.byref(lpdwSize)
    )

    res = str(lpExeName)

    if res:
        res = os.path.split(res)[-1]
    return res
Example #11
0
def pointer_grab(window, *args):
    hwnd = get_window_handle(window)
    grablog("pointer_grab%s window=%s, hwnd=%s", args, window, hwnd)
    if not hwnd:
        window._client.pointer_grabbed = None
        return
    wrect = RECT()
    GetWindowRect(hwnd, byref(wrect))
    grablog("GetWindowRect(%i)=%s", hwnd, wrect)
    if DwmGetWindowAttribute:
        # Vista & 7 stuff
        rect = RECT()
        DWMWA_EXTENDED_FRAME_BOUNDS = 9
        DwmGetWindowAttribute(HWND(hwnd), DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
                              byref(rect), sizeof(rect))
        #wx1,wy1,wx2,wy2 = rect.left, rect.top, rect.right, rect.bottom
        grablog("DwmGetWindowAttribute: DWMWA_EXTENDED_FRAME_BOUNDS(%i)=%s",
                hwnd, (rect.left, rect.top, rect.right, rect.bottom))
    bx = GetSystemMetrics(win32con.SM_CXSIZEFRAME)
    by = GetSystemMetrics(win32con.SM_CYSIZEFRAME)
    top = by
    style = GetWindowLongW(hwnd, win32con.GWL_STYLE)
    if style & win32con.WS_CAPTION:
        top += GetSystemMetrics(win32con.SM_CYCAPTION)
    grablog(" window style=%s, SIZEFRAME=%s, top=%i", style_str(style),
            (bx, by), top)
    coords = wrect.left + bx, wrect.top + top, wrect.right - bx, wrect.bottom - by
    clip = RECT(*coords)
    r = ClipCursor(clip)
    grablog("ClipCursor%s=%s", coords, r)
    window._client.pointer_grabbed = window._id
Example #12
0
def pointer_grab(window, *args):
    hwnd = get_window_handle(window)
    grablog("pointer_grab%s window=%s, hwnd=%s", args, window, hwnd)
    if not hwnd:
        window._client.pointer_grabbed = False
        return
    wx1,wy1,wx2,wy2 = win32gui.GetWindowRect(hwnd)
    grablog("GetWindowRect(%i)=%s", hwnd, (wx1,wy1,wx2,wy2))
    try:
        DwmGetWindowAttribute = ctypes.windll.dwmapi.DwmGetWindowAttribute
        # Vista & 7 stuff
        rect = ctypes.wintypes.RECT()
        DWMWA_EXTENDED_FRAME_BOUNDS = 9
        DwmGetWindowAttribute(HWND(hwnd), DWORD(DWMWA_EXTENDED_FRAME_BOUNDS), byref(rect), sizeof(rect))
        #wx1,wy1,wx2,wy2 = rect.left, rect.top, rect.right, rect.bottom
        grablog("DwmGetWindowAttribute: DWMWA_EXTENDED_FRAME_BOUNDS(%i)=%s", hwnd, (rect.left, rect.top, rect.right, rect.bottom))
    except WindowsError as e:           #@UndefinedVariable
        grablog("no DwmGetWindowAttribute: %s", e)
    bx = win32api.GetSystemMetrics(win32con.SM_CXSIZEFRAME)
    by = win32api.GetSystemMetrics(win32con.SM_CYSIZEFRAME)
    top = by
    style = win32api.GetWindowLong(hwnd, win32con.GWL_STYLE)
    if style & win32con.WS_CAPTION:
        top += win32api.GetSystemMetrics(win32con.SM_CYCAPTION)
    grablog(" window style=%s, SIZEFRAME=%s, top=%i", style_str(style), (bx, by), top)
    clip = (wx1+bx, wy1+top, wx2-bx, wy2-by)
    grablog("ClipCursor%s", clip)
    win32api.ClipCursor(clip)
    window._client.pointer_grabbed = True
Example #13
0
 def __init__(self, camera_id=0, size=(1024, 768)):
     #self.id = camera_id
     HCAM.__init__(self, 0)
     self.h = CALL('InitCamera', ctypes.byref(self), HWND(0))
     self.width = size[0]
     self.height = size[1]
     self.data = np.zeros((self.height, self.width), dtype=np.int8)
     return None
Example #14
0
 def nativeEvent(self, eventType, message):
     """ 处理windows消息 """
     msg = MSG.from_address(message.__int__())
     if msg.message == win32con.WM_NCHITTEST:
         xPos = win32api.LOWORD(msg.lParam) - self.frameGeometry().x()
         yPos = win32api.HIWORD(msg.lParam) - self.frameGeometry().y()
         w, h = self.width(), self.height()
         lx = xPos < self.BORDER_WIDTH
         rx = xPos + 9 > w - self.BORDER_WIDTH
         ty = yPos < self.BORDER_WIDTH
         by = yPos > h - self.BORDER_WIDTH
         if (lx and ty):
             return True, win32con.HTTOPLEFT
         elif (rx and by):
             return True, win32con.HTBOTTOMRIGHT
         elif (rx and ty):
             return True, win32con.HTTOPRIGHT
         elif (lx and by):
             return True, win32con.HTBOTTOMLEFT
         elif ty:
             return True, win32con.HTTOP
         elif by:
             return True, win32con.HTBOTTOM
         elif lx:
             return True, win32con.HTLEFT
         elif rx:
             return True, win32con.HTRIGHT
     elif msg.message == win32con.WM_NCCALCSIZE:
         if isMaximized(msg.hWnd):
             self.windowEffect.adjustMaximizedClientRect(
                 HWND(msg.hWnd), msg.lParam)
         return True, 0
     if msg.message == win32con.WM_GETMINMAXINFO:
         if isMaximized(msg.hWnd):
             window_rect = win32gui.GetWindowRect(msg.hWnd)
             if not window_rect:
                 return False, 0
             # 获取显示器句柄
             monitor = win32api.MonitorFromRect(window_rect)
             if not monitor:
                 return False, 0
             # 获取显示器信息
             monitor_info = win32api.GetMonitorInfo(monitor)
             monitor_rect = monitor_info['Monitor']
             work_area = monitor_info['Work']
             # 将lParam转换为MINMAXINFO指针
             info = cast(msg.lParam, POINTER(MINMAXINFO)).contents
             # 调整位置
             info.ptMaxSize.x = work_area[2] - work_area[0]
             info.ptMaxSize.y = work_area[3] - work_area[1]
             info.ptMaxTrackSize.x = info.ptMaxSize.x
             info.ptMaxTrackSize.y = info.ptMaxSize.y
             # 修改放置点的x,y坐标
             info.ptMaxPosition.x = abs(window_rect[0] - monitor_rect[0])
             info.ptMaxPosition.y = abs(window_rect[1] - monitor_rect[1])
             return True, 1
     return QWidget.nativeEvent(self, eventType, message)
Example #15
0
def PumpWindowsMessages():
    msg = MSG()
    while ctypes.windll.user32.PeekMessageW(ctypes.byref(msg), HWND(), 0, 0, PM_REMOVE):
        if msg.message == WM_QUIT:
            return False
        ctypes.windll.user32.TranslateMessage(ctypes.byref(msg))
        ctypes.windll.user32.DispatchMessageW(ctypes.byref(msg))

    return True
def GetWindowText(hwnd):
    if not isinstance(hwnd, HWND):
        hwnd = HWND(hwnd)

    nMaxCount = _GetWindowTextLength(hwnd) + 1
    lpString = ctypes.create_unicode_buffer(nMaxCount)

    _GetWindowText(hwnd, lpString, nMaxCount)

    return lpString.value
Example #17
0
 def set_placeholder(self, value):
     # This solution is based on https://stackoverflow.com/questions/4902565/watermark-textbox-in-winforms
     if self.interface.placeholder:
         # Message Code for setting Cue Banner (Placeholder)
         EM_SETCUEBANNER = c_uint(0x1501)
         # value 0 means placeholder is hidden as soon the input gets focus
         # value 1 means placeholder is hidden only after something is typed into input
         show_placeholder_on_focus = WPARAM(1)
         window_handle = HWND(self.native.Handle.ToInt32())
         user32.SendMessageW(window_handle, EM_SETCUEBANNER, show_placeholder_on_focus, self.interface.placeholder)
Example #18
0
 def notify_path_change() -> None:
     send_message_timeout_w = WinDLL('user32', use_last_error=True).SendMessageTimeoutW
     handle = HWND(0xffff)
     message = UINT(0x001A)
     l_param = c_wchar_p('Environment')
     flags = UINT(0x0002 & 0x0008)
     timeout = UINT(__class__.notify_timeout)
     result = send_message_timeout_w(handle, message, None, l_param, flags, timeout, None)
     if result == 0:
         raise WinError()
Example #19
0
 def run(self):
     self.keylogger = RawKeyboardProc(self.bufferQueue,
                                      self.keyboard,
                                      list(self.ignoreList),
                                      daemon=True)
     self.keylogger.start()
     message = json.loads(self.bufferQueue.get())
     self.keyhook = KeyboardHookProc(message["hwnd"],
                                     self.hookCommandQ,
                                     daemon=True)
     self.keylogHwnd = HWND(message["hwnd"])
     self.keyhook.start()
     if self.keyboard is not None:
         self.sigKeyboard.emit(self.keyboard)
     while True:
         if not self.bufferQueue.empty():
             jMessage = self.bufferQueue.get()
             message = json.loads(jMessage)
             if self.getKeyboard:
                 keyboard = message["keyboard"]
                 if keyboard not in self.ignoreList:
                     self.keyboard = message["keyboard"]
                     self.getKeyboard = False
                     self.sigKeyboard.emit(self.keyboard)
                     self.record_keyboard(keyboard, True)
                 else:
                     self.record_keyboard(keyboard, False)
             if (self.keyboard
                     is not None) and (self.keyboard == message["keyboard"]
                                       ) and (message["key"] is not None):
                 self.tsString.append_data(message["key"])
         if not self.commandQueue.empty():
             command = self.commandQueue.get()
             if command == "PEEK":
                 self.sigBuffer.emit(self.tsString.get_data())
             elif command == "GET":
                 print(self.tsString.get_data())
                 self.tsString.set_data("")
             elif command == "CLEAR":
                 print(self.tsString.get_data())
                 self.tsString.set_data("")
             elif command == "REGISTER":
                 self.getKeyboard = True
                 self.keyboard = None
                 self.sigKeyboard.emit(self.keyboard)
                 PostMessage(self.keylogHwnd, self.UWM_NEWNAME, 0, 0)
             elif command == "KEYBOARD":
                 self.sigKeyboard.emit(self.keyboard)
             elif command == "QUIT":
                 break
     self.hookCommandQ.put("QUIT")
     PostMessage(self.keylogHwnd, WM_QUIT, 0, 0)
     self.keyhook.join()
     self.keylogger.join()
Example #20
0
 def test_notifying_path_changes(self, WinDLL):
     path_manager.notify_path_change()
     WinDLL.assert_called_once_with('user32', use_last_error=True)
     args = WinDLL.return_value.SendMessageTimeoutW.call_args
     hwnd, msg, wParam, lParam, fuFlags, uTimeout, lpdwResult = args[0]
     self.assertEqual(hwnd.value, HWND(0xffff).value)
     self.assertEqual(msg.value, UINT(0x001A).value)
     self.assertIsNone(wParam)
     self.assertEqual(lParam.value, 'Environment')
     self.assertEqual(fuFlags.value, UINT(0x0002 & 0x0008).value)
     self.assertEqual(uTimeout.value, UINT(1000).value)
     self.assertIsNone(lpdwResult)
    def capture_window(self):
        """:returns a np array image of the dialog cropped to exclude the margins for resizing the window
        https://stackoverflow.com/questions/19695214/python-screenshot-of-inactive-window-printwindow-win32gui"""

        SoullessEnv.user32.PrintWindow(HWND(self.handle), self.saveDC_handle, 3)
        bmpstr = self.saveBitMap.GetBitmapBits(True)

        im = Image.frombuffer(
            'RGB',
            (self.bmpinfo['bmWidth'], self.bmpinfo['bmHeight']),
            bmpstr, 'raw', 'BGRX', 0, 1)
        return np.array(im, copy=False)
    def setupRP1210(self,dllName,protocol = "J1939:Channel=1",deviceID = 1):

        #Load the Windows Device Library
        RP1210DLL = windll.LoadLibrary( dllName )
                
        # Define windows prototype functions:
        # typedef short (WINAPI *fxRP1210_ClientConnect)       ( HWND, short, char *, long, long, short );
        prototype                   = WINFUNCTYPE( c_short, HWND, c_short, c_char_p, c_long, c_long, c_short)
        self.ClientConnect        = prototype( ( "RP1210_ClientConnect", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_ClientDisconnect)    ( short                                  );
        prototype                   = WINFUNCTYPE( c_short, c_short )
        self.ClientDisconnect     = prototype( ( "RP1210_ClientDisconnect", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_SendMessage)         ( short, char*, short, short, short      );
        prototype                   = WINFUNCTYPE( c_short, c_short,  POINTER( c_char*2000 ), c_short, c_short, c_short      )
        self.SendMessage          = prototype( ("RP1210_SendMessage", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_ReadMessage)         ( short, char*, short, short             );
        prototype                   = WINFUNCTYPE( c_short, c_short, POINTER( c_char*2000 ), c_short, c_short             )
        self.ReadMessage          = prototype( ("RP1210_ReadMessage", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_SendCommand)         ( short, short, char*, short             );
        prototype                   = WINFUNCTYPE( c_short, c_short, c_short, POINTER( c_char*2000 ), c_short             )
        self.SendCommand          = prototype( ("RP1210_SendCommand", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_ReadVersion)         ( char*, char*, char*, char*             );
        prototype                   = WINFUNCTYPE( c_short, c_char_p, c_char_p, c_char_p, c_char_p             )
        self.ReadVersion          = prototype( ("RP1210_ReadVersion", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_ReadDetailedVersion) ( short, char*, char*, char*             );
        prototype                   = WINFUNCTYPE( c_short, c_short, POINTER(c_char*17), POINTER(c_char*17), POINTER(c_char*17) )
        self.ReadDetailedVersion  = prototype( ("RP1210_ReadDetailedVersion", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_GetHardwareStatus)   ( short, char*, short, short             );
        prototype                   = WINFUNCTYPE( c_short, c_short, c_char_p, c_short, c_short             )
        self.GetHardwareStatus    = prototype( ("RP1210_GetHardwareStatus", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_GetErrorMsg)         ( short, char*                           );
        prototype                   = WINFUNCTYPE( c_short, c_short, c_char_p                           )
        self.GetErrorMsg          = prototype( ("RP1210_GetErrorMsg", RP1210DLL ) )

        # typedef short (WINAPI *fxRP1210_GetLastErrorMsg)     ( short, int *, char*, short             );
        prototype                   = WINFUNCTYPE( c_short, c_void_p, c_char_p, c_short             )
        self.GetLastErrorMsg      = prototype( ("RP1210_GetLastErrorMsg", RP1210DLL ) )

        print( "Attempting connect to DLL [%s], DeviceID [%d]" %( dllName, deviceID ) )

        self.szProtocolName = bytes(protocol,'ascii')
        self.nClientID = self.ClientConnect( HWND(None), c_short( deviceID ), self.szProtocolName, 0, 0, 0  )

        print('The Client ID is: %i' %self.nClientID )
Example #23
0
    def __init__(self, hwnd):
        self.hwnd = hwnd
        self.size = None
        try:
            f = ctypes.windll.dwmapi.DwmGetWindowAttribute
        except WindowsError:
            f = None
        if f:
            rect = ctypes.wintypes.RECT()
            DWMWA_EXTENDED_FRAME_BOUNDS = 9
            f(HWND(self.hwnd), DWORD(DWMWA_EXTENDED_FRAME_BOUNDS), ctypes.byref(rect), ctypes.sizeof(rect))
            self.size = (rect.right - rect.left, rect.bottom - rect.top)
        else:
            self.size = self.GetSize()

        self.hwndDC = win32gui.GetWindowDC(self.hwnd)
        self.mfcDC  = win32ui.CreateDCFromHandle(self.hwndDC)
        self.saveDC = self.mfcDC.CreateCompatibleDC()
Example #24
0
def nlog(hwnd=None, *argv) -> None:
    EM_REPLACESEL = 0x00C2
    edit = HWND()

    #if hwnd == None:
    #    print("Please run notepad.exe")
    #    pass

    # HWND FindWindowExA(
    #     HWND   hWndParent,
    #     HWND   hWndChildAfter,
    #     LPCSTR lpszClass,
    #     LPCSTR lpszWindow
    # );

    edit_id = c_wchar_p('EDIT')
    edit = FindWindowEx(hwnd, None, edit_id, None)
    for arg in argv:
        log = '{} {} {}'.format(datetime.now().ctime(), arg, "\r\n")
        SendMessage(edit, EM_REPLACESEL, True, log)
Example #25
0
 def __init__(self, songInfo: dict, parent=None):
     super().__init__(parent)
     self.originWidth = 1280
     # 实例化窗口特效
     self.windowEffect = WindowEffect()
     self.hWnd = HWND(int(self.winId()))
     self.acrylicColor = '225c7fCC'
     self.dominantColor = DominantColor()
     # 记录移动次数
     self.moveTime = 0
     self.resizeTime = 0
     # 实例化小部件
     self.playProgressBar = PlayProgressBar(
         songInfo.get('duration', '0:00'), self)
     self.songInfoCard = SongInfoCard(songInfo, self)
     self.centralButtonGroup = CentralButtonGroup(self)
     self.rightWidgetGroup = RightWidgetGroup(self)
     self.moreActionsMenu = MoreActionsMenu(self)
     # 初始化小部件
     self.__initWidget()
     self.__setQss()
Example #26
0
def get_actual_rect(hwnd):
    """Gets correct dimensions of a DWM controlled window

    "Retrieves the extended frame bounds rectangle in screen space".
    Windows 10 reports (technically) incorrect window dimensions,
    so this is used to obtain the correct window dimensions.

    Args:
        hwnd: The handle to the window from which the attribute data is retrieved.

    Returns:
        A windows RECT structure of the correct window dimensions.
    """
    rect = RECT()
    DWMWA_EXTENDED_FRAME_BOUNDS = 9
    dwmapi.DwmGetWindowAttribute(HWND(hwnd),
                                 DWORD(DWMWA_EXTENDED_FRAME_BOUNDS),
                                 ctypes.byref(rect), ctypes.sizeof(rect))
    # actual_x1 = rect.left
    # actual_y1 = rect.top
    # actual_x2 = rect.right
    # actual_y2 = rect.bottom
    # return [actual_x1, actual_y1, actual_x2, actual_y2]
    return rect
Example #27
0
OBJID_VSCROLL = -5
OBJID_HSCROLL = -6
OBJID_SIZEGRIP = -7
OBJID_CARET = -8
OBJID_CURSOR = -9
OBJID_ALERT = -10
OBJID_SOUND = -11
OBJID_NATIVEOM = -16

# ShowWindow() commands
SW_HIDE = 0
SW_SHOWNORMAL = 1
SW_SHOWNA = 8

# SetWindowPos window constants
HWND_TOPMOST = HWND(-1)

# window sizing and positioning flags
SWP_NOACTIVATE = 0x0010
SWP_NOMOVE = 0x0002
SWP_NOSIZE = 0x0001
SWP_SHOWWINDOW = 0x0040

# RedrawWindow() flags
RDW_INVALIDATE = 0x0001
RDW_UPDATENOW = 0x0100
# MsgWaitForMultipleObjectsEx
QS_ALLINPUT = 0x04ff
MWMO_ALERTABLE = 0x0002

# GetSystemMetrics constants
Example #28
0
# BOOL SetPriorityClass(
#   HANDLE hProcess,
#   DWORD  dwPriorityClass
# );
SetPriorityClass = kernel32.SetPriorityClass
SetPriorityClass.argtypes = [HANDLE, DWORD]
SetPriorityClass.restype = BOOL

HIGH_PRIORITY_CLASS = 0x00000080
REALTIME_PRIORITY_CLASS = 0x00000100

### 进程操作

# 窗口句柄
pvz_hwnd = HWND()

# 进程标识
pvz_pid = DWORD()

# 进程句柄
pvz_handle = HANDLE()

# 游戏版本
pvz_version = None


def is_valid():
    """
    检查目标进程是否可用.
Example #29
0
# typedef short (WINAPI *fxRP1210_GetErrorMsg)         ( short, char*                           );
prototype = WINFUNCTYPE(c_short, c_short, c_char_p)
RP1210_GetErrorMsg = prototype(("RP1210_GetErrorMsg", RP1210DLL))

# typedef short (WINAPI *fxRP1210_GetLastErrorMsg)     ( short, int *, char*, short             );
prototype = WINFUNCTYPE(c_short, c_void_p, c_char_p, c_short)
RP1210_GetLastErrorMsg = prototype(("RP1210_GetLastErrorMsg", RP1210DLL))

clientNames = {}  # build a dictionary of client Connect sessions

# Connect to Device
print("Attempting connect to DLL [%s], DeviceID [%d]" % (dllName, deviceID))
szProtocolName = bytes(
    "J1939:Channel=1;Baud=Auto", 'ascii'
)  #This protocol name comes from the .ini file in the Windows directory.
nClientID = RP1210_ClientConnect(HWND(None), c_short(deviceID), szProtocolName,
                                 0, 0, 0)
clientNames[nClientID] = str(szProtocolName, 'ascii')
print('The Client ID is: %i for Protocol: %s' %
      (nClientID, str(szProtocolName, 'ascii')))

# szProtocolName = bytes("J1708",'ascii') #This protocol name comes from the .ini file in the Windows directory.
# nClientID = RP1210_ClientConnect( HWND(None), c_short( deviceID ), szProtocolName, 0, 0, 0  )
# clientNames[nClientID] = str(szProtocolName,'ascii')
# print('The Client ID is: %i for Protocol: %s' %(nClientID, str(szProtocolName,'ascii') ))

#-----------------------------------------------------------------------------------------------------
# Call RP1210_ReadDetailedVersion to get DLL, API, FW versions.
#-----------------------------------------------------------------------------------------------------

chAPIVersionInfo = (c_char * 17)()
Example #30
0
    def call_dll(win):
        # 调用 api
        hWnd = HWND(int(win.winId()))  # 直接HWND(self.winId())会报错
        gradientColor = DWORD(0x50F2F2F2)  # 设置和亚克力效果相叠加的背景颜色

        CallDll._DLL.setBlur(hWnd, gradientColor)