Skip to main content

Adaptive waiting and smart automation library — includes Wi-Fi, system context, and Vision Mode for screen-based decisions.

Project description

Nano-Wait

Intelligent Automation with Adaptive Waiting and Computer Vision


Overview

Nano-Wait is a Python library for automating graphical user interfaces (GUIs) that replaces the use of time.sleep() with an Intelligent Adaptive Waiting system, dynamically adjusting the wait time based on:

  • Computer performance (CPU and memory)

  • Wi-Fi signal quality (when available)

  • User-defined aggressiveness level

From version 3.0, Nano-Wait also includes a Computer Vision (OCR) module capable of reading numbers directly from the screen and making automated decisions.

🚀 Why not use time.sleep()?

time.sleep() is static and "blind":

it ignores whether the system is overloaded or if the network is slow.

Nano-Wait solves this by applying a Dynamic Adjustment Factor, ensuring that the script:

  • Is not too slow when the system is fast

  • Nor too fast to the point of breaking the automation


📦 Installation

</code></pre>
<ul>
<li>
<p>Optional Dependencies</p>
</li>
<li>
<p>For full functionality of the Vision module:</p>
</li>
<li>
<p>Tesseract OCR (required for OCR)</p>
</li>
<li>
<p>pytesseract</p>
</li>
<li>
<p>Pillow</p>
</li>
<li>
<p>pyautogui</p>
</li>
<li>
<p>pynput</p>
</li>
<li>
<p>psutil</p>
</li>
<li>
<p>pywifi (Windows only)</p>
</li>
</ul>
<h2>⚠️ Nano-Wait does not collect network data.</h2>
<p>It only reads local signal and operating system performance metrics.</p>
<h2>🧠 Module 1 — Adaptive Waiting (Smart Wait)</h2>
<p>Main function: <strong>wait()</strong></p>
<p>The wait() function is the direct replacement for time.sleep().</p>
<pre><code>from nano_wait import wait

wait(5)

Function Signature

wait(

t: float,
wifi: str | None = None,
speed: str | float = "normal",
verbose: bool = False,
log: bool = False
) -> float

Parameters

Parameter Default Value Behavior when omitted
t required Defines the maximum wait time. Cannot be omitted.
wifi None Nano-Wait ignores network metrics and calculates the factor based only on local performance (CPU and memory).
speed "normal" Uses balanced aggressiveness, prioritizing stability without sacrificing performance.
verbose False No calculation information is displayed in the terminal.
log False No log file is generated (nano_wait.log is neither created nor updated).

Example with Wi-Fi

wait(
5,
wifi="My5G_Network",
speed="fast",
verbose=True

)

Example without Wi-Fi (local hardware only)

wait(2, speed="ultra")

🔬 How wait time is calculated

Nano-Wait calculates an adaptive factor based on:

  • CPU usage

  • Memory usage

  • Wi-Fi signal strength (when available)

Formula applied

wait_time = max(0.05, min(t / factor, t))

Safety rules

  • Floor: never wait less than 50 ms

  • Ceiling: never exceed the original t time

  • Avoids excessive CPU usage

🧠 Module 2 — Vision (OCR and Visual Decision)

The Vision module allows you to read Display numbers on the screen and make automatic decisions.

Main Class

</code></pre>
<h3>Available Modes</h3>
<table>
<thead>
<tr>
<th>Mode</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>observe</td>
<td>Only reads and displays data</td>
</tr>
<tr>
<td>decision</td>
<td>Reads data and executes actions</td>
</tr>
<tr>
<td>learn</td>
<td>Collects visual patterns (experimental)</td>
</tr>
</tbody>
</table>
<h2>📸 Screen Region Capture</h2>
<p>The user can manually mark regions:</p>
<pre><code>region = VisionMode.mark_region()

The return is a tuple:

(x, y, width, height)

🔍 Complete Example — Reading and Decision

from nano_wait.vision import VisionMode

vision = VisionMode(mode="decision")
region = VisionMode.mark_region()
vision.run(regions=[region])

Internal Logic (decision mode)

If detected number > 1000 → double-click

Otherwise → skip item

These actions can be easily customized in the code.

⚙️ Vision Internal Pipeline

  • Screen region capture (ImageGrab)

  • Grayscale conversion

  • OCR via Tesseract

  • Numerical extraction with Regex

  • Execution of automated actions

🧪 Learn Mode (Current State)

  • The learn mode currently:

  • Captures visual data repeatedly

  • Serves as a basis for future versions with persistence

📌 Note: The learn mode does not yet save models to disk.

It is experimental and focused on data collection.

System Wi-Fi Note
Windows Uses pywifi
macOS Uses airport command
Linux Uses nmcli
Others Only wireless mode

🛠 Real-World Use Cases

  • Visual Automation Bots

  • Legacy Dashboard Reading

  • Intelligent Click Adjustment

  • OCR-Based Automation

  • Lightweight RPA without Selenium

🤝 Contribution

  • Fork the project

  • Create a branch (feature/my-improvement)

  • Submit a Pull Request

📄 License

MIT License

👤 Author

Luiz Seabra De Marco

👤 Documentation Author

Vitor Seabra De Marco

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nano_wait-3.1.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nano_wait-3.1.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file nano_wait-3.1.2.tar.gz.

File metadata

  • Download URL: nano_wait-3.1.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nano_wait-3.1.2.tar.gz
Algorithm Hash digest
SHA256 2b826aa96e18d9e5a0067727a0bd599151f60ec1fa24ba22969d740a9e58fff8
MD5 45a5db8373d0374123c27bdad18db5b3
BLAKE2b-256 7d4dfe183cd2f6c1c0e6ba2dd422807da82692152eacf235a481c1a83f1e5ad3

See more details on using hashes here.

File details

Details for the file nano_wait-3.1.2-py3-none-any.whl.

File metadata

  • Download URL: nano_wait-3.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for nano_wait-3.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 98f70c3eee93ac35e8c201176a4cc9b9c65465c2f414873863d459375b1d1fb8
MD5 0c8200313c82bb6212946181bcfeb688
BLAKE2b-256 560ed0ef5af1c8493e29ecd2aa5cf9b2e56b1b04bb121795689c34b7faa36124

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page