How to bring my application to the front?

后端 未结 8 687
孤城傲影
孤城傲影 2020-12-08 15:32

I know all the reasons why it is a bad idea. I dislike it if an application steals input focus, but this is for purely personal use and I want it to happen; it will not dist

8条回答
  •  执念已碎
    2020-12-08 16:04

    Here's something simple that seems to work, tested with multiple boxes consisting of XP, Server2003, Vista, Server2008, W7. Test application ran with a standard (or admin) account, stole the input focus from notepad while writing in the foreground.

    var
      Input: TInput;
    begin
      ZeroMemory(@Input, SizeOf(Input));
      SendInput(1, Input, SizeOf(Input)); // don't send anyting actually to another app..
      SetForegroundWindow(Handle);
    

    You can tweak it further f.i. for a minimized app or such if required.

提交回复
热议问题