Python pythoncom 模块,PumpWaitingMessages() 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用pythoncom.PumpWaitingMessages()

项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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!"
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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()
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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!"
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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!"
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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()
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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!")
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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()
项目:stock_trade    作者:yoonsungkim87    | 项目源码 | 文件源码
def login_process(demo = False):
    if demo:
        server_addr = "demo.ebestsec.co.kr"
        user_certificate_pass = None
    else:
        server_addr = "hts.ebestsec.co.kr"
        user_certificate_pass = ""

    server_port = 20001
    server_type = 0
    user_id = ""
    user_pass = ""

    inXASession = win32com.client.DispatchWithEvents("XA_Session.XASession", XASessionEvents)
    inXASession.ConnectServer(server_addr, server_port)
    inXASession.Login(user_id, user_pass, user_certificate_pass, server_type, 0)

    while XASessionEvents.logInState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()
项目:stock_trade    作者:yoonsungkim87    | 项目源码 | 文件源码
def get_top_trade_cost(field = 1, day = 0):
    time.sleep(1)
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t1463.res")
    inXAQuery.SetFieldData('t1463InBlock', 'gubun', 0, field)
    inXAQuery.SetFieldData('t1463InBlock', 'jnilgubun', 0, day)
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    nCount =inXAQuery.GetBlockCount('t1463OutBlock1')
    result = []
    for i in range(nCount):
        result.append(inXAQuery.GetFieldData('t1463OutBlock1', 'shcode', i))
    XAQueryEvents.queryState = 0
    return result
项目:stock_trade    作者:yoonsungkim87    | 项目源码 | 文件源码
def get_top_trade_volume(field = 1, day = 0):
    time.sleep(1)
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t1452.res")
    inXAQuery.SetFieldData('t1452InBlock', 'gubun', 0, field)
    inXAQuery.SetFieldData('t1452InBlock', 'jnilgubun', 0, day)
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    nCount =inXAQuery.GetBlockCount('t1452OutBlock1')
    result = []
    for i in range(nCount):
        result.append(inXAQuery.GetFieldData('t1452OutBlock1', 'shcode', i))
    XAQueryEvents.queryState = 0
    return result
项目:winspeech    作者:areebbeigh    | 项目源码 | 文件源码
def _ensure_event_thread():
    """
    Make sure the event thread is running, which checks the handlerqueue
    for new event handlers to create, and runs the message pump.
    """
    global _event_thread
    if not _event_thread:
        def loop():
            while _event_thread:
                pythoncom.PumpWaitingMessages()
                if _handlerqueue:
                    (context, listener, callback) = _handlerqueue.pop()
                    # Just creating a _ListenerCallback object makes events
                    # fire till listener loses reference to its grammar object
                    _ListenerCallback(context, listener, callback)
                time.sleep(.5)

        _event_thread = 1  # so loop doesn't terminate immediately
        _event_thread = _thread.start_new_thread(loop, ())
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
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)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
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)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
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)
项目:pyttsx3    作者:nateshmbhat    | 项目源码 | 文件源码
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)
项目:pyttsx3    作者:nateshmbhat    | 项目源码 | 文件源码
def iterate(self):
        self._proxy.setBusy(False)
        while 1:
            pythoncom.PumpWaitingMessages()
            yield
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
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)
项目:stock_trade    作者:yoonsungkim87    | 项目源码 | 文件源码
def get_server_time():
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t0167.res")
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    dt = inXAQuery.GetFieldData('t0167OutBlock', 'dt', 0)
    tt = inXAQuery.GetFieldData('t0167OutBlock', 'time', 0)
    XAQueryEvents.queryState = 0
    return dt, tt
项目:T2B-framework    作者:pielco11    | 项目源码 | 文件源码
def WindowsHOOKER(threadName, running):
    hookman.KeyDown = OnKeyboardEvent
    hookman.HookKeyboard()
    while runHook:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.1)
项目:T2B-framework    作者:pielco11    | 项目源码 | 文件源码
def WindowsHOOKER(threadName, running):
    hookman.KeyDown = OnKeyboardEvent
    hookman.HookKeyboard()
    while runHook:
        pythoncom.PumpWaitingMessages()
        time.sleep(0.1)
项目:PyUIA    作者:xiaoxiayu    | 项目源码 | 文件源码
def run(self):
        self.hm.MouseAll = self._action
        self.hm.HookMouse()
        while self.state:
            sleep(0.01)
            pythoncom.PumpWaitingMessages()
项目:PyUIA    作者:xiaoxiayu    | 项目源码 | 文件源码
def run(self):
        """Begin listening for keyboard input events."""
        self.state = True
        self.hm.KeyAll = self.handler
        self.hm.HookKeyboard()
        while self.state:
            time.sleep(0.01)
            pythoncom.PumpWaitingMessages()
项目:stock_trade    作者:yoonsungkim87    | 项目源码 | 文件源码
def stock_quotation(codes):
    number = len(codes)
    concat_list = ''.join(codes)
    inXAQuery = win32com.client.DispatchWithEvents("XA_DataSet.XAQuery", XAQueryEvents)
    inXAQuery.LoadFromResFile("C:\\eBest\\xingAPI\\Res\\t8407.res")
    inXAQuery.SetFieldData('t8407InBlock', 'nrec', 0, number)
    inXAQuery.SetFieldData('t8407InBlock', 'shcode', 0, concat_list)
    inXAQuery.Request(0)

    while XAQueryEvents.queryState == 0:
        time.sleep(0.01)
        pythoncom.PumpWaitingMessages()

    result0, result1 = [], []
    nCount =inXAQuery.GetBlockCount('t8407OutBlock1')
    for i in range(nCount):
        op01 = inXAQuery.GetFieldData('t8407OutBlock1', 'shcode', i)
        op02 = inXAQuery.GetFieldData('t8407OutBlock1', 'hname', i)
        op03 = inXAQuery.GetFieldData('t8407OutBlock1', 'price', i)
        op04 = inXAQuery.GetFieldData('t8407OutBlock1', 'sign', i)
        op05 = inXAQuery.GetFieldData('t8407OutBlock1', 'change', i)
        op06 = inXAQuery.GetFieldData('t8407OutBlock1', 'diff', i)
        op07 = inXAQuery.GetFieldData('t8407OutBlock1', 'volume', i)
        op08 = inXAQuery.GetFieldData('t8407OutBlock1', 'offerho', i)
        op09 = inXAQuery.GetFieldData('t8407OutBlock1', 'bidho', i)
        op10 = inXAQuery.GetFieldData('t8407OutBlock1', 'cvolume', i)
        op11 = inXAQuery.GetFieldData('t8407OutBlock1', 'chdegree', i)
        op12 = inXAQuery.GetFieldData('t8407OutBlock1', 'open', i)
        op13 = inXAQuery.GetFieldData('t8407OutBlock1', 'high', i)
        op14 = inXAQuery.GetFieldData('t8407OutBlock1', 'low', i)
        op15 = inXAQuery.GetFieldData('t8407OutBlock1', 'value', i)
        op16 = inXAQuery.GetFieldData('t8407OutBlock1', 'offerrem', i)
        op17 = inXAQuery.GetFieldData('t8407OutBlock1', 'bidrem', i)
        op18 = inXAQuery.GetFieldData('t8407OutBlock1', 'totofferrem', i)
        op19 = inXAQuery.GetFieldData('t8407OutBlock1', 'totbidrem', i)
        op20 = inXAQuery.GetFieldData('t8407OutBlock1', 'jnilclose', i)
        op21 = inXAQuery.GetFieldData('t8407OutBlock1', 'uplmtprice', i)
        op22 = inXAQuery.GetFieldData('t8407OutBlock1', 'dnlmtprice', i)
        result0.append([op01,op02])
        result1.append([
            op03,op04,op05,op06,op07,
            op08,op09,op10,op11,op12,
            op13,op14,op15,op16,op17,
            op18,op19,op20,op21,op22])
    XAQueryEvents.queryState = 0
    return result0, result1