I have Windows XP with dual monitors. One of the monitors is dedicated to SageTV while the other is used for general computer use. If I'm typing an e-mail on one monitor while my wife is controlling SageTV with the remote, SageTV steals the focus whenever 'select' is pressed. I haven't found an adequate solution for this problem on this forum or anywhere. Ideally, SageTV would never take the focus, would always be in the foreground, and if any window inadvertently pops up on the SageTV monitor it would automatically be moved the other screen. In an effort to get what I want, I wrote the following AutoIt script. I hope others will find it useful too.
Code:
;if your monitors are virtually positioned one on top of the other then orientation = 1
;if side by side orientation = 0
$orientation = 1
;you'll have to experiment with this value to get this to work on your system
;if a window is greater than or equal to this value, it will be moved to the other monitor
$cutoff = -5
;hotkey for switching window to another monitor
$hotkey = "+{F1}"
;window name of program that frequently steals the window focus
$focus_stealer = "SageTV"
;Sleep(60000)
While 1
$title1 = WinGetTitle("")
$text1 = WinGetText("")
$handle1 = WinGetHandle("")
WinWaitNotActive ( $handle1 )
$title = WinGetTitle("")
$text = WinGetText("")
$handle = WinGetHandle("")
$size = WinGetPos($handle)
if $size <> 0 Then
if $size[$orientation] >= $cutoff Then
if $title <> $focus_stealer Then
WinActivate($handle)
Send($hotkey)
WinActivate($handle)
Else
If BitAnd(WinGetState($handle1), 16) Then
;MsgBox(0, "test", WinGetState($handle1))
Else
WinActivate($handle1)
EndIf
EndIf
EndIf
EndIf
WEnd