Jump to content
Sign in to follow this  
simonwar

Script Pausing

Recommended Posts

simonwar

Hi,

I have a script that initiates a "Print to Adobe, Acrobat", but when it does it pauses my script and does not complete the script routine?

This is my code

$i = 0
$repeats = InputBox("Repeats", "How many loops?", "")
While ($i < $repeats)
    _WinWaitActivate("Catalog - Orders", "")
    MouseClick("left", 301, 13, 1)
    MouseClick("left", 70, 136, 1)
    MouseClick("right", 70, 136, 1)
    Sleep(500)
    Send("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
    _WinWaitActivate("Mail", "")
    Sleep(500)
    Send("{TAB}{TAB}{HOME}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTDOWN}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{SHIFTUP}{CTRLDOWN}c{CTRLUP}{ESC}")
    _WinWaitActivate("Catalog - Orders", "")
    Send("{ALTDOWN}ts{ALTUP}")
    _WinWaitActivate("Select Print Destination", "")
    Sleep(100)
    Send("{ALTDOWN}p{ALTUP}")
    _WinWaitActivate("Save PDF File As", "")
    Sleep(100)
    Send("{CTRLDOWN}v{CTRLUP}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{LEFT}{BACKSPACE}{BACKSPACE}{ENTER}")
    _WinWaitActivate("esafetysigns.co.uk Order FB26DG10000520.pdf - Adobe Acrobat Pro", "")
    Sleep(9000)
    Send("{CTRLDOWN}q")
    $i = ($i + 1)
WEnd

I am using SLEEP to slow AutoIt down to allow the program its working with to "catch up", however the final SLEEP, Sleep(9000), doesn't finish?

The rest of the scipt is simply mouse moves around a screen to grab, COPY and PASTE, the relevant filenames required to SAVE AS.

The SAVE AS works fine, Acrobat opens, but I cannot close Acrobat using Send("{CTRLDOWN}q"), and when I check the Script status in the task bar, it indicates Script Paused?

Any ideas?

Thanks, Simon.

P.S. I have tried many different length SLEEPS at the end and none of them work.

Share this post


Link to post
Share on other sites
wakillon

_WinWaitActivate ? A new function ? Posted Image

And simplify your Send : {RIGHT 41} instead of "RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}"

Same for DOWN, LEFT etc...

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
simonwar

OK, done the mods, nice one.

I think whats happening is this line is not always going to be the same:

_WinWaitActivate("esafetysigns.co.uk Order FB26DG10000520.pdf - Adobe Acrobat Pro", "")

as different files to SAVE AS could be esafetysigns.co.uk Order AB15CD10000521.pdf and so on 522, 523, etc

How do I close Adobe Acrobat Pro irresective of the file thats open in it?

I tried

_WinWaitActivate("Adobe Acrobat Pro", "")
Send("{CTRLDOWN}q")

but, didn't work?

Thanks, Simon.

Share this post


Link to post
Share on other sites
wakillon

Try WinClose ("Adobe Acrobat Pro", "" ) or WinKill Posted Image

Edited by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
simonwar

Tried it but its still not having any of it.

Printing as a PDF is causing a problem I can't get around, sticky?

Any more ideas appreciated?

Share this post


Link to post
Share on other sites
seandisanti

Tried it but its still not having any of it.

Printing as a PDF is causing a problem I can't get around, sticky?

Any more ideas appreciated?

Check out WinTitleMatchMode to see different title matching options to use in your WinWaitActive()

Share this post


Link to post
Share on other sites
electrico

_WinWaitActivate ? A new function ? Posted Image

And simplify your Send : {RIGHT 41} instead of "RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}{RIGHT}"

Same for DOWN, LEFT etc...

Btw, this man as me, just used recorder, so I dont know why but recorder always create this new function while activating and disactivating any windows.

Share this post


Link to post
Share on other sites
l3ill

Tried it but its still not having any of it.

Printing as a PDF is causing a problem I can't get around, sticky?

Any more ideas appreciated?

Hi Simon,

if you are still looking here is how I solved a similar issue:

;Print PDF ======================================================================>>>
        WinActivate("sani_protocol.pdf")
        WinWaitActive("sani_protocol.pdf")
        Sleep(300)
        Send("^p")
        Sleep(300)
        WinWait("Print", "", 5)
        WinWaitActive("Print")
        Send("{ENTER}") ;cancels print for testing purposes============>>>
        ;ControlClick("Print", "Rotate and Center", "[CLASS:Button; INSTANCE:17]")
        Sleep(500)
        WinActivate("sani_protocol.pdf")
        WinWaitActive("sani_protocol.pdf")
        Sleep(300)
        WinKill("sani_protocol.pdf")
        Sleep(1000)
        ;Print PDF ======================================================================>>>

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  

×