> ## Documentation Index
> Fetch the complete documentation index at: https://docs.botifymanager.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# anti-afk

> How Botify keeps bots alive in ERLC using automated input simulation.

Botify's Anti-AFK system (based on **AntiAFK-RBX v3.2.1**) cycles through every open Roblox window at a configurable interval, simulating player input to prevent idle kicks. It works across all running instances simultaneously and integrates Auto-Reconnect to handle disconnects automatically.

***

## How the Cycle Works

Every configured interval, the system runs through this sequence:

1. Enumerate all open Roblox windows
2. For each window (in order):
   * Bring the window to the **foreground**
   * Perform the configured action **3 times**
   * Restore the window to its previous state (minimized if it was minimized)
   * Apply stagger delay before moving to the next window
3. Restore the **original foreground window** after the full cycle completes

<Note>
  Input is simulated using Win32 `keybd_event` — **not** `SendMessage`. The window must be briefly in the foreground for input to register correctly. Botify handles this automatically.
</Note>

***

## Action Types

| Action           | Keys Simulated | Best For                                                    |
| ---------------- | -------------- | ----------------------------------------------------------- |
| **Space (Jump)** | `SPACE`        | Default — works on most ERLC servers                        |
| **W/S (Walk)**   | `W` then `S`   | Servers that require movement to avoid kick                 |
| **Zoom (I/O)**   | `I` then `O`   | Minimal footprint — camera zoom only, no character movement |

***

## Interval Options

| Interval   | Notes                                                |
| ---------- | ---------------------------------------------------- |
| 3 minutes  | Aggressive — for servers with very short idle timers |
| 6 minutes  | Recommended for most ERLC servers                    |
| 9 minutes  | Balanced — safe with headroom for standard timers    |
| 11 minutes | Conservative                                         |
| 13 minutes | Low frequency                                        |
| 15 minutes | Maximum interval                                     |

<Tip>
  ERLC's default idle kick timer is approximately 20 minutes. A **9-minute interval** is safe for most servers with comfortable headroom.
</Tip>

***

## User-Safe Mode

When **User-Safe Mode** is enabled, the Anti-AFK engine checks for recent user activity before acting:

* Uses Win32 `GetLastInputInfo` / `LASTINPUTINFO` to read the system's last input timestamp
* If the user has been active (keyboard or mouse) within a short window, the cycle is **deferred**
* Prevents Botify from stealing your foreground window while you're working

***

## Auto-Reconnect

When enabled, Auto-Reconnect checks each Roblox window for a disconnect/kick dialog before performing the Anti-AFK action:

**Detection method:**

1. Sample a pixel at the expected kick dialog screen position
2. Check if the pixel color matches `RGB(57, 59, 61)` — the Roblox kick dialog background
3. If matched → calculate the **Reconnect button position** → click with a **randomized offset**

```python theme={null}
# Detection logic (simplified)
pixel_color = get_pixel_at(kick_dialog_position)
if pixel_color == (57, 59, 61):
    click_reconnect_button(randomize_offset=True)
```

<Warning>
  Auto-Reconnect requires the Roblox window to be briefly visible (not minimized) for pixel sampling. Botify handles this during the Anti-AFK cycle automatically.
</Warning>

***

## Force Jump

The **Force Jump All Windows** button (available in Developer Mode) instantly sends a jump input to all open Roblox windows — regardless of the current interval timer. Useful for manually resetting idle states or testing.

***

## Stats Tracking

The Anti-AFK system maintains live counters (visible in the Run Monitor panel):

| Stat                           | Description                                                  |
| ------------------------------ | ------------------------------------------------------------ |
| **Total Actions Performed**    | Cumulative input events sent across all windows since launch |
| **Total Reconnects Triggered** | Number of disconnect dialogs detected and clicked            |

***

## Configuration Reference

| Setting        | Key                 | Default | Description                          |
| -------------- | ------------------- | ------- | ------------------------------------ |
| Action Type    | `antiafk_action`    | `Space` | Input type performed each cycle      |
| Interval       | `antiafk_interval`  | `6 min` | How often the cycle fires            |
| User-Safe Mode | `antiafk_user_safe` | `false` | Defer cycles when user is active     |
| Auto-Reconnect | `antiafk_reconnect` | `true`  | Auto-click Reconnect on kick dialogs |
