I have got the below scrip and i want it to run every 30 minutes can someone point me in the right direction on how to do this.
I have searched for existing questions like this but don't seem to find any think that will work with my script but don't know if that's me being dumb.
My script goes to different positions on my screen clicks and then does a screen shot and then sends me the image to my gmail account.
import pyautogui
import time
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.text import MIMEText
from email import encoders
import os
time.sleep(5)
pyautogui.PAUSE = 1
pyautogui.moveTo(922,134)
pyautogui.click()
pyautogui.PAUSE = 1
pyautogui.moveTo(178,277)
pyautogui.click()
pyautogui.PAUSE = 1
pyautogui.moveTo(178,297)
pyautogui.click()
pyautogui.PAUSE = 1
pyautogui.moveTo(178,315)
pyautogui.click()
pyautogui.PAUSE = 1
pyautogui.screenshot('web.png')
pyautogui.PAUSE = 5
gmail_user = "user@gmail.com"
gmail_pwd = "password"
to = "user@gmail.com"
subject = "Report"
text = "Picture report"
attach = 'web.png'
msg = MIMEMultipart()
msg['From'] = gmail_user
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(text))
part = MIMEBase('application', 'octet-stream')
part.set_payload(open(attach, 'rb').read())
encoders.encode_base64(part)
part.add_header('Content-Disposition',
'attachment; filename="%s"' % os.path.basename(attach))
msg.attach(part)
mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(gmail_user, gmail_pwd)
mailServer.sendmail(gmail_user, to, msg.as_string())
# Should be mailServer.quit(), but that crashes...
mailServer.close()