SHOW:
|
|
- or go back to the newest paste.
1 | - | #I now have it where I can use the Windows key, except it doesn't work in combination with letters (but it does work #with the other keys like the "right arrow"). |
1 | + | '''I now have it where I can use the Windows key, except it doesn't work in combination with letters (but it does work with the other keys like the "right arrow").''' |
2 | ||
3 | import win32com.client as comclt | |
4 | from win32api import * | |
5 | from win32con import * | |
6 | ||
7 | def SendKeys(string): | |
8 | wsh= comclt.Dispatch("WScript.Shell") | |
9 | if "{WIN}" in string: | |
10 | keybd_event(VK_LWIN,0,KEYEVENTF_EXTENDEDKEY, 0) | |
11 | nonWin = string[string.index("{WIN}")+len("{WIN}"):] | |
12 | wsh.SendKeys(nonWin) | |
13 | keybd_event(VK_LWIN,0,KEYEVENTF_KEYUP,0) | |
14 | else: | |
15 | wsh.SendKeys(string) | |
16 | return | |
17 | ||
18 | #For example, calling: | |
19 | ||
20 | SendKeys("{WIN}{RIGHT}") | |
21 | ||
22 | #will snap the current window to the right. |