Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
- #AutoIt3Wrapper_Outfile_x64=..\Logbook Email Script.Exe
- #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
- #include <Date.au3>
- #include <Misc.au3>
- #include <MsgBoxConstants.au3>
- Opt("TrayMenuMode", 3)
- $sendEmailTrayBtn = TrayCreateItem("Send Email")
- $exitTrayBtn = TrayCreateItem("Exit Script")
- $emailNum = 1
- $emailMaxNum = 3
- $prevWinHandle = ""
- Global $prevMousePos
- func showOriginWin()
- WinSetState($prevWinHandle, "", @SW_MAXIMIZE)
- WinActivate($prevWinHandle)
- EndFunc
- func resetMousePos()
- MouseMove($prevMousePos[0], $prevMousePos[1])
- EndFunc
- Func sendEmail()
- Local $coordNewEmailBtn[2] = [24, 104]
- Local $coordSendBtn[2] = [29, 227]
- local $coordHomeTabBtn[2] = [92, 47]
- $fpath = 'C:\Users\GeraciR\Desktop\Logbook.docx'
- $toEmail = "ricci07@hotmail.co.uk"
- $subject = "Logbook - " & _Now() & " (" & $emailNum & "/" & $emailMaxNum & ")"
- ;Before even bothering with running the script, lets check that we have all the files we need
- If Not FileExists($fpath) Then
- MsgBox($MB_TOPMOST, "", "The logbook file doesn't exist at " & @CRLF & $fpath & @CRLF & "Script will cease!")
- Exit
- EndIf
- $winHandle = WinGetHandle("[CLASS:rctrl_renwnd32]")
- $prevWinHandle = WinGetHandle("[ACTIVE]") ;to go back to original window after doing the email task
- $prevMousePos = MouseGetPos()
- If @error Then ;will be non-zero if error
- MsgBox($MB_TOPMOST, "", "Open your email first, then rerun script")
- ;Exit
- EndIf
- WinSetState($winHandle, "", @SW_MAXIMIZE)
- WinActivate($winHandle)
- _ClipPutFile($fpath)
- If @error Then ; will be non-zero if it screwed up
- MsgBox($MB_TOPMOST, "", "Error setting clipboard" & @CRLF & "Error: " & @error)
- ;Exit
- EndIf
- Sleep(1000)
- MouseClick("LEFT", $coordHomeTabBtn[0], $coordHomeTabBtn[1])
- sleep(500)
- MouseClick("LEFT", $coordNewEmailBtn[0], $coordNewEmailBtn[1])
- Sleep(1000)
- Send($toEmail)
- Send("{TAB 3}") ; tab to subject
- Send($subject)
- Send("{TAB}")
- Send("^a") ;SELECT ALL
- Send("{BACKSPACE}") ;Clear the body text
- Send("See file")
- Send("^v") ;PASTE
- MouseClick("LEFT", $coordSendBtn[0], $coordSendBtn[1])
- EndFunc ;==>sendEmail
- While 1
- switch TrayGetMsg() ;detect which tray buttons are clicked onto
- case $sendEmailTrayBtn
- sendEmail()
- showOriginWin()
- resetMousePos()
- case $exitTrayBtn
- Exit
- EndSwitch
- $day = _DateDayOfWeek(@WDAY)
- if $day == "Monday" or $day == "Tuesday" Or $day == "Wednesday" Or $day == "Thursday" then
- If _NowTime() = "09:00:00" or _NowTime() = "14:00:00" or _NowTime() = "16:45:00" Then
- MsgBox($MB_TOPMOST, "Mon-Thur", "Its time to send email of logbook")
- sendEmail()
- showOriginWin()
- resetMousePos()
- if $emailNum == $emailMaxNum then
- $emailNum = 1
- else
- $emailNum +=1
- endif
- EndIf
- elseif $day== "Friday" then
- If _NowTime() = "09:00:00" or _NowTime() = "11:00:00" or _NowTime() = "13:00:00" Then
- MsgBox($MB_TOPMOST, "Friday", "Its time to send email of logbook")
- sendEmail()
- showOriginWin()
- resetMousePos()
- if $emailNum == $emailMaxNum then
- $emailNum = 1
- else
- $emailNum +=1
- EndIf
- EndIf
- endif
- Sleep(100)
- WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement