Jump to content

Problem looping Timerinit - Timerdiff


Recommended Posts

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.

 

Link to comment
Share on other sites

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 

Link to comment
Share on other sites

  • Moderators

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".

 

"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

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"

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

  • Moderators

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

 

"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

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!

Link to comment
Share on other sites

  • Moderators

So how about just:

While 1
    WinWait("Test, S.L - Imprimiendo...", "&Cancelar")
    ;Do whatever else you want to do
    Sleep(2000)
WEnd

 

"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

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.

Link to comment
Share on other sites

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!!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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

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...