4

I have to deal with a nasty MS Windows application that quits doing its job as soon as it loses focus. My question is, how can I trick this application somehow to believe that it is still in focus, although it really is not?

My thoughts are:

  1. Is it possible to suppress the corresponding "WM" message from just this application?
  2. Can I send a fake message to this window that it acts like it is in focus?
Kevin
  • 74,910
  • 12
  • 133
  • 166
Xcessity
  • 529
  • 6
  • 12
  • 2
    I suppose you could try sending it a `WM_SETFOCUS` message for a quick and dirty solution - if it even works. Otherwise, probably a hook that handles `WM_KILLFOCUS` messages sent to it. Either way, you can't count on the behaviour of the window if you do that. I certainly hope this is for personal use if you want to experiment with things like this. A more promising solution would be to talk with whoever made the other software and ask for an option to continue when the window loses focus. – chris Dec 12 '12 at 16:07
  • 2
    Depending on how the application works, you may also need to fake out functions like `GetFocus`. The most reliable way of doing this is simply to run the application in a virtual machine and let it keep focus in the visual machine as long as it likes. – Raymond Chen Dec 12 '12 at 17:22

1 Answers1

5

Sending the WM_ACTIVATE message works for some apps:

 SendMessage(hWnd, WM_ACTIVATE, WA_CLICKACTIVE, hWnd);

Leaving the last parameter as NULL might work too.

ascend4nt
  • 144
  • 1
  • 3