M
Morten Snedker
I have this piece of code that sets focus to the the windows
calculator application (calc.exe). Efter focus I try simply to pass
the number 5 to the application.
The calculater gets focus and is shown, but the number 5 is not
displayed. Have I missed something?
Sub SetWindowFocus()
Dim hwndApp As IntPtr
Dim hwndForeground As IntPtr
Dim ThreadForeground As Integer
hwndApp = FindWindow(vbNullString, "Lommeregner")
If Not hwndApp.Equals(IntPtr.Zero) AndAlso _
Not hwndApp.Equals(GetForegroundWindow) Then
ThreadForeground =
GetWindowThreadProcessId(hwndForeground, IntPtr.Zero)
AttachThreadInput(ThreadForeground, 0, True)
SetForegroundWindow(hwndApp)
AttachThreadInput(ThreadForeground, 0, False)
End If
SendKeys.SendWait("5")
'SendKeys.Send("5")
End Sub
Regards /Snedker
calculator application (calc.exe). Efter focus I try simply to pass
the number 5 to the application.
The calculater gets focus and is shown, but the number 5 is not
displayed. Have I missed something?
Sub SetWindowFocus()
Dim hwndApp As IntPtr
Dim hwndForeground As IntPtr
Dim ThreadForeground As Integer
hwndApp = FindWindow(vbNullString, "Lommeregner")
If Not hwndApp.Equals(IntPtr.Zero) AndAlso _
Not hwndApp.Equals(GetForegroundWindow) Then
ThreadForeground =
GetWindowThreadProcessId(hwndForeground, IntPtr.Zero)
AttachThreadInput(ThreadForeground, 0, True)
SetForegroundWindow(hwndApp)
AttachThreadInput(ThreadForeground, 0, False)
End If
SendKeys.SendWait("5")
'SendKeys.Send("5")
End Sub
Regards /Snedker