50M4 Posted April 17, 2017 Author Posted April 17, 2017 I'm sorry. I would like to know if i can stop sleep if something turns true?
Moderators Melba23 Posted April 17, 2017 Moderators Posted April 17, 2017 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 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Subz Posted April 17, 2017 Posted April 17, 2017 (edited) Something like: Local $i = 0 While 1 If $i = 10 Then Exitloop Sleep(1000) $i += 1 Wend MsgBox(48, "", "i: = " & $i) Edit: Too slow Melba23 already answered Hey Melba23 Edited April 17, 2017 by Subz
mikell Posted April 17, 2017 Posted April 17, 2017 Shouldn't this If $iTest = True be If $bTest = True ?
Moderators Melba23 Posted April 17, 2017 Moderators Posted April 17, 2017 mikell, Un double pied de nez a toi! M23 Danyfirex 1 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Danyfirex Posted April 17, 2017 Posted April 17, 2017 This days we can just if something then ... Using a meaningful variable name would be better. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
232showtime Posted April 18, 2017 Posted April 18, 2017 this days??? what about the old days? what do you use??? ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon.
InunoTaishou Posted April 18, 2017 Posted April 18, 2017 (edited) Was bored, maybe this is what you meant? expandcollapse popup#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 April 18, 2017 by InunoTaishou added >=, <=, >, and <; changed $sVal = "False" to $sval = False
Danyfirex Posted April 18, 2017 Posted April 18, 2017 6 hours ago, 232showtime said: this days??? what about the old days? what do you use??? This: CMP DX, 00 Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now