Jump to content
Sign in to follow this  
Easton

Problem looping Timerinit - Timerdiff

Recommended Posts

Easton

Hi everyone!

First af all say thank you to all the people is helping in the forum, I'm a newbie with autoit (in fact with everything related with programing) and I'm learning a lot.

The fact is that I don't know what I'm doing wrong here:

I need autoit stay always measuring the time between 2 events (closing and opening of a printing windows), because when this time is bigger than 2 seconds means than the job is over.  And then exit the loop.

------------

Winwait ("Test, S.L - Imprimiendo...","&Cancelar")

While $fDiff > 2000

if Winexists("Test - Imprimiendo...","&Cancelar")=0  then
   $hTimer = TimerInit()
   EndIf

if Winexists("Test - Imprimiendo...","&Cancelar") then
   $fDiff = TimerDiff($hTimer)
EndIf

WEnd

--------------

 

I receive this error: Variable used without being declared.

 

Share this post


Link to post
Share on other sites
Easton

I also try with:

 

Winwait ("Test, S.L - Imprimiendo...","&Cancelar")

Do

if Winexists("Test, S.L - Imprimiendo...","&Cancelar")=0  then
   $hTimer = TimerInit()
   EndIf

if Winexists("Test, S.L - Imprimiendo...","&Cancelar") then
   $fDiff = TimerDiff($hTimer)
EndIf

Until $fDiff > 2000

 

But it doesn't work 

Share this post


Link to post
Share on other sites
JLogan3o13

On your first post, you're trying to use $fDiff without first declaring it. Look again at the example in the help file for TimerInit().

On your second post "it doesn't work" doesn't exactly help us a whole lot does it? It looks like the code runs; are you getting an error, or is it never finding the window? You have to give us more than "it doesn't work".

 


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Easton

It does not know what $fDiff is.

You need to declare it before you use it.

​How do I do it? Excuse me if it is a very simple question :>

Share this post


Link to post
Share on other sites
Easton

On your first post, you're trying to use $fDiff without first declaring it. Look again at the example in the help file for TimerInit().

On your second post "it doesn't work" doesn't exactly help us a whole lot does it? It looks like the code runs; are you getting an error, or is it never finding the window? You have to give us more than "it doesn't work".

 

​Excuse me, on my second post what happens is exactly nothing. There are more than two seconds since last:

if Winexists("Test, S.L - Imprimiendo...","&Cancelar") then
   $fDiff = TimerDiff($hTimer)

And it does not end the "Do ... until"

Share this post


Link to post
Share on other sites
Easton

Best guess...

WinWait("Test, S.L - Imprimiendo...", "&Cancelar")
$hTimer = TimerInit()
Do
    Sleep(10)
Until WinExists("Test - Imprimiendo...", "&Cancelar") Ot TimerDiff($hTimer) > 2000

 

​Thank you John, I really apreciate your help.

It does not work, because "Test - Imprimiendo..." is a windows who opens and closes several times, and the first time when not "winexists" ends the "Do until"

That's why I was thinking in stay measuring the time between closing and opening a new windows, because is a really fast process (send a file to the printer) and never delays more than a half second or less. What means that if the time since last opened window is more than two seconds, the process is done.

Thank you again :)

Share this post


Link to post
Share on other sites
JLogan3o13

Why is the window opening an closing multiple times, what are you trying to accomplish? Is it installing software?

 


√-1 2^3 ∑ π, and it was delicious!

How to get your question answered on this forum!

Share this post


Link to post
Share on other sites
Easton

Why is the window opening an closing multiple times, what are you trying to accomplish? Is it installing software?

 

​I am printing invoices, and I never know how many of them are.

Every invoice my software prints makes appear and close a window.

First I tried with Autoit Recorder but I don't know why this process is not recorded.

Thank you again!

Share this post


Link to post
Share on other sites
JohnOne

Okay, I think I get it now.

 

A window pops up and closes while the job is occurring.

If that window does not appear for 2 seconds, it means the job has completed and you can carry on in your script?

Which is the popup wndow?


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Easton

Okay, I think I get it now.

 

A window pops up and closes while the job is occurring.

If that window does not appear for 2 seconds, it means the job has completed and you can carry on in your script?

Which is the popup wndow?

​Exactly!!

The popup window is  "Test - Imprimiendo...","&Cancelar"

Thank you all of you again!!

Share this post


Link to post
Share on other sites
JohnOne

WinWait("Test, S.L - Imprimiendo...", "&Cancelar")
$hTimer = TimerInit()
Do
    Sleep(10)
    If WinExists("Test - Imprimiendo...", "&Cancelar") Then
        $hTimer = TimerInit()
    EndIf
Until TimerDiff($hTimer) > 2000

MsgBox(0,0,"Complete")

 


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

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
Easton

 

WinWait("Test, S.L - Imprimiendo...", "&Cancelar")
$hTimer = TimerInit()
Do
    Sleep(10)
    If WinExists("Test - Imprimiendo...", "&Cancelar") Then
        $hTimer = TimerInit()
    EndIf
Until TimerDiff($hTimer) > 2000

MsgBox(0,0,"Complete")

 

 

​Wow thank you!!!!

Now it works perfectly, I've been nearly two days trying combinations without success, you don't know how I thank you!!

Beers from Barcelona!! :D

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  

×