Send key combination with python

末鹿安然 提交于 2019-12-05 01:44:05

问题


I want to be able to send the key combination SHIFT + CTRL + . (dot) using the following code:

import win32com.client as comclt
wsh= comclt.Dispatch("WScript.Shell")
wsh.SendKeys() 

So far I was able to send CTRL + . (dot) like this :

wsh.SendKeys(^.) 

How do I add the SHIFT key there ?

Thanks to anyone who answers :)


回答1:


For Shift use +

Complete list is available here: SendKeys

... To specify that a combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, create a compound string argument with the modified keystrokes enclosed in parentheses. For example, to send the keystroke combination that specifies that the SHIFT key is held down while:

  • e and c are pressed, send the string argument "+(ec)".
  • e is pressed, followed by a lone c (with no SHIFT), send the string argument "+ec". ...


来源:https://stackoverflow.com/questions/21549847/send-key-combination-with-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!