Send key combination with python

2020-06-21 07:01发布

问题:

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". ...