0

I have to open a program named "EDI Tracker.exe" and browse for an excel file"867_CCM.xls" and press enter and wait for the program to process the excel file. The processing time may differ based upon size of the file. Then after the processing is finished a message box with title "Result" will pop up saying "Congratulations! No Failure found". As this message box appears I will print screen and email the screen shot in outlook along with the excel attachment. The point is this is my daily routine and I want to automate it. So I am using AHK. Below is my script so far

Run, open "C:\Program Files\EDI867 Tracer\EDITracker.exe"
sleep, 1500
MouseClick, left, 1299, 85
Send, "867_CCM.xls
Send {Enter}
Return

Now I want the script to wait until the message box appears and as soon as it appears I want to do print screen and email the screenshot and the excel file mentioned above as an attachment to specific people.

P.S: I always keep the excel file in my desktop.

1

1 Answer 1

1
SetTitleMatchMode, 2
WinWaitActive, Congratulations    ; match on a partial title is more readable
SendInput {PrintScreen}

; pseudo code... will need modified...
; Use IrfanView or other utility to save the clipboard to a file
; For IrfanView use /silent /clippaste /cmdexit options
filepath := "c:\yourpath\to\save\file\at\screenshot.jpg"
cmdToRun := "c:\program files (x86)IrfanView\i_view32.exe " . filePath . "<options>"
runwait, %cmdtoRun%

This should get your screenshot saved to disk.

For the remaining tasks to send an email with the attachments you may want to transition to a .vbs file that invokes Outlook, creates a new email and attaches the files you want to the email before sending. Look elsewhere for those examples. You would be able to run the .vbs file from your .ahk script using the run command once the screenshot has been captured.

1
  • I ran across this link on accident the other day, which may allow you to script everything for Outlook in AutoHotkey as well without having to use VBA or a .vbs file.
    – JJohnston2
    Oct 2, 2015 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .