Python win32api.Sleep() Examples
The following are 17
code examples of win32api.Sleep().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
win32api
, or try the search function
.
Example #1
Source File: threadedgui.py From ironpython2 with Apache License 2.0 | 6 votes |
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()
Example #2
Source File: testMSOffice.py From ConTroll_Remote_Access_Trojan with Apache License 2.0 | 6 votes |
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.
Example #3
Source File: testMSOffice.py From ironpython2 with Apache License 2.0 | 6 votes |
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.
Example #4
Source File: Backdoor-ing Legitmate Windows Service.py From Python-for-Offensive-PenTest with MIT License | 5 votes |
def sleep(self, sec): # if the service manager singal was pause - then we sleep for an amount of seconds win32api.Sleep(sec*1000, True)
Example #5
Source File: basictimerapp.py From ironpython2 with Apache License 2.0 | 5 votes |
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)
Example #6
Source File: Create a New Admin account.py From Python-for-Offensive-PenTest with MIT License | 5 votes |
def sleep(self, sec): win32api.Sleep(sec*1000, True)
Example #7
Source File: windows.py From ATX with Apache License 2.0 | 5 votes |
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)
Example #8
Source File: platform_windows.py From scalyr-agent-2 with Apache License 2.0 | 5 votes |
def sleep(self, sec): win32api.Sleep(sec * 1000, True)
Example #9
Source File: WindowsServer.py From pycopia with Apache License 2.0 | 5 votes |
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
Example #10
Source File: testExplorer.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #11
Source File: win32serviceutil.py From ironpython2 with Apache License 2.0 | 5 votes |
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])
Example #12
Source File: pipeTestServiceClient.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #13
Source File: winprocess.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #14
Source File: winout.py From ironpython2 with Apache License 2.0 | 5 votes |
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
Example #15
Source File: status.py From ironpython2 with Apache License 2.0 | 5 votes |
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()
Example #16
Source File: status.py From ironpython2 with Apache License 2.0 | 5 votes |
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()
Example #17
Source File: cmdserver.py From ironpython2 with Apache License 2.0 | 5 votes |
def Test(): num=1 while num<1000: print 'Hello there no ' + str(num) win32api.Sleep(50) num = num + 1