Sign in to follow this  
Followers 0
jimfx

Inexplicable refusal of execution

6 posts in this topic

Hello,

I am using a combination of Excel VB and AutoIT for printing invoices from excel to a PDF file.

The invoice is being printed as follows: In excel a (VB) macro is being executed, which (among other things) will pre-select the PDF printer.

Then the AutoIT file is being executed via this command line in VB:

Dim Myapp

Myapp = Shell("C:\Autoit\printpdf.exe", 1)

The (autoit) printpdf.exe file contains following code:

Sleep (100)

$bak = ClipGet()

Sleep (100)

Opt("WinTitleMatchMode", 3)

WinActivate("Microsoft Excel - invoice")

sleep (100)

Send("^p")

WinWaitActive("Print")

Send("{TAB}{ENTER}")

Opt("WinTitleMatchMode", 2)

WinWaitActive("CIB pdf brewer","")

Send("i")

WinWaitActive("Save as","")

Send ($bak)

Opt("WinTitleMatchMode", 2)

WinWaitActive("Adobe Reader")

Etc.

Etc.

The problem: sometimes the Autoit code is not being executed, but it hangs. You have to go to the windows systray to exit autoit, and start over again. Where does it go wrong?

PS it usually happens when the computer has been idle for a while.

After the first unsuccesful execution, the other pdf-prints go without problem

Many thanks in advance

Jim

Share this post


Link to post
Share on other sites



@jos

a good suggestion..

I generallay use msgboxes to identify what stage its hanging at and why..


[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Thanks Jos,

I think I know the problem (but no solution)

When selecting the PDF-printer for the first time, the computer needs some time. I think there it goes wrong.

I could add a 4 or 5 seconds sleep, but is there a better way?

Share this post


Link to post
Share on other sites

Thanks Jos,

I think I know the problem (but no solution)

When selecting the PDF-printer for the first time, the computer needs some time. I think there it goes wrong.

I could add a 4 or 5 seconds sleep, but is there a better way?

Can't you do some WinWait() or "IsEnabled" check for a control using ControlCommand() ?

Normally something changes at the time the GUI is really available.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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
Sign in to follow this  
Followers 0