From Newsgroup: alt.privacy
Marion wrote:
I can't really recommend aloha privacy browser since it seems, after a few days of use, that the vpn suddenly cuts out. There's a warning at the top
to buy the system-wide version and the blue shield turns gray, but there's
no audible or visual other than those, so it's really not very useful.
Out of a thousand things to do on Windows, I fail maybe a handful of times.
But I finally, today, figured out how to keep the Aloha browser VPN alive!
Below is the script I'm using, where the main flaw is the window position
is fixed as I haven't figured out yet how to use relative screen coords.
Without this script, Aloha is unusable in that two horrid things happen:
1. It won't turn the VPN on by default, and,
2. Worse, much worse in fact, it turns it off randomly
Of course, if you have a proxy running in the background, you're still protected when Aloha randomly turns off; but it's not conducive to privacy.
So what I did was write this AutoHotKey script which will check every half second for the color of the VPN on/off toggle. If it's off, turn it on!
Replace the TARGET in the shortcut for aloha web browser to point to this:
TARGET = C:\data\sys\ahk\alohavpn.ahk
; C:\data\sys\ahk\alohavpn.ahk
; This is alohavpn.ahk v1.6
; 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 itos off
; (gray) to ensure the VPN stays enabled (blue).
; Behavior:
; 1) Opens Aloha browser, which opens to the clearBrowserData page.
; 2) Clicks "Clear data" (screen coords).
; 3) Clicks VPN shield icon to enable it, then periodically checks the shield.
; 4) If the shield is gray (off), click it; if blue (on), do nothing.
; Notes:
; Coordinates are absolute screen coordinates (CoordMode "Screen").
; Use Window Spy to confirm pixel colors and coordinates.
; This script uses a real click that restores cursor position.
; 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; 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 screen coordinates for mouse and pixel sampling
CoordMode "Mouse", "Screen"
CoordMode("Pixel", "Screen")
; Step 4: Click "Delete data" button (screen coordinates)
Click 1080, 801
Sleep 1500
; Step 5: Click VPN shield icon once to toggle (use pixel in icon area)
; Use the pixel within the colored area for color sampling
Click 601, 68
Sleep 1000
; Step 6: Periodically ensure the shield is ON (click only when gray)
buttonX := 601
buttonY := 68
; intervalMs := 30000 ; 30000 ms = 30 seconds
; intervalMs := 1000 ; 1000 ms = 1 second (change to 30000 for 30 seconds)
intervalMs := 500 ; 500 ms = 0.5 seconds
; Colors from Window Spy (hex RRGGBB)
blueHex := 0x5895F6
grayHex := 0xBEBEC4
tolerance := 30 ; color distance tolerance (increase if needed)
; Step 7: use the launched PID in the watcher (replace appExe usage)
; remove or ignore any appExe := "aloha.exe" line
; Start timers: the click-checker and the app-watcher
SetTimer(ClickIfGray, intervalMs)
SetTimer(CheckAppRunning, 1000)
Return
; --- Functions ---
ClickIfGray(*) {
global buttonX, buttonY, grayHex, tolerance, appPid
; Sample a 3x3 area and average to reduce anti-aliasing effects
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)
if IsColorClose(avgColor, grayHex, tolerance) {
; Ensure the exact launched process (by PID) still exists, then click and restore cursor
hwnd := WinExist("ahk_pid " appPid)
if hwnd {
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
--
On Usenet, every post should strive to add unique added value to the
newsgroup combined tribal knowledge on the topic currently being discussed.
--- Synchronet 3.21a-Linux NewsLink 1.2