本文整理汇总了Python中win32api.Sleep方法的典型用法代码示例。如果您正苦于以下问题:Python win32api.Sleep方法的具体用法?Python win32api.Sleep怎么用?Python win32api.Sleep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32api
的用法示例。
在下文中一共展示了win32api.Sleep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ThreadedDemo
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def ThreadedDemo():
rect = win32ui.GetMainFrame().GetMDIClient().GetClientRect()
rect = rect[0], int(rect[3]*3/4), int(rect[2]/4), rect[3]
incr = rect[2]
for i in range(4):
if i==0:
f = FontFrame()
title = "Not threaded"
else:
f = ThreadedFontFrame()
title = "Threaded GUI Demo"
f.Create(title, rect)
rect = rect[0] + incr, rect[1], rect[2]+incr, rect[3]
# Givem a chance to start
win32api.Sleep(100)
win32ui.PumpWaitingMessages()
示例2: TestWord8
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def TestWord8(word):
word.Visible = 1
doc = word.Documents.Add()
wrange = doc.Range()
for i in range(10):
wrange.InsertAfter("Hello from Python %d\n" % i)
paras = doc.Paragraphs
for i in range(len(paras)):
p = paras[i]()
p.Font.ColorIndex = i+1
p.Font.Size = 12 + (4 * i)
# XXX - note that
# for para in paras:
# para().Font...
# doesnt seem to work - no error, just doesnt work
# Should check if it works for VB!
doc.Close(SaveChanges = 0)
word.Quit()
win32api.Sleep(1000) # Wait for word to close, else we
# may get OA error.
示例3: _scan_for_self
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def _scan_for_self(self):
win32api.Sleep(2000) # sleep to give time for process to be seen in system table.
basename = self.cmdline.split()[0]
pids = win32process.EnumProcesses()
if not pids:
UserLog.warn("WindowsProcess", "no pids", pids)
for pid in pids:
try:
handle = win32api.OpenProcess(
win32con.PROCESS_QUERY_INFORMATION | win32con.PROCESS_VM_READ,
pywintypes.FALSE, pid)
except pywintypes.error, err:
UserLog.warn("WindowsProcess", str(err))
continue
try:
modlist = win32process.EnumProcessModules(handle)
except pywintypes.error,err:
UserLog.warn("WindowsProcess",str(err))
continue
示例4: TestWord8
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def TestWord8(word):
word.Visible = 1
doc = word.Documents.Add()
wrange = doc.Range()
for i in range(10):
wrange.InsertAfter("Hello from Python %d\n" % i)
paras = doc.Paragraphs
for i in range(len(paras)):
paras[i]().Font.ColorIndex = i+1
paras[i]().Font.Size = 12 + (4 * i)
# XXX - note that
# for para in paras:
# para().Font...
# doesnt seem to work - no error, just doesnt work
# Should check if it works for VB!
doc.Close(SaveChanges = 0)
word.Quit()
win32api.Sleep(1000) # Wait for word to close, else we
# may get OA error.
示例5: DoDemoWork
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def DoDemoWork():
print "Doing the work..."
print "About to connect"
win32api.MessageBeep(win32con.MB_ICONASTERISK)
win32api.Sleep(2000)
print "Doing something else..."
win32api.MessageBeep(win32con.MB_ICONEXCLAMATION)
win32api.Sleep(2000)
print "More work."
win32api.MessageBeep(win32con.MB_ICONHAND)
win32api.Sleep(2000)
print "The last bit."
win32api.MessageBeep(win32con.MB_OK)
win32api.Sleep(2000)
示例6: Test
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def Test():
num=1
while num<1000:
print 'Hello there no ' + str(num)
win32api.Sleep(50)
num = num + 1
示例7: demo
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def demo():
d = StatusProgressDialog("A Demo", "Doing something...")
import win32api
for i in range(100):
if i == 50:
d.SetText("Getting there...")
if i==90:
d.SetText("Nearly done...")
win32api.Sleep(20)
d.Tick()
d.Close()
示例8: thread_demo
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def thread_demo():
d = ThreadedStatusProgressDialog("A threaded demo", "Doing something")
import win32api
for i in range(100):
if i == 50:
d.SetText("Getting there...")
if i==90:
d.SetText("Nearly done...")
win32api.Sleep(20)
d.Tick()
d.Close()
示例9: test
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def test():
w = WindowOutput(queueing=flags.WQ_IDLE)
w.write("First bit of text\n")
import _thread
for i in range(5):
w.write("Hello from the main thread\n")
_thread.start_new(thread_test, (w,))
for i in range(2):
w.write("Hello from the main thread\n")
win32api.Sleep(50)
return w
示例10: kill
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def kill(self, gracePeriod=5000):
"""
Kill process. Try for an orderly shutdown via WM_CLOSE. If
still running after gracePeriod (5 sec. default), terminate.
"""
win32gui.EnumWindows(self.__close__, 0)
if self.wait(gracePeriod) != win32event.WAIT_OBJECT_0:
win32process.TerminateProcess(self.hProcess, 0)
win32api.Sleep(100) # wait for resources to be released
示例11: CallPipe
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def CallPipe(fn, args):
ret = None
retryCount = 0
while retryCount < 8: # Keep looping until user cancels.
retryCount = retryCount + 1
try:
return fn(*args)
except win32api.error, exc:
if exc.winerror==winerror.ERROR_PIPE_BUSY:
win32api.Sleep(5000)
continue
else:
raise
示例12: WaitForServiceStatus
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def WaitForServiceStatus(serviceName, status, waitSecs, machine=None):
"""Waits for the service to return the specified status. You
should have already requested the service to enter that state"""
for i in range(waitSecs*4):
now_status = QueryServiceStatus(serviceName, machine)[1]
if now_status == status:
break
win32api.Sleep(250)
else:
raise pywintypes.error(winerror.ERROR_SERVICE_REQUEST_TIMEOUT, "QueryServiceStatus", win32api.FormatMessage(winerror.ERROR_SERVICE_REQUEST_TIMEOUT)[:-2])
示例13: TestAll
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def TestAll():
try:
try:
iexplore = win32com.client.dynamic.Dispatch("InternetExplorer.Application")
TestExplorer(iexplore)
win32api.Sleep(1000)
iexplore = None
# Test IE events.
TestExplorerEvents()
# Give IE a chance to shutdown, else it can get upset on fast machines.
time.sleep(2)
# Note that the TextExplorerEvents will force makepy - hence
# this gencache is really no longer needed.
from win32com.client import gencache
gencache.EnsureModule("{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}", 0, 1, 1)
iexplore = win32com.client.Dispatch("InternetExplorer.Application")
TestExplorer(iexplore)
except pythoncom.com_error, exc:
if exc.hresult!=winerror.RPC_E_DISCONNECTED: # user closed the app!
raise
finally:
iexplore = None
示例14: sleep
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def sleep(self, sec):
win32api.Sleep(sec * 1000, True)
示例15: _input_left_mouse
# 需要导入模块: import win32api [as 别名]
# 或者: from win32api import Sleep [as 别名]
def _input_left_mouse(self, x, y):
left, top, right, bottom = self.rect
width, height = right - left, bottom - top
if x < 0 or x > width or y < 0 or y > height:
return
win32gui.SetForegroundWindow(self.hwnd)
pos = win32gui.GetCursorPos()
win32api.SetCursorPos((left+x, top+y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
win32api.Sleep(100) #ms
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
win32api.Sleep(100) #ms
# win32api.SetCursorPos(pos)