Subject: bug#8885: 24.0.50; Temporary failure with `select-frame-by-name' on Windows

From: Juanma Barranquero <[email-masked]>
Date: Fri, 17 Jun 2011 23:57:03 +0200

> AllowSetForegroundWindow failed with w32 error 5: Access is denied.
>
> This error appears to occur when Emacs is "busy" (for example when in the
> middle of loading a large .el file, etc) and executing the emacsclient
> `--eval' command from a Windows command prompt.

I cannot reproduce it, and currently the return value of
AllowSetForegroundWindow is not checked.

But, according to
http://msdn.microsoft.com/en-us/library/ms632668(VS.85).aspx the
function will fail if the calling process cannot set the foreground
window.

So it's possible that you're invoking emacsclient at at moment when
it's unable to set the foreground window, for example if the
foreground lock timeout has not expired.

All in all, trying to make emacsclient give focus to emacs is never
going to be 100% reliable.

    Juanma