Jump to content
Tripoz

Need help with time function..

Recommended Posts

Tripoz

Hello all,

I have a project in autoi script but im too nubie here...

I need some help..

 

I had a project with time,..

In simple language i just want to make function like:

1. If my condition is "True",  For the 1st 5minute in my computer clock, i will click in coord X, Y

2. If my condition " true" again in the same 5minute it willn't doing nothing.

In other words, i just want to make code that will doing something each 5mins. Even they meet alot "true condition" they just will running once in a 5min

 

Can anybody help me what funct that i must use???thx

 

Share this post


Link to post
Share on other sites
water

Welcome to AutoIt and the forum!

Can you please tell us which program you try to automate? Clicking on coordinates is not very reliable because it depends on screen resolution, window position etc.
Most of the time there are better solutions to achieve what you try to do.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tripoz

@jos.   Some condition in excel...

If the formula is =True, they will paste that formula to specific cell each 5minutes (only once in 5mins)

For excel i just will used the udf..but im confuse for the looping

 

I just need one true condition every 5mins, the other they will pass it

Edited by Tripoz

Share this post


Link to post
Share on other sites
water

During this 5 minutes, does your script need to do something else? Or can it just sit there and wait for 5 minutes?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tripoz

@water just waiting the true condition..but there maybe often show up the"true" condition...but i just need 1st true condition each 5mins

 

Edited by Tripoz

Share this post


Link to post
Share on other sites
water

Something like this:

While True
    ; Check condition here
    If condition = True Then
        ; Do whatever you need to do when the condition is true
    EndIf
    Sleep(5 * 60 * 1000) ; Wait 5 minutes
WEnd

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tripoz

Condition in 5 mins : a(true), b(false), c(true), d(true)

In every 5mins i just want to running my code if they meet 1st true condition.in that example is A..n willnot excute when they meet other True condition ( C)

Share this post


Link to post
Share on other sites
Tripoz

Something like this:

While True
    ; Check condition here
    If condition = True Then
        ; Do whatever you need to do when the condition is true
    EndIf
    Sleep(5 * 60 * 1000) ; Wait 5 minutes
WEnd

Hmmm...if the 1st condition found in minute 3, so the code will run again in minute 8 right (sleep 5min)

But in excel my condition will looping every 5minutes.. If the true condition is found in minute 6 so they will pass it too right..

Sorry bad english so i cant explain it in well..

 

Share this post


Link to post
Share on other sites
Tripoz

Minute.            :  [1.....2....3....4.....5]. [6....7....8....9....10].  [11....12....13....14....15]

Condition true:  [A.....b.....c....d.....e]. [b....c....A....d.....A].   [d......e........b.....A.......e]

They will run the code if meet "A" in minutes 1, 8 n 14....but will pass condition "A" in minute 10 cause in 5min they was found "A" in min 8...

Share this post


Link to post
Share on other sites
water

Minute.           :  [1.....2....3....4.....5]. [6....7....8....9....10].  [11....12....13....14....15]

Condition true:  [A.....b.....c....d.....e]. [b....c....A....d.....A].   [A......e........b.....A.......e]

To get a better understanding of what you need.
It processes A in minute 1 and 8, ignores A in minute 10 but would the script process condition A in minute 11?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Tripoz

 if the condition like urs, they will just process A in minute 1,8 & 11 only. N will ignore A in minute 10 n 14

Share this post


Link to post
Share on other sites
water

Something like this? It writes the values of the "mintues" to the console when A is true and will be processed. I've added comments so you see what is going on.
 

Global $iTimer = 1, $iCountA = 0
Global $sValueA = ";1;8;10;11;14;" ; <== Just needed for the test script. Remove it in your productions cript

While True
    If Mod($iTimer, 5) = 1 Then ; New block of 5 minutes has started.
        $iCountA = 0 ; Reset counter
    EndIf
    If StringInStr($sValueA, ";" & $iTimer & ";") Then ; <== Checking condition. Needs to be replaced with the real thing
        If $iCountA = 0 Then
            ConsoleWrite($iTimer & @CRLF) ; <== Needs to be changed to the reald processing (cell copying)
            $iCountA = $iCountA + 1
        EndIf
    EndIf
    $iTimer = $iTimer + 1
    Sleep(10) ; <== To wait for a minute change the value to 1000
    If $iTimer > 15 Then Exit ; <== Condition to end the script. Needs to be changed to your ending condition
WEnd

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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

×