Jump to content

Recommended Posts

Hi there my name is Emy , I'm a newbie autoit user. With the help of the documentation I successfully made few scripts . Now im trying to learn more by optimizing them,  I want to add timers to my loops so that if the pixel is not found within 10 seconds then exit the script. Again with the help of the documentation i came up with this below , however it does not give me any error but the timer doesn't work it will stay in the pixelsearch loop for ever. Im kinda stuck there , i tried several other things but no success either. Any help would be greatly appreciate

  1. #include <MsgBoxConstants.au3>
  2. $start = TimerInit()
  3. Do
  4.     PixelSearch(971,636,977,638,0xFFFFFF) 
  5. Until Not @error Or TimerDiff($start) = 10000
  6.     If TimerDiff($start) = 10000 Then
  7.         MsgBox($MB_OK,"ERROR","TIMEOUT!!!",0)
  8.         Exit
  9.     ElseIf Not @error then
  10.     EndIf
  11. MouseClick("left", Random(800,1100), Random(580,666),5,0)
 
 
 
Link to post
Share on other sites

Welcome to AutoIt and the forum!

How high is the probability that TimerDiff returns exactly the value 10000?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2021-06-05 - Version 1.5.4.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2021-06-14 - Version 1.6.5.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
Task Scheduler (2019-12-03 - Version 1.5.1.0) - Download - General Help & Support - Wiki

Tutorials:
ADO - Wiki, WebDriver - Wiki

 

Link to post
Share on other sites
7 minutes ago, water said:

How high is the probability that TimerDiff returns exactly the value 10000?

Just a little higher than the probability that it returns exactly 10000 twice, in succeeding statements :)

Until Not @error Or TimerDiff($start) = 10000
    If TimerDiff($start) = 10000 Then

 

Code hard, but don’t hard code...

Link to post
Share on other sites

I am betting you only changed one.

You need to change both of them. 

#include <MsgBoxConstants.au3>
$start = TimerInit()
Do
    PixelSearch(971,636,977,638,0xFFFFFF)
Until Not @error Or TimerDiff($start) >= 10000
    If TimerDiff($start) >= 10000 Then
        MsgBox($MB_OK,"ERROR","TIMEOUT!!!",0)
        Exit
    ElseIf Not @error then
    EndIf

 

Life's simple. You make choices and you don't look back.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...