Board logo

标题: [问题求助] VBS中如何模拟出Ctrl+Alt+P [打印本页]

作者: ZZMRSY    时间: 2022-5-15 04:47     标题: VBS中如何模拟出Ctrl+Alt+P

set WshShell = WScript.CreateObject("WScript.Shell")
WScript.Sleep 2000

' 尝试了多种方法,有

' WshShell.SendKeys "^%P"
' WshShell.SendKeys "^%{P}"
' WshShell.SendKeys ("^%{P}")
' WshShell.SendKeys "(^%P)"
' WshShell.SendKeys "^(%P)"
' WshShell.SendKeys "^(%(P))"
' WshShell.SendKeys "(^(%(P)))"

但是发现系统在模拟时总是会自动的加上一个Shift,变成Ctrl+Alt+Shift+P,激发不了原先的热键,有点尴尬。
是我的电脑有问题吗?还是我哪里写错了。请高手们指导。
作者: flashercs    时间: 2022-5-15 09:56

  1. WshShell.SendKeys "^%P"
复制代码
加shift 有可能是键盘shift 卡住了,或者锁定了Capslock
作者: ZZMRSY    时间: 2022-5-15 15:57

回复 2# flashercs


    您试过这样写可以激发对应的快捷键吗?我的电脑没有出现那两个问题,但是我这边用这种写法和其他几种写法,系统按键都模拟的是Ctrl+Alt +Shift+P。没有激发原来的快捷键,真是怪事情。
作者: czjt1234    时间: 2022-10-18 17:16

闲来无事,瞎猫碰到死耗子

oWshShell.SendKeys "(^%i)"     'ctlr + alt + i
oWshShell.SendKeys "(^%I)"     'ctlr + alt + shift + i
作者: ZZMRSY    时间: 2022-11-21 21:10

回复 4# czjt1234


    哈哈,原来是我不该把p大写的。看了你的答案才知道,多谢。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2