Jump to content

Please review and advise


Recommended Posts

Hi all

I've been learning AutoIT now for a week or so and have my 1st script almost complete and looking for advise to clean things up. This script is to automate very repetitive activities at my job. we create dozens upon dozens of contracts daily and mail just as many letter and email just as many PDF's of contracts. this script will save me from carpel tunnel syndrome for sure.

Please review the script to tell me where I can improve. I know its shabby.

p.s. I placed as many notes to explain the activities as I could think of, so this is the reason for the mass amount of notes.

; =============================================================================
; Title .........: Complete Proposal Automation v1.0
; Language ......: English
; Description ...: Automated Proposal Creation and Assymbly
; Author(s) .....: Mark
; =============================================================================
#include <Excel.au3>

; *****************************************************************************
; Create application object or connect to an already running Excel instance
; *****************************************************************************
Local $oExcel = _Excel_Open()

; *****************************************************************************
; print out 1 copy of cover sheet for mailing on plain paper
; *****************************************************************************
WinWait Microsoft Excel non-commercial use - AsphaltEstimating
_Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print 2 copies of contracts on contract paper for mailing
; *****************************************************************************
_Excel_Print($oExcel, "A1:M55", 2, "Xerox WorkCentre 7556 PS Contract Paper")
Sleep (500)

; *****************************************************************************
; print 1 copy of conttract for office on plain paper
; *****************************************************************************
_Excel_Print($oExcel, "A1:M55", 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print out 1 copy of numbers on plain paper
; *****************************************************************************
_Excel_Print($oExcel,$oExcel.Worksheets("Bid Number").Range("A1:H30"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print "Cover" to PDF Converter Professional 7.2
; *****************************************************************************
_Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "DocuCom PDF Driver")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")

; *****************************************************************************
; switch to Google Earth Pro which should be pre aligned and maxamized
; to take Google Earth Snapshot via PDF Converter Professional 7.2
; *****************************************************************************
WinActivate ("Google Earth Pro")
WinWaitActive ("Google Earth Pro")
WinSetState("Google Earth Pro", "", @SW_MAXIMIZE)

; *****************************************************************************
; activate SnagIt pre defined PDF hotkeys to capture diagram
; *****************************************************************************
send ("^+{F3}")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 1000)
WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)

; *****************************************************************************
; crop newly created PDF Converter Professional diagram and print 2 copies
; 1 for mailing & 1 for office copy
; ----following could be faster with UDF's if they exist?----
; *****************************************************************************
send ("^+ {END}")
Sleep (250)
send ("^+{C}")
Sleep (250)
send ("!{W}")
Sleep (250)
send ("!{C}")
Sleep (250)
send ("{ENTER}")
Sleep (250)
send ("^{END}")
MouseClick ("right",886, 534)
Sleep (500)
send ("p")
send ("!u")
send ("{ENTER}")
Sleep (1000)
MouseClick ("right",886, 534)
send ("p")
send ("!u")
send ("{ENTER}")
Sleep (1000)
send ("^s")
WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
; close PDF Converter Professional

; *****************************************************************************
; print out Contract page to PDF (PDF Converter Professional)
; *****************************************************************************
_Excel_Print($oExcel, "A1:M55", 1, "DocuCom PDF Driver")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinSetState (""AsphaltEstimating - PDF Converter Professional 7.2"", "", @SW_MAXIMIZE)
; *****************************************************************************
; insert Terms page into PDF Converter Professional and set to last page
; *****************************************************************************
send ("^+{I}")
Sleep (250)
; *****************************************************************************
; here we are selecting origin of inserted document, Desktop
; *****************************************************************************
MouseClick ("LEFT",734, 465)
; *****************************************************************************
; here we are selecting desktop contecnt document list
; *****************************************************************************
MouseClick ("LEFT",994, 465)
; *****************************************************************************
; here we are selecting last alphabetical document (z-terms) and inserting into
; PDF Converter Professional document currently opened
; *****************************************************************************
send ("{END}")
Sleep (250)
send ("{ENTER}")
Sleep (250)
send ("!{g}")
Sleep (250)
send ("{ENTER}")
Sleep (250)

; *****************************************************************************
; Now creating bookmarks for all pages correctly ordered in PDF Converter Professional
; *****************************************************************************
WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
Sleep (75)
; *****************************************************************************
; ensure 1st page is in front
; *****************************************************************************
send ("^{HOME}")
; *****************************************************************************
; initiate bookmark panel
; *****************************************************************************
Send ("^{b}")
Sleep (75)
; *****************************************************************************
; finalise created bookmark and start cleaning any existing bookmarks
; *****************************************************************************
send ("{ENTER}")
Sleep (75)
; *****************************************************************************
; now delete up to 15 bookmarks to ensure properly assigned once done
; *****************************************************************************
Send ("{Del 15}")
Sleep (75)
; *****************************************************************************
; ensure again page one is to begining by flipping back
; *****************************************************************************
send ("^{HOME}")
Sleep (75)
; *****************************************************************************
; now start creating real bookmarks
; *****************************************************************************
send ("^{b}")
Sleep (75)
send ("Cover")
Sleep (75)
send ("{ENTER}")
Sleep (75)
send ("^+{RIGHT}")
Sleep (75)
send ("^{b}")
Sleep (75)
send ("Diagram")
Sleep (75)
send ("{ENTER}")
Sleep (75)
send ("^+{RIGHT}")
Sleep (75)
send ("^{b}")
Sleep (75)
send ("Proposal")
Sleep (75)
send ("{ENTER}")
Sleep (75)
send ("^+{RIGHT}")
Sleep (75)
send ("^{b}")
Sleep (75)
send ("Terms")
Sleep (75)
send ("{ENTER}")
Sleep (75)
send ("^{HOME}")
Sleep (75)
send ("{DOWN 5}")
Sleep (75)
send ("{ENTER}")
Sleep (75)
; *****************************************************************************
; open Document Properties
; *****************************************************************************
send ("^{d}")
Sleep (75)
; *****************************************************************************
; remove Title & Author
; *****************************************************************************
send ("{TAB 3}")
Sleep (75)
send ("{BACKSPACE}")
Sleep (75)
send ("{TAB}")
Sleep (75)
send ("{BACKSPACE}")
Sleep (75)
send ("{TAB}")
Sleep (75)
send ("{BACKSPACE}")
Sleep (75)
send ("{TAB}")
Sleep (75)
send ("{BACKSPACE}")
Sleep (75)
send ("{TAB}")
Sleep (75)
send ("{BACKSPACE}")
Sleep (75)
; *****************************************************************************
; get back to top tabs
; *****************************************************************************
send ("{TAB 4}")
Sleep (75)
; *****************************************************************************
; move to tab 3
; *****************************************************************************
send ("{RIGHT 2}")
Sleep (75)
; *****************************************************************************
; set Display Type
; *****************************************************************************
send ("{TAB}")
Sleep (75)
send ("{HOME}")
Sleep (75)
send ("{DOWN}")
Sleep (75)
; *****************************************************************************
; set Page Layout
; *****************************************************************************
send ("{TAB}")
Sleep (75)
send ("{HOME}")
Sleep (75)
send ("{DOWN}")
Sleep (75)
; *****************************************************************************
; set Zoom Level
; *****************************************************************************
send ("{TAB}")
Sleep (75)
send ("{HOME}")
Sleep (75)
send ("{DOWN 3}")
Sleep (75)
; *****************************************************************************
; set Go to page
; *****************************************************************************
send ("{TAB}")
Sleep (75)
send (1)
Sleep (75)
send ("{ENTER}")
; *****************************************************************************
;place Highlighted bokmark as start page
; *****************************************************************************
send ("^{HOME}")
; *****************************************************************************
; now Optimize for email
; *****************************************************************************
send ("!{t}")
Sleep (250)
send ("{o}")
Sleep (2500)
send ("{ENTER}")
Sleep (1000)
; *****************************************************************************
; All done, now enter new file name and select save back to desktop area
; *****************************************************************************
send ("AsphaltEstimating")
send ("{TAB 8}")
send ("{HOME}")
send ("{DOWN}")
send ("{ENTER}")
send ("!{s}")
send ("{y}")

 

Link to comment
Share on other sites

1. Add error checking, example...

; *****************************************************************************
; Create application object or connect to an already running Excel instance
; *****************************************************************************
Local $oExcel = _Excel_Open()
If Not IsObj($oExcel) Then
    Exit MsgBox(0, "Error", "_Excel_Open()")
EndIf

 

2. After WinActivate, use WinWaitActive.

3. Try to replace Send with ControlSend, and MouseClick with ControlClick.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

Thank you for the guidance JohnOne. I really appreciate the help error proofing this. I have been testing it more and the  ControlSend  sounds like it would help guard against sending key strokes to a window that is currently not fully loaded? 

For example, Occasionally, after the script crops the PDF snapshot from Google Earth, it is bogged down, the script wants to keep going.....

; *****************************************************************************
; crop newly created PDF Converter Professional diagram and print 2 copies
; 1 for mailing & 1 for office copy
; ----following could be faster with UDF's if they exist?----
; *****************************************************************************
send ("^+ {END}")
Sleep (250)
send ("^+{C}")
Sleep (250)
send ("!{W}")
Sleep (250)
send ("!{C}")
Sleep (250)
send ("{ENTER}")
Sleep (250)
send ("^{END}")
; *****************************************************************************
; *****************************************************************************
; Variable PAUSE needed until window ready to initiate printing
; *****************************************************************************
; *****************************************************************************
MouseClick ("right",886, 534)
Sleep (1)
send ("p")
send ("!u")
send ("{ENTER}")
; *****************************************************************************
; *****************************************************************************
; Variable PAUSE needed until window ready to Continue printing of diagram
; *****************************************************************************
; *****************************************************************************
MouseClick ("right",886, 534)
send ("p")
send ("!u")
send ("{ENTER}")
; *****************************************************************************
; *****************************************************************************
; Variable PAUSE needed until window finished with last printing of diagram
; *****************************************************************************
; *****************************************************************************
send ("^s")
WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
; *****************************************************************************
; close PDF Converter Professional (this is required by program)

 

Link to comment
Share on other sites

  • Moderators

ControlSend won't necessarily guard against a window that does not exist, @qwiqshot; it will, however, prevent a mouseclick that isn't quite lined up (different resolutions) or a Send to a window that is not active (Windows don't have to be active with ControlSend or ControlClick).

If you are worried about a window being there before you begin, use WinWaitActive as J1 suggests or even just WinExists to check first.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Thank you much as well JLogan3o13 for replying.

I'm entirely new to AutoIT and the programing language world, but really having fun learning this all. Some stuff clicks, some not so much. The whole IF, Else, While Loop stuff has me scratching my head a bit, but I know, this is where I need to focus learning too. I will poke around more with these suggestions this weekend and maybe figure out the Loops to get turbo charged some.

Link to comment
Share on other sites

Hello again

I have changed over all the strings to the suggested ones and am now seeking guidance on the Error checking. Could someone provide me with either a reasonably beginner geared tutorial or an example or two, other then the one in lines 13 thru 17

There are only 3 programs involved here.

  1. Excel (All data originates here, Customer and Job details)
  2. Google Earth Pro (Visual Diagrams for PDF, made prior to Excel data entry, manually)
  3. PDF Converter Professional 7.2 (All data destination, besides paper copies)
; =============================================================================
; Title .........: Complete Proposal Automation v2-6.7.2016
; Language ......: English
; Description ...: Automated Proposal Creation and Assymbly
; Author(s) .....: Mark
; =============================================================================
#include <Excel.au3>

; *****************************************************************************
; Create application object or connect to an already running Excel instance
; *****************************************************************************
Local $oExcel = _Excel_Open()
If Not IsObj($oExcel) Then
    Exit MsgBox(0, "Error", "_Excel_Open()")
EndIf

; *****************************************************************************
; print out 1 copy of cover sheet for mailing on plain paper
; *****************************************************************************
_Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print 2 copies of contracts on contract paper for mailing
; *****************************************************************************
_Excel_Print($oExcel, "A1:M55", 2, "Xerox WorkCentre 7556 PS Contract Paper")
Sleep (500)

; *****************************************************************************
; print 1 copy of conttract for office on plain paper
; *****************************************************************************
_Excel_Print($oExcel, "A1:M55", 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print out 1 copy of numbers on plain paper
; *****************************************************************************
_Excel_Print($oExcel,$oExcel.Worksheets("Bid Number").Range("A1:H30"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
Sleep (500)

; *****************************************************************************
; print "Cover" to PDF Converter Professional 7.2
; *****************************************************************************
_Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "DocuCom PDF Driver")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
; Below line added 6_6_2016
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")

; *****************************************************************************
; switch to Google Earth Pro which should be pre aligned and maxamized
; to take Google Earth Snapshot via PDF Converter Professional 7.2
; *****************************************************************************
WinActivate ("Google Earth Pro")
WinWaitActive ("Google Earth Pro")
WinSetState("", "", @SW_MAXIMIZE)

; *****************************************************************************
; activate SnagIt pre defined PDF hotkeys to capture diagram
; *****************************************************************************
WinSetState("Google Earth Pro", "", @SW_MAXIMIZE)
send ("^+{F3}")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 10)

; *****************************************************************************
; crop newly created PDF Converter Professional diagram and print 2 copies
; 1 for mailing & 1 for office copy
; ----following could be faster with UDF's if they exist?----
; *****************************************************************************
WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+ {END}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{C}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{W}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{C}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{END}")
Sleep (250)
; print 1st diagram copy (current PDF page)
ControlClick ( "AsphaltEstimating - PDF Converter Professional 7.2", "", 59648 , "right" , 1 , 1026, 435 )
Sleep (500)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{p}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{u}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (1000)
; Print 2nd diagram copy (current PDF page)
ControlClick ( "AsphaltEstimating - PDF Converter Professional 7.2", "", 59648 , "right" , 1 , 1026, 435 )
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{p}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{u}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (1000)
; save work
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{s}")
WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
; close PDF Converter Professional

; *****************************************************************************
; print out Contract page to PDF (PDF Converter Professional)
; *****************************************************************************
Local $oExcel = _Excel_Open()
_Excel_Print($oExcel, "A1:M55", 1, "DocuCom PDF Driver")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")

; *****************************************************************************
; insert Terms page into PDF Converter Professional and set to last page
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")
Sleep (250)
; selecting origins of inserted document (Terms Page)
ControlClick ( "AsphaltEstimating - PDF Converter Professional 7.2", "FolderView", 1, "left", 1, 216, 16 )

; *****************************************************************************
; here we are selecting last alphabetical document (z-terms) and inserting into
; PDF Converter Professional document currently opened
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{END}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{g}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (250)

; *****************************************************************************
; Now creating bookmarks for all pages correctly ordered in PDF Converter Professional
; *****************************************************************************
WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
Sleep (75)

; *****************************************************************************
; ensure 1st page is in front
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
Sleep (75)

; *****************************************************************************
; initiate bookmark panel
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
Sleep (75)

; *****************************************************************************
; finalise created bookmark and start cleaning any existing bookmarks
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)

; *****************************************************************************
; now delete up to 15 bookmarks to ensure properly assigned once done
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{Del 15}")
Sleep (75)

; *****************************************************************************
; ensure again page one is to begining by flipping back
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
Sleep (75)

; *****************************************************************************
; now start creating real bookmarks
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Cover")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Diagram")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Proposal")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Terms")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{DOWN 5}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (75)

; *****************************************************************************
; open Document Properties
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{d}")
Sleep (75)

; *****************************************************************************
; remove Title & Author
; *****************************************************************************

ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB 3}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{BACKSPACE}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{BACKSPACE}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{BACKSPACE}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{BACKSPACE}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{BACKSPACE}")
Sleep (75)

; *****************************************************************************
; get back to top tabs
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB 4}")
Sleep (75)

; *****************************************************************************
; move to tab 3
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{RIGHT 2}")
Sleep (75)

; *****************************************************************************
; set PDF display type
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{HOME}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{DOWN}")
Sleep (75)

; *****************************************************************************
; set Page Layout
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{HOME}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{DOWN}")
Sleep (75)

; *****************************************************************************
; set PDF zoom Llvel
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{HOME}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{DOWN 3}")
Sleep (75)

; *****************************************************************************
; set initial PDF go to page
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB}")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "1")
Sleep (75)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")

; *****************************************************************************
;designate bookmark start page
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")

; *****************************************************************************
; now Optimize PDF for email
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "","!{t}")
Sleep (250)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{o}")
Sleep (2500)
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
Sleep (1000)

; *****************************************************************************
; All done, now enter new file name and select save location
; *****************************************************************************
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "AsphaltEstimating")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{TAB 8}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{HOME}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{DOWN}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{s}")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{y}")

; =============================================================================
; =============================================================================
; ----------------------CONFIRMED GOOD 6/7/2016 5:00pm-------------------------
; =============================================================================
; =============================================================================

 

Link to comment
Share on other sites

I thought I had the ControlClick () setup correctly but am unable to get it working. I've tried lots of combinations and cant seem to get it right. The program I have opened is "AsphaltEstimating - PDF Converter Professional 7.2" I have the script set to initiate inserting a page to the PDF, via Control+Shift+I (which works perfectly)

ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")

Now I want to click the *Desktop* Selection, then the *Contents* area, so I can insert another page into the PDF, from the desktop at the end of the list. I have to do it this was as it recalls the last location a file was accessed. In the screenshot attached here, you'll see a red dot. That is where my 1st target click should hit & is also where the Info tool was set for the displayed information, for the target window. but nothing happens.

 

Insert.png

 

 

Edited by qwiqshot
Link to comment
Share on other sites

Cant seem to figure it out. While in the PDF program, to insert a page, I hit Control+Shift+I. This initiates the "Open" window. I don't understand how to tell AutoIT at this point, how to select the file (z-Terms 2016.pdf) at this point, with

@desktopdir & "\z-Terms 2016.pdf"

I was sure that this would work :'(

WinActivate ("AsphaltEstimating - PDF Converter Professional")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")
FileOpen (@DesktopDir & "\z-Terms 2016.pdf")

 

Edited by qwiqshot
Link to comment
Share on other sites

FileOpen actually opens the file for writing, but you're wanting to interact with the screen to open the file, right?  If so, you would want to use Send to send the text of the file path to your File Open dialog box.

Link to comment
Share on other sites

I tried that as (see below), it just fills the file name box with the below data

WinActivate ("AsphaltEstimating - PDF Converter Professional")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")

Send (@DesktopDir & "\z-Terms 2016.pdf")

and MuffinMan, I am not wanting to open it, I am wanting to Insert the document into a PDF. So essentially, go to desktop, select the file, hit enter.

Edited by qwiqshot
Link to comment
Share on other sites

Could I have some assistance please?

I have a program that I cannot ControlClick. I have read that some programs or portions of them, resist clicking. PDF Converter Professional appears to have windows that fall in this category. When I do a Control+Shift+I (To insert into the PDF) it opens a window to select said document to insert. This is the window that I am having dificulties with.

I am new, so I may just be typing things wrong. I have tried so many variations that I now confused and possibly turning circles. The details for the issue are in post #7 above. Please help.

Link to comment
Share on other sites

Tonight I finally resolved the ControlClick issue after installing WinID. For some reason the data Au3Info displays had different data then it usually had. I'm posotive i've used this line before.

ControlClick ("Open", "", 1184, "left", 1, 43, 80)

The data that changed was

ControlClick ("Open", "", NULLDATA, "left", 1, 43, 80)

Obviously NULLDATA was not displayed, just need to place somethiing there for you to see. Has it ever been reported that having WinID running along side Au3Info helped?

Link to comment
Share on other sites

On 3/6/2016 at 3:38 AM, qwiqshot said:

AutoIT

Its "AutoIt", Capital "I" and a small "t" :D.

 

btw, FileOpen won't do any good, it only opens files for writing programmatically...

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

On 09/06/2016 at 9:32 PM, qwiqshot said:

I tried that as (see below), it just fills the file name box with the below data

WinActivate ("AsphaltEstimating - PDF Converter Professional")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")

Send (@DesktopDir & "\z-Terms 2016.pdf")

and MuffinMan, I am not wanting to open it, I am wanting to Insert the document into a PDF. So essentially, go to desktop, select the file, hit enter.

 

Quote

it just fills the file name box with the below data

 

WinActivate ("AsphaltEstimating - PDF Converter Professional")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")

Send (@DesktopDir & "\z-Terms 2016.pdf")

sleep(1000)
Send ("{ENTER}")
WinWaitClose("Open")

 

Edited by Synapsee
Link to comment
Share on other sites

Thank you Synapsee, this worked. I very much appreciate it.

WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")
Sleep (500)
Send (@DesktopDir & "\z-Terms 2016.pdf")

Thanks, I guess, TheDcoder. (<-----p.s. That should be TheDecoder, lmao)

Edited by qwiqshot
Link to comment
Share on other sites

Update

 

Ok. I have as much figured out here as I can figure out. Several bits of PDF Converter Professional will not accept ControlClick or ControlSend so I have tested them for a week and have had no issues but would prefer doing it right. If anyone has any insight into PDF Converter Professional and would be willing to point me in the right direction I would be grateful. Here is the results so far. Now I need to work on error checking and then a GUI to choose options prior to running like, how many diagrams need captured (and pause while aligning the next), how many different contracts need printed to PDF and/or paper (pause if need be etc). Please scrutinize so I can learn from my errors. The reason its broken into functions is I hope to eventually make it modular for a GUI.

 

; =============================================================================
; Title .........: Complete Proposal Automation v2-6.7.2016
; Language ......: English
; Description ...: Automated Proposal Creation and Assymbly
; Author(s) .....: Mark
; =============================================================================

#include <Excel.au3>
#include <MsgBoxConstants.au3>


PrintDocs()
Func PrintDocs()
      ; *****************************************************************************
      ; Create application object or connect to an already running Excel instance
      ; *****************************************************************************
      Local $oExcel = _Excel_Open()
      If Not IsObj($oExcel) Then
          Exit MsgBox(0, "Error", "_Excel_Open()")
      EndIf
      ; *****************************************************************************
      ; print out 1 copy of cover sheet for mailing on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (700)
      ; *****************************************************************************
      ; print 2 copies of contracts on contract paper for mailing
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 2, "Xerox WorkCentre 7556 PS Contract Paper")
      Sleep (700)
      ; *****************************************************************************
      ; print 1 copy of conttract for office on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel, "A1:M55", 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (700)
      ; *****************************************************************************
      ; print out 1 copy of numbers on plain paper
      ; *****************************************************************************
      _Excel_Print($oExcel,$oExcel.Worksheets("Bid Number").Range("A1:H30"), 1, "Xerox WorkCentre 7556 PS Plain Paper")
      Sleep (700)
EndFunc


PDFCover()
Func PDFCover()
   ; *****************************************************************************
   ; Create application object or connect to an already running Excel instance
   ; *****************************************************************************
   Local $oExcel = _Excel_Open()
   If Not IsObj($oExcel) Then
   Exit MsgBox(0, "Error", "_Excel_Open()")
   EndIf
   ; *****************************************************************************
   ; print "Cover" to PDF Converter Professional 7.2
   ; *****************************************************************************
   _Excel_Print($oExcel,$oExcel.Worksheets("Cover").Range("A1:K51"), 1, "DocuCom PDF Driver")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   ; Below line added 6_6_2016
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
EndFunc


GoogleEarth()
Func GoogleEarth()
   ; *****************************************************************************
   ; switch to Google Earth Pro which should be pre aligned and maxamized
   ; to take Google Earth Snapshot via PDF Converter Professional 7.2
   ; *****************************************************************************
   WinActivate ("Google Earth Pro")
   WinWait ("Google Earth Pro")
   WinWaitActive ("Google Earth Pro")
   WinSetState("", "", @SW_MAXIMIZE)
   Sleep (500)
    ; *****************************************************************************
   ; verify that  PDF pro is not open by closing it now
    ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ; *****************************************************************************
   ; activate SnagIt pre defined PDF hotkeys to capture diagram
   ; *****************************************************************************
   WinSetState("Google Earth Pro", "", @SW_MAXIMIZE)
   send ("^+{F3}")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 10)
   ; *****************************************************************************
   ; crop newly created PDF Converter Professional diagram and print 2 copies
   ; 1 for mailing & 1 for office copy
   ; *****************************************************************************
   WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+ {END}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{C}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{W}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!{C}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{END}")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (500)
EndFunc


PrintDiagrams()
Func PrintDiagrams()
   ; *****************************************************************************
   ; -------------------print 1st diagram copy (current PDF page)-----------------
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^p")
   Sleep (500)
   ControlSend ("Print", "Print Range", "", "!u")
   Sleep (250)
   ControlSend ("Print", "Print Range", "", "{ENTER}")
   Sleep (500)
   ; *****************************************************************************
   ; Print 2nd diagram copy (current PDF page)
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^p")
   Sleep (500)
   ControlSend ("Print", "Print Range", "", "!u")
   Sleep (250)
   ControlSend ("Print", "Print Range", "", "{ENTER}")
   Sleep (250)
   ; *****************************************************************************
   ; save work and exit
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{s}")
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
EndFunc


ContractPDF()
Func ContractPDF()
   ; *****************************************************************************
   ; Create application object or connect to an already running Excel instance
   ; *****************************************************************************
   Local $oExcel = _Excel_Open()
   If Not IsObj($oExcel) Then
   Exit MsgBox(0, "Error", "_Excel_Open()")
   EndIf
   ; *****************************************************************************
   ; print out Contract page to PDF (PDF Converter Professional)
   ; *****************************************************************************
   _Excel_Print($oExcel, "A1:M55", 1, "DocuCom PDF Driver")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
EndFunc


Terms()
Func Terms()
   ; *****************************************************************************
   ; insert Terms & set to last page, then save
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   sleep (125)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{I}")
   Sleep (1000)
   ; *****************************************************************************
   ; enters document location and file name
   ; *****************************************************************************
   Send (@DesktopDir & "\z-Terms 2016.pdf")
   Sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "!g")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   sleep (250)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   sleep (250)
EndFunc


Bookmarks()
Func Bookmarks()
   ; *****************************************************************************
   ; Now creating bookmarks for all pages correctly ordered in PDF Converter Professional
   ; *****************************************************************************
   WinActivate ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitActive ("AsphaltEstimating - PDF Converter Professional 7.2", "", 5)
   WinSetState("AsphaltEstimating - PDF Converter Professional 7.2", "", @SW_MAXIMIZE)
   Sleep (75)
   ; *****************************************************************************
   ; ensure 1st page is in front
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ; *****************************************************************************
   ; initiate bookmark panel
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; finalise created bookmark and start cleaning any existing bookmarks
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; now delete remnant bookmarks to ensure properly assigned once done
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{Del 20}")
   Sleep (75)
   ; *****************************************************************************
   ; ensure again page one is to begining by flipping back
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ; *****************************************************************************
   ; now start creating real bookmarks
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Cover")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Diagram")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Proposal")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; proceed to next page to bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^+{RIGHT}")
   ; *****************************************************************************
   ; initiate bookmark process
   ; *****************************************************************************
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{b}")
   Sleep (75)
   ; *****************************************************************************
   ; enter bookmark name & confirm
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "Terms")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ; *****************************************************************************
   ; go to 1st bookmark
   ; *****************************************************************************
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^{HOME}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{UP 5}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "{ENTER}")
   Sleep (75)
   ControlSend ("AsphaltEstimating - PDF Converter Professional 7.2", "", "", "^s")
   Sleep (250)
   WinClose ("AsphaltEstimating - PDF Converter Professional 7.2")
   WinWaitClose ("AsphaltEstimating - PDF Converter Professional 7.2", "", 500)
EndFunc

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...