Jump to content

Need help with time function..


Recommended Posts

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

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@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
Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.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
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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