Beispiel #1
0
    def wrapper(*args, **kwargs):
        if HK_WORKER_THREAD is None:
            raise Exception("No Hotkey Worker Thread",
                            threading.current_thread())

        t = threading.current_thread()

        if t == HK_WORKER_THREAD:
            return f(*args, **kwargs)

        e = threading.Event()
        data = (e, f, args, kwargs)
        po = py_object(data)
        lp = LPARAM(addressof(po))
        # hold on to lp in local variable so data stays valid
        if not windll.user32.PostThreadMessageW(HK_WORKER_THREAD_ID, WM_NOTIFY,
                                                0, lp):
            raise WinError()

        if not e.wait(timeout=5):
            raise TypeError("Hotkey Worker not Responding", e)

        if e._exception:
            raise e._exception
        return e._result
def PostMessage(hwnd, msg, wparam, lparam):
    if not isinstance(wparam, WPARAM):
        wparam = WPARAM(wparam)

    if not isinstance(lparam, LPARAM):
        lparam = LPARAM(lparam)

    return _PostMessage(hwnd, msg, wparam, lparam)
Beispiel #3
0
    def py_drop_func(hwnd, msg, wp, lp):
        global files, SetWindowLong
        if msg == WM_DROPFILES:
            pwint = WPARAM(wp)
            count = ctypes.windll.shell32.DragQueryFile(pwint, -1, None, None)
            szFile = ctypes.c_buffer(1024)
            files = []
            for i in range(count):
                ctypes.windll.shell32.DragQueryFile(pwint, i, szFile,
                                                    ctypes.sizeof(szFile))
                dropname = szFile.value
                files.append(dropname)
                #print(dropname)
            func(files)
            ctypes.windll.shell32.DragFinish(pwint)
        oldfunc = globals()[old]

        return CallWindowProcW(LPCVOID(oldfunc), hwnd, msg, WPARAM(wp),
                               LPARAM(lp))
Beispiel #4
0
 def from_param(cls, param):
     if isinstance(param, six.string_types):
         return LPVOID.from_param(six.text_type(param))
     return LPARAM.from_param(param)
Beispiel #5
0
 def ListCurrentWindows():
     callback_proto = WINFUNCTYPE(BOOL, HWND, LPARAM)
     callback = callback_proto(WindowWatcher._PrintWindowsCallback)
     ctypes.windll.User32.EnumWindows(callback, LPARAM(0))
Beispiel #6
0
def unicode_as_lparam(source):
    pointer = ctypes.cast(ctypes.c_wchar_p(source), ctypes.c_void_p)
    return LPARAM(pointer.value)
Beispiel #7
0
 def from_param(cls, param):
     if isinstance(param, six.string_types):
         return LPVOID.from_param(six.text_type(param))
     return LPARAM.from_param(param)
Beispiel #8
0
 def adjustMaximizedClientRect(self, hWnd: HWND, lParam: int):
     """ 窗口最大化时调整大小 """
     self.dll.adjustMaximizedClientRect(hWnd, LPARAM(lParam))
Beispiel #9
0
        # Enter
        ip.type_input.ki.wVk = WORD(13)
        ip.type_input.ki.dwFlags = DWORD(2)
        ctypes.windll.User32.SendInput(UINT(1), byref(ip),
                                       c_int(ctypes.sizeof(ip)))

        sleep(0.1)

        # Enter
        ip.type_input.ki.wVk = WORD(13)
        ip.type_input.ki.dwFlags = DWORD(0)
        ctypes.windll.User32.SendInput(UINT(1), byref(ip),
                                       c_int(ctypes.sizeof(ip)))

        # Enter
        ip.type_input.ki.wVk = WORD(13)
        ip.type_input.ki.dwFlags = DWORD(2)
        ctypes.windll.User32.SendInput(UINT(1), byref(ip),
                                       c_int(ctypes.sizeof(ip)))

        sleep(0.1)


callback = callback_proto(EnumWindowsCallback)

ctypes.windll.User32.EnumWindows(callback, LPARAM(0))
'''
	windows native type
["ARRAY", "ATOM", "ArgumentError", "Array", "BOOL", "BOOLEAN", "BYTE", "BigEndianStructure", "CDLL", "CFUNCTYPE", "COLORREF", "DEFAULT_MODE", "DOUBLE", "DWORD", "DllCanUnloadNow", "DllGetClassObject", "FILETIME", "FLOAT", "FormatError", "GetLastError", "HACCEL", "HANDLE", "HBITMAP", "HBRUSH", "HCOLORSPACE", "HDC", "HDESK", "HDWP", "HENHMETAFILE", "HFONT", "HGDIOBJ", "HGLOBAL", "HHOOK", "HICON", "HINSTANCE", "HKEY", "HKL", "HLOCAL", "HMENU", "HMETAFILE", "HMODULE", "HMONITOR", "HPALETTE", "HPEN", "HRESULT", "HRGN", "HRSRC", "HSTR", "HTASK", "HWINSTA", "HWND", "INT", "LANGID", "LARGE_INTEGER", "LCID", "LCTYPE", "LGRPID", "LONG", "LPARAM", "LPCOLESTR", "LPCSTR", "LPCVOID", "LPCWSTR", "LPOLESTR", "LPSTR", "LPVOID", "LPWSTR", "LibraryLoader", "LittleEndianStructure", "MAX_PATH", "MSG", "OLESTR", "OleDLL", "POINT", "POINTER", "POINTL", "PYFUNCTYPE", "PyDLL", "RECT", "RECTL", "RGB", "RTLD_GLOBAL", "RTLD_LOCAL", "SC_HANDLE", "SERVICE_STATUS_HANDLE", "SHORT", "SIZE", "SIZEL", "SMALL_RECT", "SetPointerType", "Structure", "UINT", "ULARGE_INTEGER", "ULONG", "USHORT", "Union", "VARIANT_BOOL", "WCHAR", "WIN32_FIND_DATAA", "WIN32_FIND_DATAW", "WINFUNCTYPE", "WORD", "WPARAM", "WinDLL", "WinError", "_COORD", "_FILETIME", "_LARGE_INTEGER", "_POINTL", "_RECTL", "_SMALL_RECT", "_SimpleCData", "_ULARGE_INTEGER", "__all__", "__builtins__", "__doc__", "__file__", "__name__", "__package__", "addressof", "alignment", "byref", "c_bool", "c_buffer", "c_byte", "c_char", "c_char_p", "c_double", "c_float", "c_int", "c_int16", "c_int32", "c_int64", "c_int8", "c_long", "c_longdouble", "c_longlong", "c_short", "c_size_t", "c_ssize_t", "c_ubyte", "c_uint", "c_uint16", "c_uint32", "c_uint64", "c_uint8", "c_ulong", "c_ulonglong", "c_ushort", "c_void_p", "c_voidp", "c_wchar", "c_wchar_p", "cast", "cdll", "create_string_buffer", "create_unicode_buffer", "get_errno", "get_last_error", "memmove", "memset", "oledll", "pointer", "py_object", "pydll", "pythonapi", "resize", "set_conversion_mode", "set_errno", "set_last_error", "sizeof", "string_at", "tagMSG", "tagPOINT", "tagRECT", "tagSIZE", "windll", "wstring_at"]
'''