0
1

PythonでVBScriptのCreateObjectしてみる

Last updated at Posted at 2023-12-23

PythonからCreateObjectできる環境を作る

VBScirptが非推奨になったのでPythonからCreateObjectできるのかを試してみた。

方法

pywin32ライブラリをインストールすれば使える。

試してみたこと

windowsの読み上げオブジェクトを使ってみた

環境作成

pip install pywin32

プログラム

# Windowsのcomオブジェクトを使うライブラリをインポート
import win32com.client as wc

# CreateObjectに該当する部分
spk=wc.Dispatch("SAPI.SpVoice")

# Speakメソッドを呼び出す(喋らせる)
spk.Speak("こんにちわ、パイソンで喋ってます。")

応用

VBScriptでCreateObjectしていたものはたいていこの方法でPythonから呼び出せるはず・・・
しらんけど・・・

以上

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1