100 ms is a quite short time to application load. Instead of System.Threading.Thread.Sleep(100) you may try procSungard.WaitForInputIdle(10000) . You'll have a higher chances that the app is actually loaded, UI running and thus app is processing message queue.
Setting focus requires API calls.
Get handle to application window: Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long And set focus: Public Declare Function SetFocusAPI Lib "user32.dll" Alias "SetFocus" (ByVal hWnd As Long) As Long so the "set focus to Sungard app" would look something like this
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "Sungard")
SetFocusAPI(hWnd)
' SendKeys
I didn't test the code but it's quite simple. One thing I do know for sure, SendKeys is never a 100% sure way to send keys :)
Teme64
Veteran Poster
1,040 posts since Aug 2008
Reputation Points: 218
Solved Threads: 206
Skill Endorsements: 5
Just happened to see this:
Private Declare Function OpenIcon Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As
Long) As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, "Sungard")
OpenIcon hWnd
SetForegroundWindow hWnd
' SendKeys
Teme64
Veteran Poster
1,040 posts since Aug 2008
Reputation Points: 218
Solved Threads: 206
Skill Endorsements: 5