當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。