Hello Cpcdos!
I doubt that any human can type faster than a computer processes the input. It's a strange behaviour. Maybe there's something wrong with your keyboard (contact bounce)?
Some time ago I wrote a sub that sends a keystroke simulation to the foreground window. Maybe it can help you.
Code: Select all
#Include Once "windows.bi"
Sub KeySim(key As String = "")
Dim As IINPUT ip
Dim As String ut
Dim As UByte ta
ta = Asc(UCase(Right(key,1))) 'key as capital
If Len(key) > 1 Then
ut = LCase(Left(key,InStr(key, Any " +") - 1)) 'isolate function key
Else
ut = "" 'no function key
EndIf
ip.itype = INPUT_KEYBOARD
With ip.ki
.wScan = 0
.dwFlags = 0
If ut <> "" Then
Select Case ut 'press function key
Case "shift"
.wVk = VK_SHIFT
Case "alt"
.wVk = VK_MENU
Case "altgr"
.wVk = VK_RMENU
Case "ctrl"
.wVk = VK_CONTROL
End Select
SendInput(1,Cast(LPINPUT,@ip),SizeOf(ip))
EndIf
.wVk = ta
SendInput(1,Cast(LPINPUT,@ip),SizeOf(ip)) 'press key
.dwFlags = KEYEVENTF_KEYUP
SendInput(1,Cast(LPINPUT,@ip),SizeOf(ip)) 'release key
If ut <> "" Then
Select Case ut 'release function key
Case "shift"
.wVk = VK_SHIFT
Case "alt"
.wVk = VK_MENU
Case "altgr"
.wVk = VK_RMENU
Case "ctrl"
.wVk = VK_CONTROL
End Select
SendInput(1,Cast(LPINPUT,@ip),SizeOf(ip))
EndIf
End With
End Sub
How the sub is to be used:
Code: Select all
...
SetForegroundWindow(hWndAudacity)
Sleep 100
KeySim("alt+d") 'open file menu
KeySim("i") 'import
KeySim("a") 'audio
...
Regards
grindstone