diff --git a/src/lib/ae_events/ae_launcher__default_launch_profiles.ts b/src/lib/ae_events/ae_launcher__default_launch_profiles.ts index d488225d..0b8a2f8c 100644 --- a/src/lib/ae_events/ae_launcher__default_launch_profiles.ts +++ b/src/lib/ae_events/ae_launcher__default_launch_profiles.ts @@ -63,14 +63,15 @@ function make_vlc_mirror_mac_profile(): LaunchProfile { // Direct binary path ensures VLC receives media file + flags reliably. // `--no-play-and-exit` prevents closing on end, `--play-and-pause` holds final frame. open_cmd: '/Applications/VLC.app/Contents/MacOS/VLC --no-play-and-exit --play-and-pause "{{path}}"', - post_delay_ms: 1000, - // Poll until VLC is frontmost before sending Cmd+F. A fixed delay is unreliable because - // VLC cold-start on a loaded conference Mac can take 3-5 seconds. - // Polling (15 × 0.5 s = up to 7.5 s after the initial wait) fires as soon as VLC is ready. - post_script: `tell application "VLC" - activate -end tell -repeat 15 times + post_delay_ms: 2000, + // Poll until VLC is frontmost before sending Cmd+F. Re-activate on every iteration — + // a single activate at the top is blocked by macOS focus-stealing prevention when VLC + // is spawned as a child of Electron (which stays frontmost). Retrying activate each loop + // keeps nudging macOS until it yields focus. Max wait: 20 × 0.5s = 10s after initial delay. + post_script: `repeat 20 times + tell application "VLC" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "VLC" is true then exit repeat @@ -104,10 +105,10 @@ const POWERPOINT_MAC_EXTEND_PROFILE: LaunchProfile = { display_mode: 'extend', open_cmd: 'open -a "Microsoft PowerPoint" "{{path}}"', post_delay_ms: 1000, - post_script: `tell application "Microsoft PowerPoint" - activate -end tell -repeat 15 times + post_script: `repeat 20 times + tell application "Microsoft PowerPoint" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "Microsoft PowerPoint" is true then exit repeat @@ -148,10 +149,10 @@ const LIBREOFFICE_MAC_EXTEND_PROFILE: LaunchProfile = { display_mode: 'extend', open_cmd: 'open -a "LibreOffice" "{{path}}"', post_delay_ms: 1000, - post_script: `tell application "LibreOffice" - activate -end tell -repeat 15 times + post_script: `repeat 20 times + tell application "LibreOffice" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "soffice" is true then exit repeat @@ -170,10 +171,10 @@ const ACROBAT_MAC_MIRROR_PROFILE: LaunchProfile = { display_mode: 'mirror', open_cmd: 'open -a "Adobe Acrobat Reader DC" "{{path}}"', post_delay_ms: 1000, - post_script: `tell application "Adobe Acrobat Reader DC" - activate -end tell -repeat 15 times + post_script: `repeat 20 times + tell application "Adobe Acrobat Reader DC" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "AdobeReader" is true then exit repeat @@ -215,10 +216,10 @@ const LIBREOFFICE_WIN_EXTEND_PROFILE: LaunchProfile = { display_mode: 'extend', open_cmd: 'open -a "LibreOffice" "{{path}}"', post_delay_ms: 1500, - post_script: `tell application "LibreOffice" - activate -end tell -repeat 15 times + post_script: `repeat 20 times + tell application "LibreOffice" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "soffice" is true then exit repeat @@ -237,10 +238,10 @@ const ACROBAT_WIN_MIRROR_PROFILE: LaunchProfile = { display_mode: 'mirror', open_cmd: 'open -a "Acrobat Reader Windows" "{{path}}"', post_delay_ms: 1500, - post_script: `tell application "Acrobat Reader Windows" - activate -end tell -repeat 15 times + post_script: `repeat 20 times + tell application "Acrobat Reader Windows" + activate + end tell delay 0.5 tell application "System Events" if frontmost of process "Acrobat Reader Windows" is true then exit repeat