当前位置: 首页>>代码示例>>Python>>正文


Python ctypes.c_bool方法代码示例

本文整理汇总了Python中ctypes.c_bool方法的典型用法代码示例。如果您正苦于以下问题:Python ctypes.c_bool方法的具体用法?Python ctypes.c_bool怎么用?Python ctypes.c_bool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ctypes的用法示例。


在下文中一共展示了ctypes.c_bool方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getWindowByTitle

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def getWindowByTitle(self, wildcard, order=0):
        """ Returns a handle for the first window that matches the provided "wildcard" regex """
        EnumWindowsProc = ctypes.WINFUNCTYPE(
            ctypes.c_bool,
            ctypes.POINTER(ctypes.c_int),
            ctypes.py_object)
        def callback(hwnd, context):
            if ctypes.windll.user32.IsWindowVisible(hwnd):
                length = ctypes.windll.user32.GetWindowTextLengthW(hwnd)
                buff = ctypes.create_unicode_buffer(length + 1)
                ctypes.windll.user32.GetWindowTextW(hwnd, buff, length + 1)
                if re.search(context["wildcard"], buff.value, flags=re.I) != None and not context["handle"]:
                    if context["order"] > 0:
                        context["order"] -= 1
                    else:
                        context["handle"] = hwnd
            return True
        data = {"wildcard": wildcard, "handle": None, "order": order}
        ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data))
        return data["handle"] 
开发者ID:glitchassassin,项目名称:lackey,代码行数:22,代码来源:PlatformManagerWindows.py

示例2: getWindowByPID

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def getWindowByPID(self, pid, order=0):
        """ Returns a handle for the first window that matches the provided PID """
        if pid <= 0:
            return None
        EnumWindowsProc = ctypes.WINFUNCTYPE(
            ctypes.c_bool,
            ctypes.POINTER(ctypes.c_int),
            ctypes.py_object)
        def callback(hwnd, context):
            if ctypes.windll.user32.IsWindowVisible(hwnd):
                pid = ctypes.c_ulong()
                ctypes.windll.user32.GetWindowThreadProcessId(hwnd, ctypes.byref(pid))
                if context["pid"] == int(pid.value) and not context["handle"]:
                    if context["order"] > 0:
                        context["order"] -= 1
                    else:
                        context["handle"] = hwnd
            return True
        data = {"pid": pid, "handle": None, "order": order}
        ctypes.windll.user32.EnumWindows(EnumWindowsProc(callback), ctypes.py_object(data))
        return data["handle"] 
开发者ID:glitchassassin,项目名称:lackey,代码行数:23,代码来源:PlatformManagerWindows.py

示例3: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def __init__(self, cfg):
        self.__is_use_can_port = cfg['use_can']

        # Data for store
        self.rx_counter_servo_unit = multiprocessing.Value(ctypes.c_int,0)
        self.rx_time_us_diff = multiprocessing.Value(ctypes.c_int,0)
        self.rx_button_y = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_button_g = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_button_r = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_actual_angle = multiprocessing.Value(ctypes.c_float,0.0)
        self.can_error_count_rx = multiprocessing.Value(ctypes.c_int,0)

        # Initialize process
        self.__m = multiprocessing.Process(target=self.__process_can, \
                                           args=(cfg['can_name'], \
                                                 cfg['can_bustype'], \
                                                 cfg['can_bitrate'], \
                                                 cfg['can_dbc_path'], \
                                                 cfg['can_rx_interval']))
        # Start process
        self.__m.start()

        return 
开发者ID:YanbaruRobotics,项目名称:PythonPilot,代码行数:25,代码来源:io_can.py

示例4: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def __init__(self, num_processes, max_queue_size, fn):
        """

        Parameters
        ----------
        num_processes: int
            Number of processes to spawn
        max_queue_size: int
            Maximum samples in the queue before processes wait
        fn: function
            function that generates samples, executed on separate processes.
        """
        self.queue = mp.Queue(maxsize=int(max_queue_size))
        self.alive = mp.Value(c_bool, False, lock=False)
        self.num_proc = num_processes
        self.proc = list()
        self.fn = fn 
开发者ID:mlperf,项目名称:training_results_v0.6,代码行数:19,代码来源:multiproc_data.py

示例5: process_is_wow64

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def process_is_wow64(handle=None):
	"""
	Determine whether the process associated with the handle is running
	in WOW64 or not.

	:param int handle: A handle to the process to check.
	:return: Whether the process is running in WOW64 or not.
	:rtype: bool
	"""
	if not hasattr(m_k32, 'IsWow64Process'):
		return False
	handle = (handle or -1)
	is_wow64 = ctypes.c_bool()
	if not m_k32.IsWow64Process(handle, ctypes.byref(is_wow64)):
		raise WindowsProcessError('Error: IsWow64Process', get_last_error=m_k32.GetLastError())
	return is_wow64.value 
开发者ID:zeroSteiner,项目名称:mayhem,代码行数:18,代码来源:windows.py

示例6: logi_led_pulse_single_key

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def logi_led_pulse_single_key(key_name, red_percentage_start, green_percentage_start, blue_percentage_start, ms_duration, is_infinite = False, red_percentage_end = 0, green_percentage_end = 0, blue_percentage_end = 0):
    """ pulses the lighting color of the combined RGB percentages over the specified millisecond duration for the specified key name. 
        the color will gradually change from the starting color to the ending color. if no ending color is specified, the ending color will be black.
        the effect will stop after one interval unless is_infinite is set to True. note that RGB ranges from 0-255, but this function ranges from 0-100.
        this function only applies to LOGI_DEVICETYPE_PERKEY_RGB devices. """
    if led_dll:
        key_name               = ctypes.c_int(key_name)
        red_percentage_start   = ctypes.c_int(red_percentage_start)
        green_percentage_start = ctypes.c_int(green_percentage_start)
        blue_percentage_start  = ctypes.c_int(blue_percentage_start)
        red_percentage_end     = ctypes.c_int(red_percentage_end)
        green_percentage_end   = ctypes.c_int(green_percentage_end)
        blue_percentage_end    = ctypes.c_int(blue_percentage_end)
        ms_duration            = ctypes.c_int(ms_duration)
        is_infinite            = ctypes.c_bool(is_infinite)
        return bool(led_dll.LogiLedPulseSingleKey(key_name, red_percentage_start, green_percentage_start, blue_percentage_start, red_percentage_end, green_percentage_end, blue_percentage_end, ms_duration, is_infinite))
    else:
        return False 
开发者ID:Logitech,项目名称:logiPy,代码行数:20,代码来源:logi_led.py

示例7: __SetDLLReturnTypes

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def __SetDLLReturnTypes(self):
        self.nnotesdll.NotesInitExtended.restype = ctypes.c_uint16
        self.nnotesdll.NotesTerm.restype = ctypes.c_uint16
        self.nnotesdll.NSFDbOpen.restype = ctypes.c_uint16
        self.nnotesdll.NSFDbClose.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteOpenExt.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteOpenByUNID.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteClose.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteCopy.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteGetInfo.restype = None
        self.nnotesdll.NSFNoteIsSignedOrSealed.restype = ctypes.c_bool
        self.nnotesdll.NSFNoteDecrypt.restype = ctypes.c_uint16
        self.nnotesdll.NSFItemDelete.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteHasMIMEPart.restype = ctypes.c_bool
        self.nnotesdll.NSFNoteHasMIME.restype = ctypes.c_bool
        self.nnotesdll.NSFNoteHasComposite.restype = ctypes.c_bool
        self.nnotesdll.MMCreateConvControls.restype = ctypes.c_uint16
        self.nnotesdll.MMDestroyConvControls.restype = ctypes.c_uint16
        self.nnotesdll.MMSetMessageContentEncoding.restype = None
        self.nnotesdll.MIMEConvertCDParts.restype = ctypes.c_uint16
        self.nnotesdll.MIMEConvertMIMEPartCC.restype = ctypes.c_uint16
        self.nnotesdll.NSFNoteUpdate.restype = ctypes.c_uint16 
开发者ID:adb014,项目名称:nsf2x,代码行数:24,代码来源:nsf2x.py

示例8: create

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def create(cls):
        """Singleton factory."""
        if not hasattr(cls, 'length_to_eps'):
            # Maps episode length to list of episodes
            cls.length_to_eps = {}
            # Set of episode indices already in the cache
            cls.ep_indices = set()
            # List of batches if popping batches
            cls.batches = []
            # If all episodes have been loaded into memory
            cls.load_complete = Value(ctypes.c_bool, False)
            # Lock to access batches
            cls.batches_lock = Lock()
            # Lock to access length_to_eps
            cls.cache_lock = Lock()
            # Lock for condition variables
            cls.fill_cache_lock = RLock()
            # Condition notifying Loader to add to cache
            cls.add_to_cache_cv = Condition(lock=cls.fill_cache_lock)
            # Condition notifying teacher that cache has episodes
            cls.cache_filled_cv = Condition(lock=cls.fill_cache_lock) 
开发者ID:natashamjaques,项目名称:neural_chat,代码行数:23,代码来源:pytorch_data_teacher.py

示例9: process_is_wow64

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def process_is_wow64(handle=None):
    """
    Determine whether the process associated with the handle is running
    in WOW64 or not.

    :param int handle: A handle to the process to check.
    :return: Whether the process is running in WOW64 or not.
    :rtype: bool
    """
    if not hasattr(ctypes.windll.kernel32, 'IsWow64Process'):
        return False
    if platform.architecture()[0] == '64bit':
        ctypes.windll.kernel32.IsWow64Process.argtypes = [ctypes.c_uint64, ctypes.POINTER(ctypes.c_bool)]
    handle = (handle or -1)
    is_wow64 = ctypes.c_bool()
    if not ctypes.windll.kernel32.IsWow64Process(handle, ctypes.byref(is_wow64)):
        raise WindowsProcessError('Error: IsWow64Process', get_last_error=ctypes.windll.kernel32.GetLastError())
    return is_wow64.value 
开发者ID:Josue87,项目名称:BoomER,代码行数:20,代码来源:windows.py

示例10: nextEventMatchingMask_untilDate_inMode_dequeue_

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def nextEventMatchingMask_untilDate_inMode_dequeue_(self, mask, date, mode, dequeue):
        if self.inLiveResize():
            # Call the idle() method while we're stuck in a live resize event.
            from pyglet import app
            if app.event_loop is not None:
                app.event_loop.idle()

        event = send_super(self, 'nextEventMatchingMask:untilDate:inMode:dequeue:',
                           mask, date, mode, dequeue,
                           superclass_name='NSWindow',
                           argtypes=[NSUInteger, c_void_p, c_void_p, c_bool])

        if event.value is None:
            return 0
        else:
            return event.value

    # Need this for set_size to not flash. 
开发者ID:pyglet,项目名称:pyglet,代码行数:20,代码来源:pyglet_window.py

示例11: eval

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def eval(self, js_str, timeout=0, max_memory=0):
        """ Eval the JavaScript string """

        if is_unicode(js_str):
            bytes_val = js_str.encode("utf8")
        else:
            bytes_val = js_str

        res = None
        self.lock.acquire()
        try:
            res = self.ext.mr_eval_context(self.ctx,
                                           bytes_val,
                                           len(bytes_val),
                                           ctypes.c_ulong(timeout),
                                           ctypes.c_size_t(max_memory),
                                           ctypes.c_bool(self.basic_types_only))

            if bool(res) is False:
                raise JSConversionException()
            return self._eval_return(res)
        finally:
            self.lock.release()
            if res is not None:
                self.free(res) 
开发者ID:sqreen,项目名称:PyMiniRacer,代码行数:27,代码来源:py_mini_racer.py

示例12: _load_data_imp

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def _load_data_imp(_cmd, _block_ptr):
    global _dragged_item_path
    handler = runtime.ObjCBlockPointer(_block_ptr,
                                       argtypes=[ctypes.c_void_p, ctypes.c_bool, ctypes.c_void_p])

    if _dragged_item_path:
        NSURL = ObjCClass('NSURL')
        url = NSURL.fileURLWithPath_isDirectory_(ns(_dragged_item_path), os.path.isdir(_dragged_item_path))

        _dragged_item_path = None
    else:
        url = None

    if not url:
        error = NSError.errorWithDomain_code_userInfo_('com.robertvojta.blackmamba', 1, None)
        handler(None, None, error)
    else:
        handler(url.ptr, False, None) 
开发者ID:zrzka,项目名称:blackmamba,代码行数:20,代码来源:drag_and_drop.py

示例13: __init__

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def __init__(self, modelpath, libptr, zpar_session_obj):
        super(Tagger, self).__init__()

        # save the zpar session object
        self._zpar_session_obj = zpar_session_obj

        # set up a logger
        self.logger = logging.getLogger(__name__)

        # get the library method that loads the tagger models
        self._load_tagger = libptr.load_tagger
        self._load_tagger.restype = c.c_int
        self._load_tagger.argtypes = [c.c_void_p, c.c_char_p]

        # get the library methods that tag sentences and files
        self._tag_sentence = libptr.tag_sentence
        self._tag_sentence.restype = c.c_char_p
        self._tag_sentence.argtypes = [c.c_void_p, c.c_char_p, c.c_bool]

        self._tag_file = libptr.tag_file
        self._tag_file.restype = None
        self._tag_file.argtypes = [c.c_void_p, c.c_char_p, c.c_char_p, c.c_bool]

        if self._load_tagger(self._zpar_session_obj, modelpath.encode('utf-8')):
            raise OSError('Cannot find tagger model at {}\n'.format(modelpath)) 
开发者ID:EducationalTestingService,项目名称:python-zpar,代码行数:27,代码来源:Tagger.py

示例14: transpose

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def transpose(self, conjugate=False):
        """
        Transpose the KHIVA Array.

        :param conjugate: Indicates if the transpose is conjugated or not.
        :return: The transposed KHIVA Array.
        """
        result = ctypes.c_void_p(0)
        error_code = ctypes.c_int(0)
        error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH)
        KhivaLibrary().c_khiva_library.khiva_transpose(ctypes.pointer(self.arr_reference),
                                                       ctypes.c_bool(
                                                           conjugate),
                                                       ctypes.pointer(result),
                                                       ctypes.pointer(
                                                           error_code),
                                                       error_message)
        if error_code.value != 0:
            raise Exception(str(error_message.value.decode()))

        return Array(array_reference=result) 
开发者ID:shapelets,项目名称:khiva-python,代码行数:23,代码来源:array.py

示例15: cross_covariance

# 需要导入模块: import ctypes [as 别名]
# 或者: from ctypes import c_bool [as 别名]
def cross_covariance(xss, yss, unbiased):
    """ Calculates the cross-covariance of the given time series.

    :param xss: A KHIVA array with time series.
    :param yss: A KHIVA Array with time series.
    :param unbiased: Determines whether it divides by n - lag (if true) or n (if false).
    :return: KHIVA array with the cross-covariance value for the given time series.
    """

    b = ctypes.c_void_p(0)
    error_code = ctypes.c_int(0)
    error_message = ctypes.create_string_buffer(KHIVA_ERROR_LENGTH)
    KhivaLibrary().c_khiva_library.cross_covariance(ctypes.pointer(xss.arr_reference),
                                                    ctypes.pointer(
                                                        yss.arr_reference),
                                                    ctypes.pointer(ctypes.c_bool(unbiased)), ctypes.pointer(b), ctypes.pointer(error_code), error_message)
    if error_code.value != 0:
        raise Exception(str(error_message.value.decode()))

    return Array(array_reference=b) 
开发者ID:shapelets,项目名称:khiva-python,代码行数:22,代码来源:features.py


注:本文中的ctypes.c_bool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。