win32com.client.Dispatch(“WScript.Shell”)到底是什么?

2024-05-16 12:33:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我在寻找一段模拟击键的Python代码。 我偶然发现了一些使用win32com.client.Dispatch("WScript.Shell")的东西。 我一点也不喜欢Windows,但它是为了帮助一个朋友实现游戏的自动化。

我遇到了一个问题,这个在记事本或者火狐上很好用,比如,它确实写了,但在他的游戏上没有。 为了找出它是来自他的游戏还是我的自动化,我想了解一些关于win32com.client的细节,以及什么才是真正的WScript.Shell

谢谢大家


Tags: 代码client游戏windows朋友shell细节win32com
1条回答
网友
1楼 · 发布于 2024-05-16 12:33:13

一些引用:

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

(来自this

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

相关问题 更多 >