Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send key combination with python

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 :)

like image 666
Shady Programmer Avatar asked Feb 04 '14 10:02

Shady Programmer


People also ask

How do you press a key combination in Python?

This method also allows us to press a key while holding another key, for example, ctrl+c to copy. To do this we will need to press ctrl, press and release c and then release ctrl.


1 Answers

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". ...
like image 94
Chandan Avatar answered Sep 23 '22 01:09

Chandan