Give this a try and let me know if it does what you want. For the name of the program to keep in focus, it is case sensitive, but can be anywhere in the title. i.e. Untitled - Notepad, Notepad would work just fine for the name.
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT
; Author: A.N.Other <[email protected]
; Script Function:
Template script (you can customize this template by editing "ShellNew\Template.ahk" in your Windows folder)
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
Inputbox, name, Program to focus, Type the name of the program to keep in focus:, , 250, 150
if name = ; If nothing is entered for the app name exit script
Inputbox, time, How long to wait, How long should I wait before reactivating? (milliseconds):, , 250, 150
If time =
time := 1000
SetTimer, WatchWindow, %time%