Automation Guide

One-Click Stream Start: Automating OBS with AutoHotkey v2

Building robust workflows for reliability, state management, and professional streaming automation

StreaMediaPro
Jan 15, 2026 β€’ 11 min read β€’ Advanced
AutoHotkey automation workflow with OBS and Discord

For a technical blog post targeting developers and power users, "One-Click Stream Start" isn't just about convenienceβ€”it's about reliability and state management. When you go live, you cannot afford to forget to turn on the microphone, select the wrong scene, or fail to notify your Discord community.

Here is a comprehensive guide to building robust AutoHotkey (v2) workflows for streaming automation.

🎯 The Problem: Manual Streaming is Error-Prone

Starting a professional stream involves multiple disjointed actions:

  1. Launching OBS Studio
  2. Waiting for OBS to initialize
  3. Selecting the correct Scene Collection ("Gaming" vs. "Just Chatting")
  4. Starting the Stream
  5. Starting the Recording (local backup)
  6. Updating status on Discord/Slack
  7. Opening browser overlays (chat, alerts)

Doing this manually every time introduces human error. AutoHotkey (AHK) solves this by orchestrating these steps via COM objects, window messages, and HTTP requests.

πŸ“‹ Prerequisites

AutoHotkey v2

Latest version for modern syntax and COM support

OBS WebSockets Plugin

Built into OBS v28+ for programmatic control

Node.js or Python

For handling WebSocket handshake with advanced logic

πŸ’‘ Note: For this guide, we use a hybrid approach: COM Automation for launching apps and OBS WebSockets (via HTTP/JSON) for controlling OBS. This is more reliable than simulating keystrokes with ControlSend.

πŸ—οΈ Architecture of the Workflow

sequenceDiagram
    participant User
    participant AHK Script
    participant OBS Studio
    participant Discord API
    participant Browser

    User->>AHK Script: Press Hotkey (Ctrl+Alt+S)
    AHK Script->>OBS Studio: Check if Running
    alt OBS Not Running
        AHK Script->>OBS Studio: Launch Process
        AHK Script->>AHK Script: Wait for Window Ready
    end
    AHK Script->>OBS Studio: Connect via WebSocket
    AHK Script->>OBS Studio: Set Scene Collection
    AHK Script->>OBS Studio: Start Stream & Record
    AHK Script->>Discord API: POST Status Update
    AHK Script->>Browser: Open Chat Overlay
    AHK Script->>User: Show Notification "Live!"
Mermaid sequence diagram: Full automation flow

βš™οΈ Step 1: The AutoHotkey v2 Script

This script demonstrates how to launch OBS, wait for it to be ready, and trigger actions via a Node.js WebSocket bridge.

Part A: The Node.js Bridge (obs-controller.js)

// obs-controller.js
const OBSWebSocket = require('obs-websocket-js').default;
const obs = new OBSWebSocket();

async function startStreaming() {
    try {
        await obs.connect('ws://localhost:4455', 'your-password');
        console.log('Connected to OBS');
        
        // Start Streaming
        await obs.call('StartStream');
        console.log('Stream Started');
        
        // Start Recording
        await obs.call('StartRecord');
        console.log('Recording Started');
        
        // Switch Scene (Optional)
        // await obs.call('SetCurrentProgramScene', { sceneName: 'Live Scene' });

        await obs.disconnect();
        process.exit(0);
    } catch (error) {
        console.error('Error:', error);
        process.exit(1);
    }
}

startStreaming();

Part B: The AutoHotkey v2 Script (Streamer.ahk)

#Requires AutoHotkey v2.0
#SingleInstance Force

; Configuration
OBS_PATH := "C:\Program Files\obs-studio\bin\64bit\obs64.exe"
NODE_SCRIPT_PATH := "C:\Scripts\obs-controller.js"
DISCORD_WEBHOOK_URL := "https://discord.com/api/webhooks/your-webhook-id/your-token"

; Hotkey: Ctrl + Alt + S to Start Stream
^!s:: {
    TrayTip("Stream Starting", "Initializing OBS and services...", 1)
    
    ; 1. Check if OBS is running
    if !ProcessExist("obs64.exe") {
        Run(OBS_PATH)
        WinWaitActive("ahk_exe obs64.exe", , 10)
        if ErrorLevel {
            MsgBox("OBS failed to start.")
            return
        }
        Sleep(2000) ; Give OBS time to initialize plugins
    }

    ; 2. Trigger Node.js script to control OBS via WebSocket
    try {
        RunWait("node " NODE_SCRIPT_PATH, , "Hide")
    } catch as err {
        MsgBox("Failed to control OBS: " err.Message)
        return
    }

    ; 3. Open Browser Overlays (Streamlabs/StreamElements)
    Run("https://streamlabs.com/dashboard")
    
    ; 4. Notify Discord
    NotifyDiscord("πŸ”΄ I am now LIVE! Join here: https://twitch.tv/yourchannel")

    TrayTip("Stream Live", "You are now streaming and recording.", 2)
}

; Function to send Discord Webhook
NotifyDiscord(message) {
    whr := ComObject("WinHttp.WinHttpRequest.5.1")
    whr.Open("POST", DISCORD_WEBHOOK_URL, false)
    whr.SetRequestHeader("Content-Type", "application/json")
    payload := '{"content": "' message '"}'
    whr.Send(payload)
}

πŸš€ Step 2: Advanced Features for Freelancers

1️⃣ State Checking (Idempotency)

Don't just send "Start Stream." Check if you are already streaming.

  • In Node.js: Call GetStreamStatus before StartStream
  • In AHK: Use ProcessExist to check if OBS is running before launching

2️⃣ Scene Management

Different content requires different scenes. Add parameters to your AHK hotkey:

^!g::Starts "Gaming" scene
^!c::Starts "Chatting" scene

Pass this parameter to the Node.js script to call SetCurrentProgramScene.

3️⃣ Audio Device Control

Use AHK to mute/unmute specific Windows audio devices before streaming. Prevent notifications from leaking into your stream.

; Example: Mute System Sounds using NirCmd (external tool)
RunWait("nircmd.exe mutesysvolume 1", , "Hide")

πŸ”΄ 4️⃣ Fail-Safe: The "Panic Button"

Create a hotkey that immediately stops streaming and recording if something goes wrong.

^!x:: { ; Ctrl + Alt + X to Emergency Stop
    TrayTip("Emergency Stop", "Stopping stream immediately...", 1)
    RunWait("node C:\Scripts\obs-stop.js", , "Hide")
    ProcessClose("chrome.exe") ; Close browser overlays
    TrayTip("Stream Stopped", "All services halted.", 2)
}

πŸ“¦ Step 3: Deployment & Maintenance

1
Compile the Script

Use Ahk2Exe to compile Streamer.ahk into an .exe for easy distribution or startup folder placement.

2
Startup Folder

Place the compiled exe in shell:startup so it runs on boot and is always ready.

3
Logging

Add logging to your Node.js script to track when streams start/stop for analytics and debugging.

βœ… Conclusion

By combining AutoHotkey v2 for OS-level orchestration and OBS WebSockets for precise application control, you create a resilient, one-click streaming workflow. This setup:

  • Reduces pre-stream anxiety
  • Ensures consistent audio/video settings
  • Automates community notifications
  • Allows you to focus on content, not configuration

"Automation isn't about replacing skillβ€”it's about eliminating friction so your expertise can shine."

Workflow Wisdom

πŸ”— Resources

πŸ’‘ Pro Tip

Use #SingleInstance Force in AHK to prevent multiple script instances from conflicting. Critical for reliability.

πŸ”§ Quick Setup

  1. 1. Install AHK v2
  2. 2. Enable OBS WebSockets in Settings
  3. 3. npm install obs-websocket-js
  4. 4. Customize paths & webhooks in script