
AppActivate doesn't seem to work with SendKeys
I have a VB.NET application which has a button click event both bring up and
take down an IE window. The code is as follows:
'ProcessId is a Public integer variable
If ProcessId = 0 then
ProcessId = Shell("""C:\Program Files\Internet
Explorer\IEXPLORE.EXE"" ""filename""", AppWinStyle.NormalFocus)
AppActivate(ProcessId)
Else
AppActivate(ProcessId)
SendKeys.Send("%(FC)") 'Send the window an Alt-F, Alt C to close it
EndIf
A click of the application's button brings up IE as expected, but then while
a later click of this button executes the "Else" code properly, it doesn't
close the IE window. The calling program loses focus, but the IE window
doesn't seem to gain the focus in order for the SendKeys command to close
it. Its like the AppActivate command is only doing half the job.
What am I missing here?
Don Peters