Cleaning up Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Cleaning up Script

Post by ConfusedatWork2 » 30 Nov 2021, 12:27

Im running into issues here... timing i think is the main culprit...not waiting for FOXIT to finish mainly.

If anyone could help out, maybe clean it up for me, im a basic user, and I appreciate the help from everyone.


Basically i have three things open, basically its just going back and forth and cycling through, printing settlements.
Excel - Copy cell data to paste in another program, move onto the next row to get ready for copy again.
Agrosoft - Program - Paste from Excel and Run program
FOXIT - PDF prints to FOXIT and use the same Paste from Excel for file name
FOXIT - Wait for PDF to print to screen
Repeat from first input box entry


Im getting an error on the bottom section where i want to try and wait for the PDF file is created. But don't know how to get my file name in there...
Winwait, % Settle.pdf - Foxit PDF Editor ahk_class classFoxitPhantom




Current Code

Code: Select all

InputBox, Setts, Settlements, Please Enter Number of settlements to process, 320, 240
if ErrorLevel 
{
Return
}
Else


Loop, % Setts
{

;; ------------EXCEL-----------------

WinActivate,   Settlements - Excel ahk_class XLMAIN
Sleep 1000
Send {f2}
Send {shift down}
Send {home}
Send {Shift up}
Sleep 50
Send ^c
Clipboard :="Settle"
Send {Enter}
Sleep 500

;; ----------AGROSOFT-------------

Winactivate,    Agrosoft-Production ahk_class FNWND3170
Sleep 500
Click 721 194 ;; Reprint One Settlement
Sleep 50
Send {shift down}{left 10}{shift up}
Send {delete}
Send {shift down}{Right 10}{shift up}
Send {delete}
Sleep 200

Send % Settle ;; Paste in Agrosoft
Sleep 250

Send {Ctrl Down}u
Send {Ctrl Up}

Sleep 1000

;; -------FOXIT----------

WinWait,  Print to PDF Document - Foxit PDF Editor Printer ahk_class #32770
Sleep 250
Send % Settle
Sleep 500


Send {Enter}
Sleep 2000

;; ------FOXIT----------

Winwait,   % Settle.pdf - Foxit PDF Editor ahk_class classFoxitPhantom


}

}
Return

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Cleaning up Script

Post by boiler » 30 Nov 2021, 14:03

To start with one issue, the following doesn’t make sense:

Code: Select all

Send ^c
Clipboard :="Settle"
There would be no reason to execute a copy command then immediately overwrite the clipboard contents with the literal string Settle. From your subsequent code, I am guessing that you actually mean to assign the clipboard contents to the variable named Settle. That would be the following:

Code: Select all

Send ^c
Settle := Clipboard
But to make it reliable, you should first clear the clipboard and wait for the contents to populate:

Code: Select all

Clipboard := ""
Send, ^c
ClipWait, 1
Settle := Clipboard

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Cleaning up Script

Post by boiler » 30 Nov 2021, 14:10

ConfusedatWork2 wrote: Im getting an error on the bottom section where i want to try and wait for the PDF file is created. But don't know how to get my file name in there...
Winwait, % Settle.pdf - Foxit PDF Editor ahk_class classFoxitPhantom
If you’re saying the variable Settle is the variable containing the file name of the pdf file less the extension which would need to be tacked on, and that becomes part of the window title, then this would be the syntax:

Code: Select all

Winwait, % Settle ".pdf - Foxit PDF Editor ahk_class classFoxitPhantom"

See the documentation on Expressions to learn more about using expression syntax.

ConfusedatWork2
Posts: 12
Joined: 18 Nov 2021, 16:02

Re: Cleaning up Script

Post by ConfusedatWork2 » 30 Nov 2021, 14:52

OH my... so much better...waiting for the programs to finish before moving on.. I appreciate your help!!!

Post Reply

Return to “Ask for Help (v1)”