I had the same problem for a Windows Server 2012 machine. After trying many other approaches, I tried the one suggested by John T and got it to work. It's somewhat different, probably because of the Metro interface and/or the secure desktop that the popup dialog runs in. It's not able to interact by window title (which is "Remote Desktop Connection"), so I have it detect the process and then send enter.
; Wait for the "Remote Desktop Connection" process to popup and automatically cancel
; must use PID matching on sessionmsg.exe because IfWinExist didn't work (secure desktop?)
loop
{
Process, wait, sessionmsg.exe, 2
NewPID = %ErrorLevel% ; Save the value immediately since ErrorLevel is often changed.
if NewPID = 0
{
Sleep 1000 ; wait a second, save our CPU
}
else
{
Send { Enter }
Sleep 10000 ; it takes sessionmsg.exe several seconds to exit
}
}