本文整理汇总了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()
示例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
示例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!"
示例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
示例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)
示例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)
示例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()
示例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)
示例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
示例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)
示例11: iterate
# 需要导入模块: import pythoncom [as 别名]
# 或者: from pythoncom import PumpWaitingMessages [as 别名]
def iterate(self):
self._proxy.setBusy(False)
while 1:
pythoncom.PumpWaitingMessages()
yield
示例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)
示例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()
示例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.
示例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