示例#1
0
    def __post_init__(self) -> None:
        """ The id field must be initialised at runtime.
		UIA will return the id to use when given the GUID.
		Any application can be first to register a custom property, subsequent applications
		will be given the same id.
		"""
        import NVDAHelper
        self.id = NVDAHelper.localLib.registerUIAProperty(
            byref(self.guid), self.programmaticName, self.uiaType)
示例#2
0
    def is_profile_scan_for_scan_num(self, scan_number):

        IsProfileScan = c_long()
        error = self.thermo_Library.IsProfileScanForScanNum(
            c_long(scan_number), byref(IsProfileScan))
        if error:
            raise IOError("IsProfileScanForScanNum error :", error)
        # print (IsProfileScan.value, bool(1))
        return bool(IsProfileScan.value)
示例#3
0
文件: __init__.py 项目: hss16/nvda
 def terminate(self):
     MTAThreadHandle = ctypes.wintypes.HANDLE(
         windll.kernel32.OpenThread(winKernel.SYNCHRONIZE, False,
                                    self.MTAThread.ident))
     self.MTAThreadQueue.put_nowait(None)
     #Wait for the MTA thread to die (while still message pumping)
     if windll.user32.MsgWaitForMultipleObjects(1, byref(MTAThreadHandle),
                                                False, 200, 0) != 0:
         log.debugWarning(
             "Timeout or error while waiting for UIAHandler MTA thread")
     windll.kernel32.CloseHandle(MTAThreadHandle)
     del self.MTAThread
示例#4
0
 def get_filter_for_scan_num(self, scan_number):
     """Returns the closest matching run time that corresponds to scan_number for the current
     controller. This function is only supported for MS device controllers.
     e.g.  ['FTMS', '-', 'p', 'NSI', 'Full', 'ms', '[200.00-1000.00]']
     """
     str_filter = BSTR(None)
     error = self.thermo_Library.GetFilterForScanNum(scan_number, byref(str_filter))
     if error:
         raise IOError(
             "scan %i GetFilterForScanNum error : %s" % (scan_number, str(error))
         )
     else:
         return str(str_filter.value).split()
示例#5
0
	def __post_init__(self) -> None:
		""" The id field must be initialised at runtime.
		A GUID uniquely identifies a custom annotation, but the UIA system relies on integer IDs.
		Any application (clients or providers) can register a custom annotation type, subsequent applications
		will get the same id for a given GUID.
		Registering custom annotations is only supported on Windows 11 and above.
		For any lesser version, id will be 0.

		"""
		if winVersion.getWinVer() >= winVersion.WIN11:
			import NVDAHelper
			self.id = NVDAHelper.localLib.registerUIAAnnotationType(
				byref(self.guid),
			)
		else:
			self.id = 0
示例#6
0
def SHGetKnownFolderPath(folderGuid: Union[FolderId, str],
                         dwFlags: int = 0,
                         hToken: Optional[int] = None) -> str:
    """Wrapper for `SHGetKnownFolderPath` which caches the results
	to avoid calling the win32 function unnecessarily."""
    if isinstance(folderGuid, FolderId):
        folderGuid = folderGuid.value
    guid = comtypes.GUID(folderGuid)

    pathPointer = ctypes.c_wchar_p()
    res = ctypes.windll.shell32.SHGetKnownFolderPath(comtypes.byref(guid),
                                                     dwFlags, hToken,
                                                     ctypes.byref(pathPointer))
    if res != 0:
        raise RuntimeError(
            f"SHGetKnownFolderPath failed with error code {res}")
    path = pathPointer.value
    ctypes.windll.ole32.CoTaskMemFree(pathPointer)
    return path
示例#7
0
 def call(self, fname, nOut, *args): # To Do: Properly handle complex return values 
     retval  = VARIANT()
     self.__handle.Feval(fname, nOut, byref(retval), *args)
     return retval.value
示例#8
0
文件: raw.py 项目: manor/mz
    def headers(self):
        '''Doesn't actually store the full headers. Generates the full scan_info
        list by looking at filter and header values. The results are cached.
        '''

        if not self._headers:
            self._headers = []

            first = c_long()
            last  = c_long()
            scan_time = c_double()

            mode_re = re.compile(r'\s+(ms(?:\d+)?)\s+')
            data_re = re.compile(r'\s+([cp])\s+')
            mz_re = re.compile(r'(\d+\.\d+)@')

            retval = self.source.GetFirstSpectrumNumber(byref(first))
            if retval:
                if debug:
                    print retval
                return None

            retval = self.source.GetLastSpectrumNumber(byref(last))
            if retval:
                if debug:
                    print retval
                return None

            for scan in xrange(first.value, last.value + 1):
                filter_str = comtypes.automation.BSTR(None)

                retval = self.source.GetFilterForScanNum(scan, byref(filter_str))
                if retval:
                    if debug:
                        print retval
                    return None

                retval = self.source.RTFromScanNum(scan, byref(scan_time))
                if retval:
                    if debug:
                        print retval
                    return None

                data_m = data_re.search(filter_str.value)
                mode_m = mode_re.search(filter_str.value)

                scan_mode = str(mode_m.group(1)).upper()
                if scan_mode == 'MS':
                    scan_mode = 'MS1'

                if scan_mode == 'MS1':
                    mz = 0.0
                else:
                    header_fields = comtypes.automation.VARIANT()
                    num_fields = c_long()
                    retval = self.source.GetTrailerExtraLabelsForScanNum(scan, header_fields, comtypes.byref(num_fields))
                    if retval:
                        if debug:
                            print retval
                        return None

                    if 'Monoisotopic M/Z:' in header_fields.value:
                        mz_value = comtypes.automation.VARIANT()
                        retval = self.source.GetTrailerExtraValueForScanNum(scan, u'Monoisotopic M/Z:', mz_value)
                        if retval:
                            if debug:
                                print retval
                            return None
                        mz = mz_value.value
                    if mz == 0.0:
                        mz = float(mz_re.search(filter_str.value).group(1))
                self._headers.append((scan_time.value, # scan time
                                      mz, # scan m/z from header, or 0 if MS1
                                      scan, # scan name == scan number
                                      scan_mode, # MS1 or MS2, referred to as 'scan type' in our API)
                                      str(data_m.group(1)).lower() if data_m else 'p')) # data mode, 'p' or 'c'
        return self._headers