I can't seem to figure how to overcome Word's annoying notification popup. After I press Replace All button, a notification pops up "All done. We made 3 replacements."
If I press the Enter key, it goes away. However, simulating the Enter or Return keystroke via KM does not seem to work.
Word Replace All.kmmacros (6.4 KB)
Worked for me, but took about
4 seconds to dismiss it.
I disabled the Failure Aborts Macro action because that seems to block the next actions.
Seems like pressing a button slows the actions, possibly making the macro fail:
The accessibility command for pressing the button is synchronous, so it does not complete until the targeting application finishes the action, which in this case includes putting up the dialog and getting some sort of answer.
The error returned is
This is either because you clicked Cancel, or because the application took so long to respond, either way the system reported that pressing the button failed, and Keyboard Maestro is reporting that.
This is just an indication…
Is there a button on the popup?
If so, then use these KM Actions:
Pause Until Button with
Press Button with
The Press Button action is actually synchronous to the button, so the engine does not proceed until the action of the button press completes, which may be instantaneous or may be after the target application finishes processing whatever the button causes to happen, depending on how the application is written.
Yuck! What a mess...
Word's accessibility is less than perfect. It hangs for 5-6 seconds after the replace-all button is pressed.
I got around this by combining AppleScript UI-Scripting and Keyboard Maestro actions.
I'm using Word from Office 2016, and I can't guarantee the UI-Scripting will work properly in different versions.
If I was doing this regularly I'd script the find/replace.
Microsoft Word Replace All v1.00.kmmacros (8.7 KB)