My goal is to wait until the “Check Spelling” window is closed by an operator, which would then allow a larger script to continue to process.
Does anybody have any creative methods to tell if the Check Spelling window is open or closed?
Below is an example of a script routine that worked with InDesign 2017, but does not work with 2024:
tell application id "com.adobe.InDesign"
activate
tell application "System Events"
tell process "InDesign CC"
keystroke "l" using {command down, option down}
end tell
repeat until exists (button 1 of window "Check Spelling" of process "InDesign CC")
delay 0.2
end repeat
set errState to true
set errFound to false
set spWinExists to true
repeat while (spWinExists is true or errState is true)
set errFound to false
try
with timeout of 0.5 seconds
get title of process "InDesign CC"
end timeout
on error
set errFound to true
end try
if errFound is not true then
set errState to false
else
set errState to true
end if
try
if (exists of (button 1 of window "Check Spelling" of process "InDesign CC")) is false then set spWinExists to false
on error
set spWinExists to false
end try
end repeat
end tell
end tell
Hi leo_r,
We cannot use 2025 for hardware reasons that are difficult to explain. Regarding my spell check question, I’m looking for a method to determine when the Check Spelling window is no longer open. It seems that System Events cannot detect the Check Spelling window as a UI element like it used to.
Replacing “InDesign CC” with “Adobe InDesign 2024” does not resolve the issue. It seems that System Events does not recognize the “Check Spelling” window at all, unlike how it did with InDesign 2017.
Indeed. System Events doesn’t list any InDesign’s auxiliary windows. I don’t have any ideas of how to detect the status of the Check Spelling window right now (save for taking screenshots and analyzing their text).
Hi leo_r,
Yes indeed! I used the same screenshot you mentioned, and it’s working perfectly.
As I’m new to Keyboard Maestro, I’m still figuring out the best approach. I’ve set up an “IF” macro to search for an image on the screen, and my script executes this KM image search macro in a repeat loop until the image is no longer found.
Here’s the basic AppleScript I’m using in conjunction:
set spellResp to button returned of (display dialog "Would you like to check spelling?" buttons {"No", "Yes"} default button "Yes" with icon 2)
if spellResp is "Yes" then
set theOldClip to the clipboard
set myTest to false
set the clipboard to "true"
tell application id "com.adobe.InDesign"
activate
tell application "System Events"
tell process "InDesign CC"
keystroke "l" using {command down, option down}
end tell
--make sure check spelling opens
repeat while myTest is false
tell application "Keyboard Maestro Engine"
do script "FindCheckSpelling"
set foundCheckSpelling to the clipboard
if foundCheckSpelling is "true" then
set myTest to true
end if
end tell
end repeat
--wait for spellcheck to close
repeat while myTest is true
try
tell application "Keyboard Maestro Engine"
do script "FindCheckSpelling"
end tell
set foundCheckSpelling to the clipboard
if foundCheckSpelling is "false" then
set myTest to false
else
delay 0.1
end if
end try
end repeat
set the clipboard to theOldClip
end tell
end tell
---script continues to do other checks on the document
end if
Here’s what the macro looks like. However, I’ll be removing the triggers, as they aren’t needed for my final script: