Don't mean to be rude but you gots to RTFM. SetFocus() caan be used to bring a GUI window into focus or to check to see if the windows exists.

If SetFocus ("Untitled - Notepad") = 0 ;Notepad in memory

If SetFocus ("Untitled - Notepad") <> 0 ; Notepad not in memory

SendKeys() will stuff characters to the window you just setfocus to.

Here's a sample from the manual:

code:

Run "notepad.exe"
SetFocus( "Untitled – Notepad" )
$ReturnCode = SendKeys("Hello World")
Sleep( 2 )
$ReturnCode = SendKeys("~{F4}Y")

It's not perfect. Users can break it. Throw up message boxes to let them know what's happening. Here's a sample from one of my scripts:

code:
 
MessageBox("NOTICE!" + Chr(13) + "LANDesk Virus Protect must first be uninstalled." + Chr(13) + "System must REBOOT when complete!" + Chr(13) + "Choose Yes to uninstall and Yes to reboot" + Chr(13) + "on the two options that follow","Norton AntiVirus 7.5 Install",48,60)
RUN "C:\Program Files\LANDesk\VP5\vpremove.exe"
goto finish
endif
RUN "C:\Program Files\LANDesk\VP5\vpremove.exe"
sleep( 1 )
setfocus("Uninstall Message")
sendkeys({ENTER})
sleep( 15 )
setfocus("Uninstall Message")
sendkeys({ENTER})
endif

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.