Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

[AHK v2] – Function that waits for a value to become true or a function to return true. Emulates built-in WinWait, KeyWait, etc. but supports any kind of check.

License

NotificationsYou must be signed in to change notification settings

SALZKARTOFFEEEL/wait

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 

Repository files navigation

Waits for a value to become true or a function to return true.
Emulates built-inWinWait,KeyWait, etc. but supports any kind of check.

Definition

ret := wait(value, timeout :=0, interval :=100)
  • value: The value continuously checkedor the function whose return value is continuously checked.
  • timeoutinteger: Number of milliseconds to wait for at most.0 (the default) will cause it to wait indefinitely.
  • intervalinteger: Number of milliseconds to wait before retrying.100 is the default.Specifying0 is valid and causes aSleep 0.
  • ret: The return value.
    • Iftimeout was reached,ret is an empty string.
    • Otherwise (ifvalue became true),ret isvalue itself if it is not callable⁽¹⁾, or otherwisethe return value of the last call tovalue.call().

Remarks

  1. value is considered callable when either of these conditions is met:

    • type(value) == "Func"value is aFunc Object.
    • type(value) == "BoundFunc"value is aBoundFunc Object.
    • value.hasMethod("Call")value is aFunctor or any other object that implements aCall method.

    These conditions are tested for in the order specified above,with short-circuit evaluation.If either test throws an exception(though only the last one is expected to do so),value is considered not callable.

  2. wait is able to throw an exception if the input arguments are invalid.timeout andinterval must both be apure Integer and be0 or greater.Any other exception is unintended and should be reported. Thank you!

Examples

; Example #1; This will wait 1 second before setting x to true.setTimer () => x :=true,-1000; This will consequently wait at least 1 second before continuing.wait x
; Example #2; This will wait until the Spacebar is pressed,; but will check for it much more frequently than KeyWait would.wait () =>getKeyState("Space"),,10
; Example #3; This is exactly equivalent to the previous example.waitfunc("getKeyState").bind("Space"),,10
; Example #4; This will wait for Joystick #1 to be plugged in; and display its name on the screen.msgbox"Joystick '" wait(() =>getKeyState("1JoyName"))"' has been plugged in!"

About

[AHK v2] – Function that waits for a value to become true or a function to return true. Emulates built-in WinWait, KeyWait, etc. but supports any kind of check.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp