Search code examples
pythonwindowswindows-7pywin32

Pywin32 SendKeys: "Windows button" keypress


I'm trying to use Python to lock my computer. The only way I know to do this via keystrokes is by holding down the "Windows button" and pressing the "L" key. However, I can't figure out how to do this with Pywin32.

I found an extensive list of Pywin32's available keys: http://win32com.goermezer.de/content/view/136/254/ (But it doesn't include the "Windows button," so I'm still stuck.)

Any suggestions?


Solution

  • From Tim Golden's pages:

    import ctypes
    ctypes.windll.user32.LockWorkStation()