简体   繁体   English

VBA Excel Sendkeys箭头在cmd.exe中不起作用

[英]VBA Excel Sendkeys ARROW don't work in cmd.exe

i have some troubles when i will use another key than "{ENTER}" . 我在使用"{ENTER}"以外的其他键时会遇到麻烦。

"{UP}" , "{DOWN}" , "{LEFT}" and "{RIGHT}" don't work in cmd.exe , why ? "{UP}""{DOWN}""{LEFT}""{RIGHT}"cmd.exe不起作用,为什么?

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

Excel启动控制台

You are trying to Wait one second between each SendKey. 您正在尝试在每个SendKey之间Wait一秒钟。 Rather than wait ing, give focus to the app between SendKeys: 不必wait ,而是将焦点放在SendKeys之间的应用程序上:

Private Sub press_key(key As String)
    SendKeys key, True
    DoEvents
End Sub

This will improve the interface between VBA and the app. 这将改善VBA与应用程序之间的界面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM