@@ -72,14 +72,20 @@ PromptHandler(promptName, append := false) {
72
72
global _running := true
73
73
global _startTime := A_TickCount
74
74
75
- ShowWaitTooltip()
76
- SetSystemCursor(GetSetting(" settings" , " cursor_wait_file" , " wait" ))
77
-
78
75
prompt := GetSetting(promptName, " prompt" )
79
76
promptEnd := GetSetting(promptName, " prompt_end" )
80
77
mode := GetSetting(promptName, " mode" , GetSetting(" settings" , " default_mode" ))
81
- input := GetTextFromClip()
78
+
79
+ try {
80
+ input := GetTextFromClip()
81
+ } catch {
82
+ global _running := false
83
+ RestoreCursor()
84
+ return
85
+ }
82
86
87
+ ShowWaitTooltip()
88
+ SetSystemCursor(GetSetting(" settings" , " cursor_wait_file" , " wait" ))
83
89
CallAPI(mode, promptName, prompt, input , promptEnd)
84
90
85
91
} catch as err {
@@ -93,16 +99,20 @@ PromptHandler(promptName, append := false) {
93
99
; ###
94
100
95
101
SelectText () {
96
- if WinActive (" ahk_exe WINWORD.EXE" ) or
97
- WinActive ("ahk_exe OUTLOOK.EXE" ) {
98
- ; In Word/Outlook select the current paragraph
99
- Send " ^{Up}^+{Down}+{Left}" ; Move to para start, select para, move left to not include para end
100
- } else if WinActive (" ahk_exe notepad++.exe" ) or
101
- WinActive ("ahk_exe Code.exe" ) {
102
- ; In Notepad++ select the current line
103
- Send " {End}{End}+{Home}+{Home}"
104
- } else {
105
- Send " ^a"
102
+ Send " ^c"
103
+ ClipWait (2 )
104
+ text := A_Clipboard
105
+ if StrLen (text ) < 1 {
106
+ if WinActive (" ahk_exe WINWORD.EXE" ) or WinActive (" ahk_exe OUTLOOK.EXE" ) {
107
+ ; In Word/Outlook select the current paragraph
108
+ Send " ^{Up}^+{Down}+{Left}" ; Move to para start, select para, move left to not include para end
109
+ } else if WinActive (" ahk_exe notepad++.exe" ) or WinActive (" ahk_exe Code.exe" ) {
110
+ ; In Notepad++ select the current line
111
+ Send " {End}{End}+{Home}+{Home}"
112
+ } else {
113
+ ; Select all text if no text is selected
114
+ Send " ^a"
115
+ }
106
116
}
107
117
sleep 50
108
118
}
@@ -118,6 +128,7 @@ GetTextFromClip() {
118
128
text := A_Clipboard
119
129
120
130
if StrLen (text ) < 1 {
131
+ ShowWarning(" No text selected. Please select text and try again." )
121
132
throw ValueError(" No text selected" , - 1 )
122
133
} else if StrLen (text ) > 16000 {
123
134
throw ValueError(" Text is too long" , - 1 )
@@ -126,6 +137,10 @@ GetTextFromClip() {
126
137
return text
127
138
}
128
139
140
+ ShowWarning (message ) {
141
+ MsgBox message
142
+ }
143
+
129
144
GetSetting (section, key, defaultValue := "" ) {
130
145
global _settingsCache
131
146
if (_settingsCache.Has(section . key . defaultValue)) {
@@ -432,4 +447,4 @@ LogDebug(msg) {
432
447
logMsg := " [" . now . " ] " . msg . " `n"
433
448
FileAppend (logMsg, " ./debug.log" )
434
449
}
435
- }
450
+ }
0 commit comments