Reputation: 752
i have some troubles when i will use another key than "{ENTER}"
.
"{UP}"
, "{DOWN}"
, "{LEFT}"
and "{RIGHT}"
don't work in cmd.exe
, why ?
Private Sub press_key(key As String)
SendKeys key, True
Application.Wait (Now + TimeValue("0:00:01"))
End Sub
Sub Test()
Call Shell("C:\ ... \name.EXE", vbNormalFocus)
Application.Wait (Now + TimeValue("0:00:01"))
press_key ("{ENTER}")
press_key ("{ENTER}")
press_key ("{DOWN}")
press_key ("{DOWN}")
press_key ("{DOWN}")
press_key ("{RIGHT}")
press_key ("{DOWN}")
press_key ("{DOWN}")
press_key ("{DOWN}")
press_key ("{ENTER}")
End Sub
Upvotes: 1
Views: 510
Reputation: 96771
You are trying to Wait
one second between each SendKey. Rather than wait
ing, give focus to the app between SendKeys:
Private Sub press_key(key As String)
SendKeys key, True
DoEvents
End Sub
This will improve the interface between VBA and the app.
Upvotes: 2