Exemple #1
0
 def ISO_6C_BlockWrite(self, DevID, pBlockparam, pData, nCount, nAntennaID):
     ''' 标签块写操作,可以改写EPC, User, Reserved区 '''
     func = self.__dll.ISO_6C_BlockWrite
     func.argtypes = (c_char_p, POINTER(BlockInfo), POINTER(ResultdData),
                      POINTER(c_int), c_int)
     func.restype = UINT
     return func(DevID, pBlockparam, pData, nCount, nAntennaID)
Exemple #2
0
 def GetGpIO(self, DevID, io, pRepMsg):
     ''' 查询GPIO口的信息 '''
     func = self.__dll.GetGpIO
     func.argtypes = (c_char_p, POINTER(GPIO),
                      POINTER(DEVICE_GPI_STATUS_RESULT))
     func.restype = UINT
     return func(DevID, io, pRepMsg)
class IVirtualDesktopManager(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopManager
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method IsWindowOnCurrentVirtualDesktop')],
            HRESULT,
            'IsWindowOnCurrentVirtualDesktop',
            (['in'], HWND, 'topLevelWindow'),
            (['out'], POINTER(BOOL), 'onCurrentDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method GetWindowDesktopId')],
            HRESULT,
            'GetWindowDesktopId',
            (['in'], HWND, 'topLevelWindow'),
            (['out'], POINTER(GUID), 'desktopId'),
        ),
        COMMETHOD(
            [helpstring('Method MoveWindowToDesktop')],
            HRESULT,
            'MoveWindowToDesktop',
            (['in'], HWND, 'topLevelWindow'),
            (['in'], REFGUID, 'desktopId'),
        ),
    ]
class IInspectable(comtypes.IUnknown):
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = IID_IInspectable
    _methods_ = [
        COMMETHOD(
            [helpstring('Method GetIids')],
            HRESULT,
            'GetIids',
            (['out'], POINTER(ULONG), 'iidCount'),
            (['out'], POINTER(POINTER(IID)), 'iids'),
        ),
        COMMETHOD(
            [helpstring('Method GetRuntimeClassName')],
            HRESULT,
            'GetRuntimeClassName',
            (['out'], POINTER(HSTRING), 'className'),
        ),
        COMMETHOD(
            [helpstring('Method GetTrustLevel')],
            HRESULT,
            'GetTrustLevel',
            (['out'], POINTER(TrustLevel), 'trustLevel'),
        ),
    ]
Exemple #5
0
    def getFileVersion(self,filename):
        from ctypes.wintypes import (
            windll, sizeof, WinError, byref, POINTER, cast, c_char, Structure, c_uint,
            pointer, BOOL, DWORD, LPVOID, LPCVOID, LPCWSTR,
        )

        class VS_FIXEDFILEINFO(Structure):
            _fields_ = [
                ("dwSignature", DWORD), # will be 0xFEEF04BD
                ("dwStrucVersion", DWORD),
                ("dwFileVersionMS", DWORD),
                ("dwFileVersionLS", DWORD),
                ("dwProductVersionMS", DWORD),
                ("dwProductVersionLS", DWORD),
                ("dwFileFlagsMask", DWORD),
                ("dwFileFlags", DWORD),
                ("dwFileOS", DWORD),
                ("dwFileType", DWORD),
                ("dwFileSubtype", DWORD),
                ("dwFileDateMS", DWORD),
                ("dwFileDateLS", DWORD)
        ]

        PUINT = POINTER(c_uint)
        LPDWORD = POINTER(DWORD)

        GetFileVersionInfoSizeW = windll.version.GetFileVersionInfoSizeW
        GetFileVersionInfoSizeW.restype = DWORD
        GetFileVersionInfoSizeW.argtypes = [LPCWSTR, LPDWORD]
        GetFileVersionInfoSize = GetFileVersionInfoSizeW # alias

        GetFileVersionInfoW = windll.version.GetFileVersionInfoW
        GetFileVersionInfoW.restype = BOOL
        GetFileVersionInfoW.argtypes = [LPCWSTR, DWORD, DWORD, LPVOID]
        GetFileVersionInfo = GetFileVersionInfoW # alias

        VerQueryValueW = windll.version.VerQueryValueW
        VerQueryValueW.restype = BOOL
        VerQueryValueW.argtypes = [LPCVOID, LPCWSTR, POINTER(LPVOID), PUINT]
        VerQueryValue = VerQueryValueW # alias

        filename = unicode(filename)
    
        dwLen  = GetFileVersionInfoSize(filename, None)
        if not dwLen :
            raise WinError()
        lpData = (c_char * dwLen)()
        if not GetFileVersionInfo(filename, 0, sizeof(lpData), lpData):
            raise WinError()
        uLen = c_uint()
        lpffi = POINTER(VS_FIXEDFILEINFO)()
        lplpBuffer = cast(pointer(lpffi), POINTER(LPVOID))
        if not VerQueryValue(lpData, u"\\", lplpBuffer, byref(uLen)):
            raise WinError()
        ffi = lpffi.contents
        return [int(ffi.dwFileVersionMS >> 16),
            int(ffi.dwFileVersionMS & 0xFFFF),
            int(ffi.dwFileVersionLS >> 16),
            int(ffi.dwFileVersionLS & 0xFFFF)]
Exemple #6
0
 def ISO_6C_Lock(self, DevID, permission, nAntennaID, strEPC, nEpcLength,
                 pData):
     ''' 锁定标签操作 '''
     func = self.__dll.ISO_6C_Lock
     func.argtypes = (c_char_p, POINTER(LockPermissions), c_int, c_char_p,
                      c_int, POINTER(ResultdData))
     func.restype = UINT
     return func(DevID, permission, nAntennaID, strEPC, nEpcLength, pData)
Exemple #7
0
 def ISO_6C_Write(self, DevID, antennaID, blockparam, pData, nCount,
                  bEncrypt, bCheckSig):
     ''' 标签写操作,可以改写EPC, User, Reserved区 '''
     func = self.__dll.ISO_6C_Write
     func.argtypes = (c_char_p, c_byte, POINTER(BlockInfo),
                      POINTER(ResultdData), POINTER(c_int), c_bool, c_bool)
     func.restype = UINT
     return func(DevID, antennaID, blockparam, pData, nCount, bEncrypt,
                 bCheckSig)
Exemple #8
0
 def ISO_6C_Kill(self, DevID, unAccessword, unKillword, nAntennaID, strEPC,
                 nEpcLength, pData, nCount):
     ''' 杀死标签操作 '''
     func = self.__dll.ISO_6C_Kill
     func.argtypes = (c_char_p, c_uint, c_uint, c_byte, c_char_p, c_byte,
                      POINTER(ResultdData), POINTER(c_int))
     func.restype = UINT
     return func(DevID, unAccessword, unKillword, nAntennaID, strEPC,
                 nEpcLength, pData, nCount)
Exemple #9
0
 def ISO_6C_BlockErase(self, DevID, nAntennaID, pBlockparam, pData, nCount):
     ''' 
     标签块擦除操作,可以清理EPC, User, Reserved区 
     该函数的参数:DveID:c_char nAntenna:BlockInfo, pBlockparam:ResultdData, pData:LP_c_long
     '''
     func = self.__dll.ISO_6C_BlockErase
     func.argtypes = (c_char_p, POINTER(BlockInfo), POINTER(ResultdData),
                      POINTER(c_int))
     func.restype = UINT
     return func(DevID, nAntennaID, pBlockparam, pData, nCount)
Exemple #10
0
 def ISO_6C_ReadCycle(self, pszDevID, nAntennaID, pBlockparam, ardi,
                      bEncrypt, bCheckSig):
     ''' 进行快速的读取操作, 并且多次循环进行读操作的情形 '''
     prototype = CFUNCTYPE(UINT, c_char_p, c_int, POINTER(BlockInfo),
                           POINTER(ALLReadDataInfo), c_bool, c_bool)
     params = (1, 'pszDevID'), (1, 'nAntennaID'), (1, 'pBlockparam'), (
         1, 'ardi'), (1, 'bEncrypt'), (1, 'bCheckSig')
     func = prototype(('ISO_6C_ReadCycle', self.__dll), params)
     return func(pszDevID=pszDevID,
                 nAntennaID=nAntennaID,
                 pBlockparam=pBlockparam,
                 ardi=ardi,
                 bEncrypt=bEncrypt,
                 bCheckSig=bCheckSig)
Exemple #11
0
        def nonBlockedRead(self, output):
            if 'linux' in sys.paltform:
                fd = output.fileno()
                fl = fcntl.fcnt(fd, fcntl.F_GETFL)
                fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
                try:
                    return output.read()
                except Exception as ex:
                    return ''
            elif 'win32' in sys.platform:
                LPDWORD = POINTER(DWORD)
                PIPE_NOWAIT = wintypes.DWORD(0x00000001)
                ERROR_NO_DATA = 232

                SetNamedPipeHandleState = windll.kernel32.SetNamedPipeHandleState
                SetNamedPipeHandleState.argtypes = [
                    HANDLE, LPDWORD, LPDWORD, LPDWORD
                ]
                SetNamedPipeHandleState.restype = BOOL
                h = msvcrt.get_osfhandle(output)
                res = windll.kernel32.SetNamedPipeHandleState(
                    h, byref(PIPE_NOWAIT), None, None)
                if res == 0:
                    logger.error('Error reading pipe %s' % WinError())
                    return ''
                return h
Exemple #12
0
 def ISO_6C_Read(self, DevID, antennaID, blockparam, pData, nCount,
                 bEncrypt, bCheckSig):
     ''' 读取标签块区操作,可以读取EPC, User, Reserved, TID区  '''
     prototype = CFUNCTYPE(UINT, c_char_p, c_int, POINTER(BlockInfo),
                           POINTER(READ_REPORT_RESULT), POINTER(c_int),
                           c_bool, c_bool)
     params = (1, 'DevID'), (1, 'antennaID'), (1, 'blockparam'), (
         1, 'pData'), (1, 'nCount'), (1, 'bEncrypt'), (1, 'bCheckSig')
     func = prototype(('ISO_6C_Read', self.__dll), params)
     return func(DevID=DevID,
                 antennaID=antennaID,
                 blockparam=blockparam,
                 pData=pData,
                 nCount=nCount,
                 bEncrypt=bEncrypt,
                 bCheckSig=bCheckSig)
Exemple #13
0
 def ISO_6C_GetPeriodInventoryResult(self, DevID, tags):
     ''' 配合周期性盘点使用,先调用开始周期性盘点后,再立即循环调用该函数获取盘点到的标签,停止周期性盘点后,也就停止调用该函数 '''
     prototype = CFUNCTYPE(UINT, c_char_p, POINTER(AllTagInfo))
     params = (1, 'DevID'), (1, 'tags')
     func = prototype(('ISO_6C_GetPeriodInventoryResult', self.__dll),
                      params)
     return func(DevID=DevID, tags=byref(tags))
Exemple #14
0
 def ISO_6C_WriteCycle(self, pszDevID, nAntennaID, pBlockparam, bEncrypt,
                       bCheckSig):
     ''' 进行快速的写操作,并且多次循环进行写操作的情形 '''
     func = self.__dll.ISO_6C_WriteCycle
     func.argtypes = (c_char_p, c_int, POINTER(BlockInfo), c_bool, c_bool)
     func.restype = UINT
     return func(pszDevID, nAntennaID, pBlockparam, bEncrypt, bCheckSig)
Exemple #15
0
def _make_non_blocking(file_obj):
    """make file object non-blocking
    Windows doesn't have the fcntl module, but someone on
    stack overflow supplied this code as an answer, and it works
    http://stackoverflow.com/a/34504971/2893090"""

    if USING_WINDOWS:
        import msvcrt
        from ctypes import windll, byref, wintypes, WinError
        from ctypes.wintypes import HANDLE, DWORD, POINTER, BOOL
        LPDWORD = POINTER(DWORD)
        PIPE_NOWAIT = wintypes.DWORD(0x00000001)

        SetNamedPipeHandleState = windll.kernel32.SetNamedPipeHandleState
        SetNamedPipeHandleState.argtypes = [HANDLE, LPDWORD, LPDWORD, LPDWORD]
        SetNamedPipeHandleState.restype = BOOL

        h = msvcrt.get_osfhandle(file_obj.fileno())

        res = windll.kernel32.SetNamedPipeHandleState(h, byref(PIPE_NOWAIT),
                                                      None, None)
        if res == 0:
            raise ValueError(WinError())

    else:
        import fcntl
        # Set the file status flag (F_SETFL) on the pipes to be non-blocking
        # so we can attempt to read from a pipe with no new data without locking
        # the program up
        fcntl.fcntl(file_obj, fcntl.F_SETFL, os.O_NONBLOCK)
class IVirtualDesktopNotification(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopNotification
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method VirtualDesktopCreated')],
            HRESULT,
            'VirtualDesktopCreated',
            (['in'], POINTER(IVirtualDesktop), 'pDesktop'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyBegin')],
            HRESULT,
            'VirtualDesktopDestroyBegin',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyFailed')],
            HRESULT,
            'VirtualDesktopDestroyFailed',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method VirtualDesktopDestroyed')],
            HRESULT,
            'VirtualDesktopDestroyed',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopDestroyed'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopFallback'),
        ),
        COMMETHOD(
            [helpstring('Method ViewVirtualDesktopChanged')],
            HRESULT,
            'ViewVirtualDesktopChanged',
            (['in'], POINTER(IApplicationView), 'pView'),
        ),
        COMMETHOD(
            [helpstring('Method CurrentVirtualDesktopChanged')],
            HRESULT,
            'CurrentVirtualDesktopChanged',
            (['in'], POINTER(IVirtualDesktop), 'pDesktopOld'),
            (['in'], POINTER(IVirtualDesktop), 'pDesktopNew'),
        ),
    ]
class IVirtualDesktop(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktop
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method IsViewVisible')],
            HRESULT,
            'IsViewVisible',
            (['out'], POINTER(IApplicationView), 'pView'),
            (['out'], POINTER(INT), 'pfVisible'),
        ),
        COMMETHOD(
            [helpstring('Method GetID')],
            HRESULT,
            'GetID',
            (['out'], POINTER(GUID), 'pGuid'),
        )
    ]
class IVirtualDesktopNotificationService(comtypes.IUnknown):
    _case_insensitive_ = True
    _iid_ = IID_IVirtualDesktopNotificationService
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method Register')],
            HRESULT,
            'Register',
            (['in'], POINTER(IVirtualDesktopNotification), 'pNotification'),
            (['out'], POINTER(DWORD), 'pdwCookie'),
        ),
        COMMETHOD(
            [helpstring('Method Unregister')],
            HRESULT,
            'Unregister',
            (['in'], DWORD, 'dwCookie'),
        ),
    ]
class Text:
    REFGUID = POINTER(GUID)
    REFIID = REFGUID
    ENUM = INT
    IID = GUID
    INT32 = ctypes.c_int32
    INT64 = ctypes.c_int64
    CLSID_ImmersiveShell = GUID('{C2F03A33-21F5-47FA-B4BB-156362A2F239}')
    CLSID_IVirtualNotificationService = GUID(
        '{A501FDEC-4A09-464C-AE4E-1B9C21B84918}')
def GetFileVersion(filename):
    dwLen = GetFileVersionInfoSize(filename, None)
    if not dwLen:
        raise WinError()
    lpData = (c_char * dwLen)()
    if not GetFileVersionInfo(filename, 0, sizeof(lpData), lpData):
        raise WinError()
    uLen = c_uint()
    lpffi = POINTER(VS_FIXEDFILEINFO)()
    lplpBuffer = cast(pointer(lpffi), POINTER(LPVOID))
    if not VerQueryValue(lpData, u"\\", lplpBuffer, byref(uLen)):
        raise WinError()
    ffi = lpffi.contents
    return (
        ffi.dwFileVersionMS >> 16,
        ffi.dwFileVersionMS & 0xFFFF,
        ffi.dwFileVersionLS >> 16,
        ffi.dwFileVersionLS & 0xFFFF,
    )
class IApplicationViewConsolidatedEventArgs(IInspectable):
    _case_insensitive_ = True
    _iid_ = IID_IApplicationViewConsolidatedEventArgs
    _idlflags_ = []
    _methods_ = [
        COMMETHOD(
            [helpstring('Method get_IsUserInitiated')],
            HRESULT,
            'get_IsUserInitiated',
            (['retval', 'out'], POINTER(BOOL), 'value'),
        ),
    ]
Exemple #22
0
    def getdirinfo(path):
        import ctypes
        from ctypes import c_void_p, c_wchar_p, Structure, WinError
        from ctypes.wintypes import DWORD, HANDLE, POINTER, BOOL

        FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
        FILE_SHARE_READ = 0x00000001
        OPEN_EXISTING = 3

        class FILETIME(Structure):
            _fields_ = [("dwLowDateTime", DWORD), ("dwHighDateTime", DWORD)]

        class BY_HANDLE_FILE_INFORMATION(Structure):
            _fields_ = [("dwFileAttributes", DWORD),
                        ("ftCreationTime", FILETIME),
                        ("ftLastAccessTime", FILETIME),
                        ("ftLastWriteTime", FILETIME),
                        ("dwVolumeSerialNumber", DWORD),
                        ("nFileSizeHigh", DWORD), ("nFileSizeLow", DWORD),
                        ("nNumberOfLinks", DWORD), ("nFileIndexHigh", DWORD),
                        ("nFileIndexLow", DWORD)]

        flags = FILE_FLAG_BACKUP_SEMANTICS

        func = ctypes.windll.kernel32.CreateFileW
        func.argtypes = [
            c_wchar_p, DWORD, DWORD, c_void_p, DWORD, DWORD, HANDLE
        ]
        func.restype = HANDLE

        hfile = func(path, 0, FILE_SHARE_READ, None, OPEN_EXISTING, flags,
                     None)
        if hfile is None:
            raise WinError()

        func = ctypes.windll.kernel32.GetFileInformationByHandle
        func.argtypes = [HANDLE, POINTER(BY_HANDLE_FILE_INFORMATION)]
        func.restype = BOOL

        info = BY_HANDLE_FILE_INFORMATION()
        rv = func(hfile, info)

        func = ctypes.windll.kernel32.CloseHandle
        func.argtypes = [HANDLE]
        func.restype = BOOL

        func(hfile)

        if rv == 0:
            raise WinError()

        return info
Exemple #23
0
	def __enter__(self):
		self.handle = HANDLE()
		name = LPCSTR(self.printer_name)
		if not OpenPrinterA(name, pointer(self.handle), None):
			raise Exception("failed to open printer %s" % self.printer_name)
		log("OpenPrinter: handle=%#x", self.handle.value)
		size = DWORD(0)
		GetPrinterA(self.handle, 1, None, 0, pointer(size))
		if size.value==0:
			raise Exception("GetPrinterA PRINTER_INFO_1 failed for '%s'" % self.printer_name)
		log("GetPrinter: PRINTER_INFO_1 size=%#x", size.value)
		self.info1 = msvcrt.malloc(size.value)
		if not GetPrinterA(self.handle, 1, self.info1, size.value, pointer(size)):
			raise Exception("GetPrinterA PRINTER_INFO_1 failed for '%s'", self.printer_name)
		info = cast(self.info1, POINTER(PRINTER_INFO_1))
		log(" flags=%#x" % info[0].Flags)
		log(" name=%#s" % info[0].pName)
		log(" description=%s" % info[0].pDescription)
		log(" comment=%s" % info[0].pComment)

		size = DWORD(0)
		GetPrinterA(self.handle, 2, None, 0, pointer(size))
		if size.value==0:
			raise Exception("GetPrinterA PRINTER_INFO_2 failed for '%s'", self.printer_name)
		log("GetPrinter: PRINTER_INFO_2 size=%#x", size.value)
		self.info2 = msvcrt.malloc(size.value)
		if GetPrinterA(self.handle, 2, self.info2, size.value, pointer(size)):
			info = cast(self.info2, POINTER(PRINTER_INFO_2))
			log(" driver=%#s" % info[0].pDriverName)

		size = DWORD(0)
		GetPrinterA(self.handle, 8, None, 0, pointer(size))
		if size.value==0:
			raise Exception("GetPrinter: PRINTER_INFO_8 failed for '%s'" % self.printer_name)
		self.info8 = msvcrt.malloc(size.value)
		if GetPrinterA(self.handle, 8, self.info8, size.value, pointer(size)):
			info = cast(self.info8, POINTER(PRINTER_INFO_8))
			if info[0] and info[0].pDevMode:
				devmode = cast(info[0].pDevMode, POINTER(DEVMODE))
				log("PRINTER_INFO_8: devmode=%s" % devmode)
				log("PRINTER_INFO_8: device name='%s'" % devmode[0].dmDeviceName)

		size = DWORD(0)
		GetPrinterA(self.handle, 9, None, 0, pointer(size))
		if size.value==0:
			raise Exception("GetPrinter: PRINTER_INFO_9 failed for '%s'" % self.printer_name)
		log("GetPrinter: PRINTER_INFO_9 size=%#x" % size.value)
		self.info9 = msvcrt.malloc(size.value)
		if GetPrinterA(self.handle, 9, self.info9, size.value, pointer(size)):
			info = cast(self.info9, POINTER(PRINTER_INFO_9))
			if info[0] and info[0].pDevMode:
				devmode = cast(info[0].pDevMode, POINTER(DEVMODE))
				log("PRINTER_INFO_9: devmode=%s" % devmode)
				log("PRINTER_INFO_9: device name=%s" % devmode[0].dmDeviceName)
		assert devmode, "failed to query a DEVMODE for %s" % self.printer_name
		self.hdc = CreateDCA(None, name, None, devmode)
		log("CreateDCA(..)=%#x", self.hdc)
		return self.hdc
class IServiceProvider(comtypes.IUnknown):
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = IID_IServiceProvider
    _methods_ = [
        COMMETHOD(
            [helpstring('Method QueryService'), 'local', 'in'],
            HRESULT,
            'QueryService',
            (['in'], REFGUID, 'guidService'),
            (['in'], REFIID, 'riid'),
            (['out'], POINTER(LPVOID), 'ppvObject'),
        ),
    ]
Exemple #25
0
class SYSTEM_INFO(Structure):
    _fields_ = [
        ('wProcessorArchitecture', WORD),
        ('wReserved', WORD),
        ('dwPageSize', DWORD),
        ('lpMinimumApplicationAddress', LPVOID),
        ('lpMaximumApplicationAddress', LPVOID),
        ('dwActiveProcessorMask', POINTER(DWORD)),
        ('dwNumberOfProcessors', DWORD),
        ('dwProcessorType', DWORD),
        ('dwAllocationGranularity', DWORD),
        ('wProcessorLevel', WORD),
        ('wProcessorRevision', WORD),
    ]
class IObjectArray(comtypes.IUnknown):
    """
    Unknown Object Array
    """
    _case_insensitive_ = True
    _idlflags_ = []
    _iid_ = None

    _methods_ = [
        COMMETHOD(
            [helpstring('Method GetCount')],
            HRESULT,
            'GetCount',
            (['out'], POINTER(UINT), 'pcObjects'),
        ),
        COMMETHOD(
            [helpstring('Method GetAt')],
            HRESULT,
            'GetAt',
            (['in'], UINT, 'uiIndex'),
            (['in'], REFIID, 'riid'),
            (['out', 'iid_is'], POINTER(LPVOID), 'ppv'),
        ),
    ]
 class PROCESSENTRY32(ctypes.Structure):
     from ctypes.wintypes import DWORD, POINTER, ULONG, LONG, MAX_PATH, c_char
     _fields_ = (
         (
             'dwSize',
             DWORD,
         ),
         (
             'cntUsage',
             DWORD,
         ),
         (
             'th32ProcessID',
             DWORD,
         ),
         (
             'th32DefaultHeapID',
             POINTER(ULONG),
         ),
         (
             'th32ModuleID',
             DWORD,
         ),
         (
             'cntThreads',
             DWORD,
         ),
         (
             'th32ParentProcessID',
             DWORD,
         ),
         (
             'pcPriClassBase',
             LONG,
         ),
         (
             'dwFlags',
             DWORD,
         ),
         (
             'szExeFile',
             c_char * MAX_PATH,
         ),
     )
Exemple #28
0
    class TOUCHINPUT(Structure):
        _fields_ = [('x', LONG), ('y', LONG), ('pSource', HANDLE),
                    ('id', DWORD), ('flags', DWORD), ('mask', DWORD),
                    ('time', DWORD), ('extraInfo', POINTER(ULONG)),
                    ('size_x', DWORD), ('size_y', DWORD)]

        def size(self):
            return (self.size_x, self.size_y)

        def screen_x(self):
            return self.x / 100.0

        def screen_y(self):
            return self.y / 100.0

        def _event_type(self):
            if self.flags & TOUCHEVENTF_MOVE:
                return 'update'
            if self.flags & TOUCHEVENTF_DOWN:
                return 'begin'
            if self.flags & TOUCHEVENTF_UP:
                return 'end'

        event_type = property(_event_type)
Exemple #29
0
        w = property(lambda self: self.right - self.left)
        h = property(lambda self: self.bottom - self.top)

    try:
        windll.user32.SetWindowLongPtrW.restype = WNDPROC
        windll.user32.SetWindowLongPtrW.argtypes = [HANDLE, c_int, WNDPROC]
        SetWindowLong_wrapper = windll.user32.SetWindowLongPtrW
    except AttributeError:
        windll.user32.SetWindowLongW.restype = WNDPROC
        windll.user32.SetWindowLongW.argtypes = [HANDLE, c_int, WNDPROC]
        SetWindowLong_wrapper = windll.user32.SetWindowLongW

    windll.user32.GetMessageExtraInfo.restype = LPARAM
    windll.user32.GetMessageExtraInfo.argtypes = []
    windll.user32.GetClientRect.restype = BOOL
    windll.user32.GetClientRect.argtypes = [HANDLE, POINTER(RECT)]
    windll.user32.GetWindowRect.restype = BOOL
    windll.user32.GetWindowRect.argtypes = [HANDLE, POINTER(RECT)]
    windll.user32.CallWindowProcW.restype = LRESULT
    windll.user32.CallWindowProcW.argtypes = [
        WNDPROC, HANDLE, UINT, WPARAM, LPARAM
    ]
    windll.user32.GetActiveWindow.restype = HANDLE
    windll.user32.GetActiveWindow.argtypes = []
    windll.user32.RegisterTouchWindow.restype = BOOL
    windll.user32.RegisterTouchWindow.argtypes = [HANDLE, ULONG]
    windll.user32.UnregisterTouchWindow.restype = BOOL
    windll.user32.UnregisterTouchWindow.argtypes = [HANDLE]
    windll.user32.GetTouchInputInfo.restype = BOOL
    windll.user32.GetTouchInputInfo.argtypes = [
        HANDLE, UINT, POINTER(TOUCHINPUT), c_int
Exemple #30
0
 def ISO_6C_Inventory_Cycle(self, DevID, tags):
     ''' 循环盘点操作 '''
     prototype = CFUNCTYPE(UINT, c_char_p, POINTER(AllTagInfo))
     params = (1, 'DevID'), (1, 'tags')
     func = prototype(('ISO_6C_Inventory_Cycle', self.__dll), params)
     return func(DevID=DevID, tags=byref(tags))