From 917326440725190840eacdd519da86e34c50daec Mon Sep 17 00:00:00 2001 From: Beingpax Date: Thu, 6 Mar 2025 20:07:35 +0545 Subject: [PATCH] feat: add error handling for Zen browser AppleScript --- VoiceInk/Resources/zenURL.scpt | 36 ++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/VoiceInk/Resources/zenURL.scpt b/VoiceInk/Resources/zenURL.scpt index 16b4ef8..9cebf90 100644 --- a/VoiceInk/Resources/zenURL.scpt +++ b/VoiceInk/Resources/zenURL.scpt @@ -1,13 +1,25 @@ -tell application "Zen Browser" - activate - delay 0.05 - tell application "System Events" - keystroke "l" using command down - delay 0.05 - keystroke "c" using command down - delay 0.05 - keystroke tab +try + tell application "Zen Browser" + try + activate + delay 0.1 + tell application "System Events" + try + keystroke "l" using command down + delay 0.1 + keystroke "c" using command down + delay 0.1 + keystroke tab + on error errMsg + return "ERROR: System Events failed: " & errMsg + end try + end tell + delay 0.1 + return (the clipboard as text) + on error errMsg + return "ERROR: Zen Browser activation failed: " & errMsg + end try end tell - delay 0.05 - return (the clipboard as text) -end tell +on error errMsg + return "ERROR: Zen Browser application not available: " & errMsg +end try