Send key combination with python

2024/9/30 23:25:37

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

Answer

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://en.xdnf.cn/q/71032.html

Related Q&A

Taking data from drop-down menu using flask

Im completely new to flask, and really am completely lost with how to approach this. Ive looked into other SO questions but I cant seem to get this working regardless. I have a form as such: <form…

How to get list_blobs to behave like gsutil

I would like to only get the first level of a fake folder structure on GCS.If I run e.g.:gsutil ls gs://gcp-public-data-sentinel-2/tiles/I get a list like this:gs://gcp-public-data-sentinel-2/tiles/01/…

How to avoid gcc warning in Python C extension when using Py_BEGIN_ALLOW_THREADS

The simplest way to manipulate the GIL in Python C extensions is to use the macros provided:my_awesome_C_function() {blah;Py_BEGIN_ALLOW_THREADS// do stuff that doesnt need the GILif (should_i_call_ba…

Pairwise operations (distance) on two lists in numpy

I have two lists of coordinates:l1 = [[x,y,z],[x,y,z],[x,y,z],[x,y,z],[x,y,z]] l2 = [[x,y,z],[x,y,z],[x,y,z]]I want to find the shortest pairwise distance between l1 and l2. Distance between two coordi…

Bad results when undistorting points using OpenCV in Python

Im having trouble undistorting points on an image taken with a calibrated camera using the Python bindings for OpenCV. The undistorted points have entirely different coordinates than the original point…

Pandas - Groupby and create new DataFrame?

This is my situation - In[1]: data Out[1]: Item Type 0 Orange Edible, Fruit 1 Banana Edible, Fruit 2 Tomato Edible, Vegetable 3 Laptop Non Edible, Elec…

Can pytest fixtures and confest.py modules be shared across packages?

Suppose I have packageA which provides a class usefulClass, pytest fixtures in a test_stuff.py module, and test configurations in a conftest.py module. Moreover, suppose that I have packageBand package…

Sort a list by presence of items in another list

Suppose I have two lists:a = [30, 10, 90, 1111, 17] b = [60, 1201, 30, 17, 900]How would you sort this most efficiently, such that:list b is sorted with respect to a. Unique elements in b should be pla…

Sample from a multivariate t distribution python

I am wondering if there is a function for sampling from a multivariate student t-distribution in Python. I have the mean vector with 14 elements, the 14x14 covariance matrix and the degrees of freedom …

Why is this Jinja nl2br filter escaping brs but not ps?

I am attempting to implement this Jinja nl2br filter. It is working correctly except that the <br>s it adds are being escaped. This is weird to me because the <p>s are not being escaped and…