Ariver
2026-07-13 2d1d4ad406228ef62ab078724cb7d1556e003d01
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash
#
# qa-settings-window-macos.sh - Launch PrivateVoice and capture the Settings window.
#
# Usage:
#   ./scripts/qa-settings-window-macos.sh [APP_PATH] [OUTPUT_DIR]
#
set -euo pipefail
 
APP_NAME="PrivateVoice Dictation"
 
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
INFO_PLIST="$PROJECT_DIR/build/darwin/Info.plist"
 
APP_PATH="${1:-/Applications/$APP_NAME.app}"
VERSION="$(defaults read "$INFO_PLIST" CFBundleShortVersionString 2>/dev/null || echo "unknown")"
BUILD_ID="$(defaults read "$INFO_PLIST" CFBundleVersion 2>/dev/null || date +%Y%m%d.%H%M)"
OUTPUT_DIR="${2:-$PROJECT_DIR/build/qa/settings-window-$VERSION-build$BUILD_ID}"
SCREENSHOT="$OUTPUT_DIR/settings-input-tab.png"
BOUNDS_FILE="$OUTPUT_DIR/settings-window-bounds.txt"
 
fail() {
  echo "ERROR: $1" >&2
  exit 1
}
 
[[ -d "$APP_PATH" ]] || fail "App bundle not found: $APP_PATH"
 
mkdir -p "$OUTPUT_DIR"
 
osascript -e "tell application \"$APP_NAME\" to quit" >/dev/null 2>&1 || true
pkill -x "$APP_NAME" >/dev/null 2>&1 || true
sleep 1
 
open "$APP_PATH"
 
osascript <<APPLESCRIPT
tell application "System Events"
  repeat 60 times
    if exists process "$APP_NAME" then exit repeat
    delay 0.25
  end repeat
  if not (exists process "$APP_NAME") then error "process did not start"
 
  tell process "$APP_NAME"
    set frontmost to true
    repeat 80 times
      if exists window 1 then exit repeat
      delay 0.25
    end repeat
    if not (exists window 1) then error "settings window did not appear"
 
    set position of window 1 to {80, 80}
    set size of window 1 to {980, 720}
    delay 0.8
 
    try
      click button "输入" of window 1
    on error
      set windowPosition to position of window 1
      click at {item 1 of windowPosition + 92, item 2 of windowPosition + 144}
    end try
 
    delay 0.8
    set windowPosition to position of window 1
    set windowSize to size of window 1
    set x to item 1 of windowPosition
    set y to item 2 of windowPosition
    set w to item 1 of windowSize
    set h to item 2 of windowSize
    do shell script "printf '%s,%s,%s,%s' " & x & " " & y & " " & w & " " & h & " > " & quoted form of "$BOUNDS_FILE"
  end tell
end tell
APPLESCRIPT
 
BOUNDS="$(cat "$BOUNDS_FILE")"
screencapture -x -R"$BOUNDS" "$SCREENSHOT"
 
if [[ ! -s "$SCREENSHOT" ]]; then
  fail "Screenshot was not created: $SCREENSHOT"
fi
 
echo "Settings window screenshot: $SCREENSHOT"
echo "Window bounds: $BOUNDS"