Search code examples
pythonscreenshotdelay

trying to delay part of my program


Im trying to take a snapshot of the webpage i open but i need to delay the second part of the code so that the program has time to open the page

Here is the code

import os
import sys
import time
import Image
import ImageGrab


import webbrowser
webbrowser.open_new(input("URL: "))
#Need to delay here

SaveDirectory=r'C:\Documents and Settings\User\My Documents\My Pictures'
ImageEditorPath=r'C:\WINDOWS\system32\mspaint.exe'
img=ImageGrab.grab()
box = (100, 100, 400, 400)
region = img.crop(box)
saveas=os.path.join(SaveDirectory,'ScreenShot_'+'.png')
img.save(saveas)
editorstring='""%s" "%s"'% (ImageEditorPath,saveas) 
os.system(editorstring)

Solution

  • you can try to use time.sleep(seconds) to let your program delay for a while.