我不知道这是否可行。我正在使用Excel并使用VB脚本。有没有办法检测是否同时按下两个键以及它们是哪个?然后,如果是那些被按下的键,我可以使用If / Then语句来做我需要做的任何过程吗?
我知道如果我有类似组合框的东西我可以使用keydown功能来检测按下的单个按键,但这只能用于一个按键,而不能用于两个按键。另外,我没有使用组合框,文本框或其他任何东西。我严格使用单元格,因此即使按下单个键也没有像keydown那样的东西。
同样,我需要它同时检测两个键被按下。我也想以某种方式让它在工作簿级别检测到这一点,而不是每个单独的工作表,因为有几个工作表,并希望这些按下的键从一个工作表到下一个工作表。
如果可能,请告诉我,但我觉得这是不可能的。
答案 0 :(得分:2)
道格
感谢你的建议,我想出了一切。在这里,如果其他人发现这有用:
Private Sub Workbook_Activate() 'When the workbook is active this will run the script in the place of the standard Ctrl + C. Application.onkey "^{c}", "ThisWorkbook.cCopy" End Sub Private Sub Workbook_Deactivate() 'When another workbook is active this will disable this script so the standard Ctrl + C will work again. Application.onkey "^{c}" End Sub Sub cCopy() 'This is the script to run when active. This was used for testing purposes only. Worksheets("Sites").Range("I1").Value2 = "Yes" End Sub