Millisecond stopwatch helper for script timing checks and guarded waits.
Syntax
Timer(auto_start=True)
Constructor parameters
Name
Description
auto_startBoolean
Start counting immediately after creation.
Optional · Positional or named
Default:True
Returns
Timer
Behavior / side effects
Millisecond stopwatch helper for script timing checks and guarded waits.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
timer = Timer(auto_start=False)
timer.start()
while not timer.is_elapsed(2000):
wait(50)
timer.stop()
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Related APIs
None
Fields
Name
Description
auto_startBoolean
Whether the timer starts immediately after creation. Assign True to start; assign False to pause.
Default:True
Constructor example
timer = Timer()
if timer.is_elapsed(500):
text("half-second passed")
Methods
10 methods
Timer.start
Method
Start counting if the timer is currently stopped.
Syntax
timer.start()
Parameters
None
Returns
Timer — Returns the same timer for chaining.
Behavior / side effects
Start counting if the timer is currently stopped.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.start()
wait(100)
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Pause counting while preserving elapsed milliseconds.
Syntax
timer.pause()
Parameters
None
Returns
Timer — Returns the same timer for chaining.
Behavior / side effects
Pause counting while preserving elapsed milliseconds.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.pause()
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
timer.pause()
timer.resume()
wait(100)
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Stop counting and keep elapsed milliseconds frozen.
Syntax
timer.stop()
Parameters
None
Returns
Timer — Returns the same timer for chaining.
Behavior / side effects
Stop counting and keep elapsed milliseconds frozen.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.stop()
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Reset elapsed time to 0 while keeping the current running state.
Syntax
timer.reset()
Parameters
None
Returns
Timer — Returns the same timer for chaining.
Behavior / side effects
Reset elapsed time to 0 while keeping the current running state.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
wait(100)
timer.reset()
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Reset elapsed time to 0 and start counting immediately.
Syntax
timer.restart()
Parameters
None
Returns
Timer — Returns the same timer for chaining.
Behavior / side effects
Reset elapsed time to 0 and start counting immediately.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer(auto_start=False)
timer.restart()
wait(100)
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
wait(100)
print(timer.elapsed_ms())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Check whether elapsed time is greater than or equal to the provided milliseconds.
Syntax
timer.is_elapsed(time)
Parameters
Name
Description
timeNumber
Target milliseconds threshold.
Required · Positional or named
No default
Returns
Boolean — true when elapsed time reached or exceeded the threshold.
Behavior / side effects
Check whether elapsed time is greater than or equal to the provided milliseconds.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
wait(500)
if timer.is_elapsed(500):
print("Elapsed")
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
print(timer.is_running())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.
Check whether the timer is paused after being started.
Syntax
timer.is_paused()
Parameters
None
Returns
Boolean — true when timer is paused.
Behavior / side effects
Check whether the timer is paused after being started.
Execution
Blocking: No
Thread safety: Use separate objects per flow
Parallel execution: Yes
Value operations execute in the calling flow without an intentional wait for capture, gesture completion, or user input. Create mutable containers/builders separately in each flow; this is isolation, not a shared-object synchronization guarantee.
Example
# Measure time in the calling flow
timer = Timer()
timer.pause()
print(timer.is_paused())
Errors / limitations
No additional limitations documented; follow the parameter and behavior contract above.