tonhowtf/omniget · warning · anyhow::Error

configure e inicie uma vez pela tela antes de usar o atalho

Error message

configure e inicie uma vez pela tela antes de usar o atalho

What it means

toggle() switches the autoclicker on/off using the last saved ClickOptions. If the autoclicker is not running and no options were ever configured via start() (LAST_OPTS is None), it cannot know what to start and returns this error, requiring the user to configure and start once through the UI first.

Solutions

  1. Open the autoclicker screen, configure CPS/options, and click Start once before using the hotkey shortcut.
  2. Persist last options to disk (settings file) so they survive restarts and survive hotkey use after relaunch.
  3. Initialize LAST_OPTS with sensible defaults at startup so toggle() always has something to start.
  4. Catch this error in the hotkey handler and surface a notification telling the user to configure first.

Example fix

// before
let opts = last_options()
    .ok_or_else(|| anyhow!("configure e inicie uma vez pela tela antes de usar o atalho"))?;
// after
let opts = last_options().unwrap_or_else(|| ClickOptions {
    cps: 10.0,
    /* defaults de fábrica */
    ..Default::default()
});
start(opts)?;
Defensive patterns

Strategy: validation

Validate before calling

fn hotkey_ready() -> bool { autoclicker_running() || last_options().is_some() }

Type guard

fn has_saved_options(o: &Option<ClickOptions>) -> bool { o.is_some() }

Try / catch

match autoclick::toggle() {
    Ok(started) => update_ui(started),
    Err(e) if e.to_string().contains("configure e inicie") =>
        open_autoclicker_screen(), // orientar o usuário
    Err(e) => show_error(e),
}

Prevention

When it happens

Trigger: Pressing the global hotkey (toggle()) before ever calling start() with a valid ClickOptions — last_options() returns None because LAST_OPTS was never populated.

Common situations: Fresh install: user immediately presses the hotkey without opening the autoclicker screen; settings lost after app restart if LAST_OPTS is not persisted; another process cleared state.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/96158de3eebfd2ee. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/autoclick.rs:204

        .map_err(|e| {
            RUNNING.store(false, Ordering::SeqCst);
            anyhow!("thread: {}", e)
        })?;
    Ok(())
}

pub fn stop() {
    RUNNING.store(false, Ordering::SeqCst);
}

/// Atalho global: para se estiver rodando, senão começa com as últimas opções.
pub fn toggle() -> anyhow::Result<bool> {
    if RUNNING.load(Ordering::SeqCst) {
        stop();
        return Ok(false);
    }
    let opts = last_options()
        .ok_or_else(|| anyhow!("configure e inicie uma vez pela tela antes de usar o atalho"))?;
    start(opts)?;
    Ok(true)
}

pub fn mouse_position() -> Option<(i32, i32)> {
    let enigo = Enigo::new(&Settings::default()).ok()?;
    enigo.location().ok()
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn precise_sleep() {
        let t = Instant::now();
        sleep_until(t + Duration::from_millis(5));
        let e = t.elapsed();

View on GitHub (pinned to 8600b91f42)