in reply to Sending a message to Win32 Dialog in background.

What you're doing with sendmessage etc is simulating a user sitting behind a keyboard -- GUI toolkits generally stop processing events when the application loses focus (its in the background)

In short, I don't think you can't do it

  • Comment on Re: Sending a message to Win32 Dialog in background.

Replies are listed 'Best First'.
Re^2: Sending a message to Win32 Dialog in background.
by Corion (Patriarch) on Oct 31, 2012 at 10:05 UTC

    At least up until Windows XP, this does not match my experience. The Win32 windows callback gets called for every message sent to it, whether the window is in the foreground or not. Especially, there are messages that get sent to set the focus to the window.

    If all else fails, the controlling/sending program can force the other window into the foreground and then send the messages.

      Hi, Thanks for your responses, win32 windows will indeed process the messages sent to them no matter whether they are foreground or background, but i am facing an issue particularly here. I think the only way to achieve this could be to set the required window to foreground and then sendkeys. Let me check other options.

        As the alternative, you could try to send the keyboard messages directly to the appropriate window instead of using SendKeys. This will not always work in a convenient way, as the keycodes and keyboard states do not necessarily translate into Windows messages.

      At least up until Windows XP, this does not match my experience.

      You're right, I was misremembering an experience I had with some GUI toolkits, which drop/filter incoming messages based on focus

Re^2: Sending a message to Win32 Dialog in background.
by Anonymous Monk on Oct 31, 2012 at 10:04 UTC
    OTOH, it might work if you can make the app always-on-top, shrink the window to 1x1px or 16x16px, and/or move it off screen ( -100,-100 ) ... good luck finding out :)