再次感谢!

解决方案 »

  1.   

    if HWND = GetActiveWindow then
    begin
       // add your code here
    end;
      

  2.   

    if form1.active then ...
      

  3.   

    if form1.active then ...
    没错,是这个
      

  4.   

    use GetForegroundWindow apifrom msdn:
    The GetForegroundWindow function returns a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads.用getActiveWindow有时候会取错误的窗口的:)