You wouldn't actually use this script with a MsgBox from the same script. First, a MsgBox pauses the script until resolved. Second, you don't need to wait for something that you know is going to appear because it is programmed into your script. You can thus handle that issue directly, instead of having code that waits for it. Before you execute the MsgBox command, you can copy its text to the clipboard, or adjust the text in any way you wish. You then have what you want.
Code: Select all
#Requires AutoHotkey v1.1.33
!k::msg("12+f= asdf`nwer wer")
msg(txt) {
Clipboard := RegExReplace(txt, "(\s.*|\W)")
MsgBox % txt
}