【问题标题】:WshShell keystroke multimedia Next Track windowsWshShell 击键多媒体 Next Track 窗口
【发布时间】:2015-02-04 04:00:22
【问题描述】:

我有一个向活动窗口发送击键的 wscript。

我有以下媒体键的击键代码:

Vol +(代码:&hAF)

卷-(代码:&hAE)

上一首曲目(代码:&hB1)

下一曲目(代码:&hB0)(不工作)

播放/暂停(代码:&hB3)

但是我不能让它模拟Next Track键,我认为它与十六进制代码中的0有关

这是发送按键的代码:

'this script is working on W7 and W8    
Set WshShell = CreateObject("WScript.Shell")
WshShell.SendKeys(chr(&hB0)) 'change the chr argument by any hex to send keystrokes to the active window
Set WshShell = Nothing

我使用此链接作为获取代码的基础:http://orlando.mvps.org/SendKeysMore.asp

问题在于,不是发送击键“Media Next”,而是向活动窗口发送击键“°”

这个十六进制 (&hB0) 转换为十进制是 176,而 176 映射到°

非常感谢您的帮助。

提前致谢

【问题讨论】:

    标签: testing keyboard-events keystroke wsh


    【解决方案1】:

    我解决了我的问题。由于某种原因,我无法让上面的代码工作。

    使用其他方法(和谷歌)我找到了一个 C 脚本

    位于: https://batchloaf.wordpress.com/2012/04/17/simulating-a-keystroke-in-win32-c-or-c-using-sendinput/

    经过测试,我将代码修改为可以传递参数: 张贴在这里: https://batchloaf.wordpress.com/2012/04/17/simulating-a-keystroke-in-win32-c-or-c-using-sendinput/#comment-4808

    参数(关键代码)取自: https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx

    我使用 Cygwin 编译代码,所以如果你想在另一台机器上运行编译后的代码,你需要在类路径上有 cygwin1.dll。

    【讨论】:

    • 感谢您记录您的解决方案。您应该使用答案左侧的“勾号”图标将您的答案标记为已接受。
    • 完成!完毕!完成!
    猜你喜欢
    • 2019-04-15
    • 2011-04-11
    • 1970-01-01
    • 2012-02-27
    • 2023-03-15
    • 1970-01-01
    • 2016-06-02
    • 2020-01-06
    • 2012-08-03
    相关资源
    最近更新 更多