13

I was searching for a Python piece of code which would simulate keystrokes. I stumble upon something using win32com.client.Dispatch("WScript.Shell"). I am not fan (at all) of Windows but it is to help a friend with automation of a game.

I got a problem, this works fine on notepad or firefox for example, it does write but not on his game. In order to find wether it comes from his game or my automation I would like to have some details about win32com.client and what really represents WScript.Shell

Thank you all

1
  • have you tried autoit?
    – Oliver
    May 7, 2014 at 17:47

1 Answer 1

21

Some citations:

As we discussed previously, automation objects are COM objects that expose methods and properties using the IDispatch interface. So how do we use these objects from Python? The win32com.client package contains a number of modules to provide access to automation objects. This package supports both late and early bindings, as we will discuss.

To use an IDispatch-based COM object, use the method win32com.client.Dispatch(). This method takes as its first parameter the ProgID or CLSID of the object you wish to create. If you read the documentation for Microsoft Excel, you'll find the ProgID for Excel is Excel.Application, so to create an object that interfaces to Excel, use the following code:

import win32com.client
xl = win32com.client.Dispatch("Excel.Application")

(from this)

The WScript.Shell object provides functions to read system information and environment variables, work with the registry and manage shortcuts. (from: 1 2)

1
  • 1
    Fixed your link but if you could find an o reilly one would be best Feb 21, 2017 at 16:55

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.