• Improving Aloha free VPN privacy using an AutoHotKey freeware script

    From Marion@marionf@fact.com to alt.privacy,alt.comp.freeware,alt.msdos.batch on Sun Oct 19 22:34:24 2025
    From Newsgroup: alt.privacy

    Aloha is a free VPN browser but it's crippleware in that the VPN shuts off randomly, necessitating an always running underlying proxy or VPN.

    To combat the fact the free VPN randomly shuts off (by design), this AutoHotkey script makes the Aloha browser actually immensely more useable.

    I wrote this script to first launch the Aloha VPN Browser, and, if you have "On Startup" URLs, it waits for its window, then it continuously monitors
    the VPN shield icon inside that browser (every half second) and clicks it
    only when the VPN shield is detected as gray (off) so the VPN remains
    enabled (blue) at all times.

    If perchance the Aloha browser window is covered over by another window,
    the script forces a tiny repaint of the Aloha window before sampling pixel colors again.

    I also added follow-me code if the browser window is resized or moved (even
    if it's moved to another monitor) by using client-relative coordinates so
    it works across monitors and window positions, and exits gracefully when
    the Aloha browser process closes.

    Clicks are implemented to avoid stealing focus or visibly moving the mouse
    and the script preserves mouse position around its clicks.

    The script originally included a clear-browsing-data action in earlier versions but the current version removed that click to simplify behavior.
    <aloha://settings/clearBrowserData>

    The script forces a tiny visual change (transparency toggle) to prompt
    Aloha to repaint shield pixels when the window is unfocused so pixel
    sampling remains accurate.

    In summary, this AHK script will prevent Aloha VPN dropouts using an automatic shield-re-enable AHK script

    (which runs silently in the bg w/o stealing focus or moving the mouse.)

    It wasn't easy to write. But here it is all done and working for you!
    Please improve, of course, so everyone benefits from every post you make.

    ; C:\data\sys\ahk\alohavpn.ahk
    ; This is alohavpn.ahk v1.7
    ; This script automatically launches the Aloha VPN Browser,
    ; presses a button to clear browsing data, and continuously
    ; monitors the VPN shield icon by clicking it only if it's off
    ; (gray) to ensure the VPN stays enabled (blue) even if the
    ; browser window isn't the active window or if it's behind others.
    ; Behavior:
    ; 1) Opens Aloha browser
    ; 2) Clicks VPN (gray) shield icon to enable it (blue);
    ; 3) Then periodically checks the shield x:y location 140:53;
    ; 4) If the shield is gray (off), click it; if blue (on), do nothing.
    ; Notes:
    ; Limit on comment line length is .......................................
    ; Coordinates are relative to the Aloha window (CoordMode "Window").
    ; The origin (0,0) is the window top-left corner (incl title/borders).
    ; The X increases to the right; the Y increases downward.
    ; Works regardless of monitor the window is on or where it's moved.
    ; Works regardless of window size.
    ; Works on the window regardless if it's active (current focus) or not.
    ; Use Window Spy to confirm pixel colors and window-relative coordinates.
    ; Clicks use ControlClick so focus isn't stolen & the mouse doesn't move.
    ; Versions
    ; v1.0 20250910 59 lines
    ; Launches the freeware Aloha VPN Browser [Version 4.9.0.0 (64-bit)]
    ; Set the shortcut TARGET = C:\data\sys\ahk\aloha_vpn.ahk
    ; This script runs Aloha which opens to clearBrowserData
    ; <aloha://settings/clearBrowserData>
    ; This script taps the "Clear data" button on bottom right
    ; Then it taps the VPN shield at top to turn the shield on automatically
    ; v1.1 20251016 68 lines
    ; Taps the shield icon every 30 seconds
    ; The probem is that it toggles it off if it had been toggled on
    ; v1.2 20251016 75 lines
    ; Use "C:\Program Files\AutoHotkey\WindowSpy.ahk" to get the color
    ; Click 601, 68 ; this is in the blue/gray part (5895F6/BEBEC4)
    ; v1.3 20251016 142 lines
    ; If gray, tap it. If blue, don't tap it.
    ; Colors from Window Spy (hex RRGGBB)
    ; blueHex := 0x5895F6
    ; grayHex := 0xBEBEC4
    ; tolerance := 30 ; adjust if needed (0-441)
    ; ControlClick without moving the visible mouse (no flicker)
    ; v1.4 20251016 148 lines
    ; Changed the time period from 30 seconds to 1 second
    ; 30 seconds = 30000, 1 second = 1000
    ; v1.5 20251016 127 lines
    ; Cleaned up comments
    ; v1.6 20251016 161 lines
    ; Changed hard-coded path to aloha.exe to be independent of user
    ; Added detection of run failure for a more robust watcher
    ; v1.7 20251017 175 lines
    ; Removed the clear-cookies click to simplify the script.
    ; Added the ability to monitor the shield no matter where it is.
    ; Changed x:y coordinates relative to the screen top-left origin
    ; to x:y (140:53) coordinates relative to the window top-left origin.
    ; Screen: 602, 67, Window: 140, 53
    ; No matter where the Aloha window is on the monitor, the shield
    ; icon will always be at (140,53) relative to the window's origin.
    ; Client: 132, 53 (default) (i.e., main monitor)
    ; Color: 5895F6 (Red=58 Green=95 Blue=F6) (blue)
    ; Active windows position
    ; Screen: x: 462 y: 14 w: 910 h: 1060
    ; Client: x: 470 y: 14 w: 894 h: 1052
    ; The shield icon is always (139,54) relative to window origin
    ; (or (131,54) in client coordinates).
    ; Aloha wasn't repainting shield icon when the window is unfocused.
    ; so we needed to force a tiny "change" in aloha to repaint pixels.
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

    ; Step 1: Launch Aloha VPN Browser and capture its PID
    ; The new instance replaces older running instances sans prompting.
    #SingleInstance Force
    ; Use path to aloha which is independent of the user
    localAppData := EnvGet("LOCALAPPDATA")
    exePath := localAppData . "\Aloha Mobile\Aloha\Application\aloha.exe"

    if !FileExist(exePath) {
    MsgBox "Aloha executable not found:" "'n" exePath
    ExitApp
    }

    ; Start the exe (don't treat Run's return as authoritative)
    Run(exePath)

    ; Wait up to 10 seconds for the Aloha window to appear, then get its PID
    if !WinWait("ahk_class Chrome_WidgetWin_1", , 10) {
    MsgBox "Aloha started but no window appeared within 10s. Check that it launched correctly."
    ExitApp
    }

    ; Get the PID of the window we just waited for
    appPid := WinGetPID("ahk_class Chrome_WidgetWin_1")
    if !appPid {
    MsgBox "Could not determine Aloha PID after launch."
    ExitApp
    }

    ; Step 2: Wait for the browser window and allow page to render
    ; WinWait "ahk_class Chrome_WidgetWin_1",, 15
    Sleep 3000

    ; Step 3: Use client-relative coordinates for mouse and pixel sampling
    CoordMode "Mouse", "Client"
    CoordMode "Pixel", "Client"

    ; Step 5: Shield icon position (stable across monitors)
    buttonX := 131
    buttonY := 55

    ; Step 6: Periodically ensure the shield is ON (click only when gray)
    intervalMs := 500 ; 500 ms = 0.5 seconds

    ; Colors from Window Spy (hex RRGGBB)
    blueHex := 0x5895F6 ; blue (ON)
    grayHex := 0xBEBEC4 ; gray (OFF)
    tolerance := 30 ; color distance tolerance (increase if needed)

    ; Step 7: Use the launched PID in the watcher and start timers
    SetTimer(ClickIfGray, intervalMs)
    SetTimer(CheckAppRunning, 1000)
    Return

    ; --- Functions ---

    ClickIfGray(*) {
    global buttonX, buttonY, grayHex, tolerance, appPid
    hwnd := WinExist("ahk_pid " appPid)
    if !hwnd
    return

    ; Force a repaint by toggling transparency (no visible bounce)
    WinSetTransparent(254, "ahk_id " hwnd)
    WinSetTransparent("OFF", "ahk_id " hwnd)

    ; Sample a 3x3 area around the shield pixel (client-relative)
    total := 0
    count := 0
    for dx in [-1, 0, 1] {
    for dy in [-1, 0, 1] {
    x := buttonX + dx
    y := buttonY + dy
    color := PixelGetColor(x, y, "RGB")
    total += color
    count += 1
    }
    }
    avgColor := Round(total / count)

    ; Show the sampled color value in a tooltip (for debugging)
    ; ToolTip "Sampled color: " avgColor
    ; 16315633 in hex = 0xF8F8F1 is a light gray-white shade.
    ; 5937144 in hex = 0x5A8A88 is a teal-blue shade.

    ToolTip "Sampled color: " Format("0x{:06X}", avgColor)

    if IsColorClose(avgColor, grayHex, tolerance) {
    MouseGetPos(&oldX, &oldY)
    MouseMove(buttonX, buttonY, 0)
    Click
    MouseMove(oldX, oldY, 0)
    }

    }

    IsColorClose(c1, c2, tol) {
    r1 := (c1 >> 16) & 0xFF
    g1 := (c1 >> 8) & 0xFF
    b1 := (c1) & 0xFF
    r2 := (c2 >> 16) & 0xFF
    g2 := (c2 >> 8) & 0xFF
    b2 := (c2) & 0xFF
    dist := Sqrt((r1 - r2)**2 + (g1 - g2)**2 + (b1 - b2)**2)
    return dist <= tol
    }

    CheckAppRunning(*) {
    global appPid
    if !WinExist("ahk_pid " appPid) {
    SetTimer(ClickIfGray, 0)
    SetTimer(CheckAppRunning, 0)
    ExitApp
    }
    }

    ; End of C:\data\sys\ahk\alohavpn.ahk
    --
    I go to trouble and time and effort to write my Usenet posts because I'm
    kind hearted enough to care that everyone gets excellent researched data.
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Marion@marionf@fact.com to alt.privacy,alt.comp.freeware,alt.msdos.batch on Sun Oct 19 22:41:36 2025
    From Newsgroup: alt.privacy

    Marion wrote:
    End of C:\data\sys\ahk\alohavpn.ahk

    I should point out that to use it, all you need to do is make a shortcut
    with the path to the AutoHotKey script as its TARGET.

    alohavpn.lnk
    TARGET = C:\path\to\ahk\alohavpn.ahk

    The AHK script turns the aloha vpn browser from almost unusable crippleware
    to reasonably usable freeware.

    I would still recommend having a system-wide VPN or proxy in the background (just in case) where this script does the trick using Psiphon freeware.

    @echo off
    REM C:\data\sys\batch\psiphon.bat version 1.0 20250819
    REM This is psiphon.bat version 2.2 (??? lines)
    REM Runs "C:\app\network\psiphon\psiphon3.exe" -mode=socks
    REM This method leaves windows open.
    REM %comspec% /k C:\app\network\psiphon\psiphon3.exe -mode=socks
    REM This method closes windows.
    REM psiphon.bat version 1.1 20250916
    REM Added automatic PAC sync/apply after Psiphon launch
    REM psiphon.bat version 1.2 20250916
    REM Added logging to proxy.log when PAC is triggered from psiphon
    REM psiphon.bat version 1.3 20250916
    REM Added optional pause for viewing output before closing
    REM psiphon.bat version 1.4 20250916
    REM Changed to never close parent cmd window and always pause at end
    REM psiphon.bat version 1.5 20250916
    REM Added self-elevation to request UAC if not already admin
    REM psiphon.bat version 1.6 20250916
    REM Added final PAC URL + Auto-Detect set to ensure persistence
    REM after Psiphon/proxy changes
    REM psiphon.bat version 1.7 20250917
    REM Added launch of mongoose.vbs to serve proxy.pac before PAC logic
    REM psiphon.bat version 1.8 20250917
    REM Reordered launch sequence: Mongoose now starts BEFORE Psiphon
    REM Added PAC availability check using curl
    REM Added 2-second wait after Mongoose launch to ensure readiness
    REM psiphon.bat version 1.9 20250917
    REM Error: PAC file not available. Aborting. Press any key to continue
    REM Increased delay from 2 to 4 to give Mongoose more time to bind & serve
    REM psiphon.bat version 2.0 20250917 (111 lines)
    REM Decreased delay back to 2 as it didn't make a difference
    REM Added echo message during Mongoose wait to indicate progress
    REM psiphon.bat version 2.1 20250917 (118 lines)
    REM Expanded Psiphon's reach to WinHTTP apps without compromising WinINET apps
    REM By adding Automatic Sync of WinINET to WinHTTP (e.g., for Windows Update)
    REM Transfers only the Psiphon-injected static HTTP/HTTPS proxy address
    REM Does not transfer PAC logic and SOCKS settings from WinInet to WinHTTP
    REM psiphon.bat version 2.2 20250920 (??? lines)

    :: --- Elevate to admin if not already ---
    >nul 2>&1 net session
    if %errorlevel% neq 0 (
    echo Requesting administrative privileges...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
    )

    REM Launch Mongoose silently to serve proxy.pac
    cscript //nologo "C:\data\sys\batch\launchmongoose.vbs"

    REM Wait for Mongoose to initialize (added in v1.8)
    echo waiting for mongoose... (added in v2.0)
    timeout /t 2 /nobreak >nul

    REM Verify PAC file is available before proceeding (added in v1.8)
    curl --silent --fail http://127.0.0.1/proxy.pac >nul || (
    echo PAC file not available. Aborting.
    pause
    exit /b
    )

    REM Launch Psiphon in SOCKS mode
    start "" /D "C:\app\network\psiphon" psiphon3.exe -mode=socks

    REM Wait a few seconds for Psiphon to initialize
    timeout /t 5 /nobreak >nul

    REM Log that PAC is being run from psiphon
    echo [%DATE% %TIME%] pac.cmd triggered from psiphon.bat >> C:\data\sys\log\proxy.log

    REM Apply PAC logic automatically (silent mode)
    call "C:\data\sys\batch\pac.cmd" /silent

    REM Force PAC URL and Auto-Detect to desired values at the very end
    REM This ensures Psiphon or proxy sync cannot leave them unset
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_SZ /d http://127.0.0.1/proxy.pac /f >nul
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoDetect /t REG_DWORD /d 1 /f >nul

    REM Sync WinINET proxy settings into WinHTTP (added in v2.1)
    netsh winhttp import proxy source=ie

    REM Always pause so you can see output if run from a console
    echo.
    echo Press any key to close...
    pause >nul

    REM End batch without killing the shell
    exit /b


    ::START: You type Win+R -> psiphon
    :: |
    :: v
    ::psiphon.bat
    :: - Check if running as admin
    :: - If not, request UAC elevation and restart
    :: - Launch mongoose.vbs to serve proxy.pac (moved earlier in v1.8)
    :: - Wait 2 seconds for Mongoose to initialize (added in v1.8)
    :: - Echo "waiting for mongoose..." during delay (added in v1.9)
    :: - Verify PAC file is accessible via curl (added in v1.8)
    :: - Launch psiphon3.exe in SOCKS mode
    :: - Wait 5 seconds for Psiphon to initialize
    :: - Log that pac.cmd is being run
    :: - Call pac.cmd /silent
    :: |
    :: v
    :: pac.cmd
    :: - Log run
    :: - Run proxy.cmd /sync to align WinINET -> WinHTTP
    :: - Capture current PAC URL and Auto-Detect status
    :: - If missing or wrong, call proxy.cmd with PAC URL
    :: - Force set PAC URL and Auto-Detect in registry
    :: - Re-capture status so final display is accurate
    :: - Show final PAC and Auto-Detect status
    :: - Return to psiphon.bat
    :: - Force set PAC URL and Auto-Detect again (double guarantee)
    :: - Pause for user to see output
    :: - Exit without closing parent shell
    ::END
    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From VanguardLH@V@nguard.LH to alt.privacy,alt.comp.freeware,alt.msdos.batch on Sun Oct 26 12:09:54 2025
    From Newsgroup: alt.privacy

    Marion <marionf@fact.com> wrote:

    Aloha is a free VPN browser but it's crippleware in that the VPN shuts
    off randomly, necessitating an always running underlying proxy or
    VPN.

    To combat the fact the free VPN randomly shuts off (by design), this AutoHotkey script makes the Aloha browser actually immensely more
    useable.
    ...

    A better targeted audience for Aloha VPN Browser is their forums:

    https://community.alohabrowser.com

    I saw users there comment on the timeouts, and they might be interested
    in how to keep Aloha activated.
    --- Synchronet 3.21a-Linux NewsLink 1.2