Jump to content

Recommended Posts

  • Moderators
Posted

50M4,

Welcome to the AutoIt forums.

You can do this by using a series of small Sleeps and checking in between:

$iMaxDelay = 10000 ; 10 secs
$iActDelay = 0

While 1
    ; Minimum Sleep time
    Sleep(10) 
    ; Increase the actual delay
    $iActDelay += 10 
    ; If the test is true or the max delay is reached - exit the loop
    If $iTest = True Or $iActDelay >= $iMaxDelay Then ExitLoop
WEnd

There are several other ways to do it, but the basic principle is always the same.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

  • Moderators
Posted

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Posted

This days we can just  if something then ...

Using a meaningful variable name  would be better.

 

Saludos

Posted

this days??? what about the old days? what do you use??? :lol::lol::lol:

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Posted (edited)

Was bored, maybe this is what you meant?

#include <String.au3>

HotKeySet("{F1}", SetName)

Global $sName = "Test"
Global $sBool = True
Global $iInt = -1
Global $dDouble = 0.0

ToolTip("$sName = " & $sName, 0, 0)

SleepUntil("sName = InunoTaishou", 100)

MsgBox("", $sName, "Name has been updated to " & $sName & ". Met condition needed and left sleep function")

ToolTip("$sBool = " & $sBool, 0, 0)

SleepUntil("$sBool <> True", 100)

MsgBox("", $sBool, "Bool has been updated to " & $sBool & ". Met condition needed and left sleep function")

ToolTip("$iInt = " & $iInt, 0, 0)

SleepUntil("$iInt > 0", 100)

MsgBox("", $iInt, "Int has been updated to " & $iInt & ". Met condition needed and left sleep function")

ToolTip("$dDouble = " & $dDouble, 0, 0)

SleepUntil("$dDouble = 99.99", 100)

MsgBox("", $dDouble, "Double has been updated to " & $dDouble & ". Met condition needed and left sleep function")

Func SetName()
    $sName = "InunoTaishou"
    HotKeySet("{F1}", SetBool)
EndFunc

Func SetBool()
    $sBool = False
    HotKeySet("{F1}", SetInt)
EndFunc

Func SetInt()
    $iInt = 100
    HotKeySet("{F1}", SetDouble)
EndFunc

Func SetDouble()
    $dDouble = 99.99
EndFunc

Func SleepUntil($sCondition, $iTime = 100)
    ; Comparison to use, check if Var = Val or Var <> Val in the while loop
    Local $sComparison = (StringInStr($sCondition, "=") ? "=" : StringInStr($sCondition, "<>") ? "<>" : _
                            StringInStr($sCondition, ">=") ? ">=" : StringInStr($sCondition, "<=") ? "<=" : _
                            StringInStr($sCondition, ">") ? ">" : StringInStr($sCondition, "<") ? "<" : "")

    ; Invalid operator supplied to compare Var to Val
    If ($sComparison = "") Then Return SetError(1, 0, False)

    ; Split the condition
    Local $aSplit = StringSplit($sCondition, $sComparison, $STR_NOCOUNT + $STR_ENTIRESPLIT)
    ; Variables used to hold the name of the Var to check and the value to check against
    Local $sVar = ""
    Local $sVal = ""

    ; Check that the condition supplied was a valid condition (i.e., $sVar = "String")
    If (UBound($aSplit) = 2) Then
        ; Get the var name, removing the '$' character so it can be used in Eval()
        ; and removing the trailing and leading spaces
        $sVar = StringReplace(StringStripWS($aSplit[0], $STR_STRIPLEADING + $STR_STRIPTRAILING), "$", "")

        ; Check that the variable is declared, if not return an error
        If (Not IsDeclared($sVar)) Then Return SetError(2, 0, False)

        ; Get the value, alost removing the trailing and leading
        $sVal = StringStripWS($aSplit[1], $STR_STRIPLEADING + $STR_STRIPTRAILING)
        If (IsNumber($sVal)) Then
            $sVal = Number($sVal)
        ElseIf ($sVal = "True") Then
            $sVal = True
        ElseIf ($sVal = "False") Then
            $sVal = False
        EndIf
    Else
        Return SetError(3, 0, False)
    EndIf

    ; Which comparison method to use?
    Switch ($sComparison)
        ; Keep sleeping until the Variable = the Val
        Case "="
            While (Eval($sVar) <> $sVal)
                Sleep($iTime)
            WEnd
        ; Keep sleeping until the Variable <> the Val
        Case "<>"
            While (Eval($sVar) = $sVal)
                Sleep($iTime)
            WEnd
        Case ">="
            While (Eval($sVar) <= $sVal)
                Sleep($iTime)
            WEnd
        Case "<="
            While (Eval($sVar) >= $sVal)
                Sleep($iTime)
            WEnd
        Case ">"
            While (Eval($sVar) < $sVal)
                Sleep($iTime)
            WEnd
        Case "<"
            While (Eval($sVar) > $sVal)
                Sleep($iTime)
            WEnd
    EndSwitch

    Return True
EndFunc

 

Edited by InunoTaishou
added >=, <=, >, and <; changed $sVal = "False" to $sval = False
Posted
6 hours ago, 232showtime said:

this days??? what about the old days? what do you use??? :lol::lol::lol:

This:

CMP DX,	00

Saludos

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