Here's a commented code example:
SetTitleMatchMode, 2
/* Choose the window title acoording to your language:
* English: Message
* German: Nachricht
* ...
*/
msgWin := "- Message ahk_exe outlook.exe"
WinGet, hwndList, List, %msgWin%
Loop % hwndList
{
aHwnd := hwndList%A_Index%
WinGetTitle, ttl, % "ahk_id " aHwnd
ControlGetText, btnText, Button1, ahk_id %aHwnd%
/* If you want to be sure, check for the text of the send button:
* English: &Send, German: &Senden, ...
*/
if(!btnText || !InStr(btnText, "Send")) {
MsgBox, Not a draft window:`n%ttl%
} else {
MsgBox, Draft window:`n%ttl%
}
}
It basically checks for each open Message window, if there's a Send button in it (for me, it's Button1
). If there's no such button, it's not a draft.
As described in the code's comments, you'll have to adjust the language dependent identifiers. You may also have to change the control name (Button1
), window spy will give you that info.