1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Zoomミーティングのチャットにプログラムで投稿するまでの苦悩

Posted at

はじめに

『ミーティングチャットに、プログラムで投稿したい!』

Zoomミーティング中に、チャットへ自動でメッセージを送信したくなりました。最初はZoomの公式APIがあると思い、調査を開始しました。

Zoom APIを調べた結果・・・

Zoomには豊富なAPIが提供されていますが、意外にも 「ミーティングチャットに直接投稿するAPI」 は存在しませんでした。Webhookを使い、ミーティングチャットを外部に送信することは可能ですが、外部からチャットを書き込む機能は提供されていません。Zoom APIを利用したアプローチは断念。別の方法を探すことにしました。

ZoomのAPIドキュメントは以下から確認できます。

AppleScript(osascript)を使おう!

macOSではGUI操作を自動化できるAppleScriptが使えます。これをうまく活用すれば、Zoomのチャット欄にメッセージを送信できるはず!?

AppleScriptとは?

AppleScriptは、macOSのアプリケーションを自動操作するためのスクリプト言語です。osascriptコマンドは、ターミナルや他のプログラムから実行できます。

Zoomミーティングのチャットエリアを特定する

ZoomのUI構造を確認し、チャット欄の要素を特定します。

UI構造を特定するコマンド

以下のコマンドでZoomウィンドウのUI構造を確認できます。

osascript -e 'tell application "System Events" to tell process "zoom.us" to return entire contents of front window'

コマンド実行結果

実行すると、Zoomミーティングウィンドウの構造が以下のように表示されます。

tab group 1 of window Zoom ミーティング of application process zoom.us, image 1 of tab group 1 of window Zoom ミーティング of application process zoom.us, image 2 of tab group 1 of window Zoom ミーティング of application process zoom.us, static text XXXXXX of tab group 1 of window Zoom ミーティング of application process zoom.us, splitter group 1 of window Zoom ミーティング of application process zoom.us, scroll area 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, table 1 of scroll area 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, splitter 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, UI element 1 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, static text 宛先: of UI element 1 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, UI element 2 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, static text 全員 of UI element 2 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, scroll area 1 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, UI element ファイルと画像のインプット エリア of scroll area 1 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, scroll area 2 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, text area 1 of scroll area 2 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 1 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 2 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 3 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 4 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 5 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, button 6 of group 1 of splitter group 1 of window Zoom ミーティング of application process zoom.us, UI element 3 of window Zoom ミーティング of application process zoom.us, button 閉じる of UI element 3 of window Zoom ミーティング of application process zoom.us, button ポップアウト of UI element 3 of window Zoom ミーティング of application process zoom.us, static text XXXXXXのZoomミーティング of UI element 3 of window Zoom ミーティング of application process zoom.us, button 3 of UI element 3 of window Zoom ミーティング of application process zoom.us, splitter 1 of window Zoom ミーティング of application process zoom.us, button 1 of window Zoom ミーティング of application process zoom.us, button 2 of window Zoom ミーティング of application process zoom.us, button 3 of window Zoom ミーティング of application process zoom.us, group 1 of button 3 of window Zoom ミーティング of application process zoom.us

これでは、どこがチャットを送信するエリアであるかわかりません・・・

特定方法

一生懸命、細かく読み解きました・・・

特定結果

そして、辿り着いた結果がこれ!

window "Zoom ミーティング"
  └─ splitter group 1
       └─ group 1
            └─ scroll area 2
                 └─ text area 1

この情報を基に、Zoomミーティングのチャットにメッセージを入力し、Enterキーで送信するAppleScriptを作成しました。

Zoomミーティングのチャットに投稿するプログラム

以下が完成したコードです。これを実行することで、Zoomミーティングのチャットに自動でメッセージを送信できます。

const { exec } = require('child_process');

// 送信したいメッセージ
const message = "こんにちは、これはプログラムから書き込んでいます!";

// AppleScriptを実行
exec(`osascript -e 'tell application "System Events"
  tell process "zoom.us"
    set frontmost to true
    delay 0.5
    tell text area 1 of scroll area 2 of group 1 of splitter group 1 of window "Zoom ミーティング"
      set value to "${message}"
      key code 36 -- Enterキーで送信
    end tell
  end tell
end tell'`, (error) => {
  if (error) {
    console.error(`エラー: ${error.message}`);
  } else {
    console.log(`メッセージを送信しました: ${message}`);
  }
});

実行手順

1. Node.jsがインストールされていることを確認

node -v

2. 以下のコマンドを実行

node zoomChat.js

注意事項

  • Zoomミーティングが開かれていること
  • Zoomミーティングで、チャットが表示されていること
  • アクセシビリティ権限を許可していること
    「システム設定」→「プライバシーとセキュリティ」→「アクセシビリティ」で、このプログラムを実行するアプリケーション(ターミナル、VSCode等)の制御の許可をしてください。

実行結果

このように、Zoomミーティングのチャットに書き込むことができました!

スクリーンショット 2025-03-28 21.17.17.png

まとめ

Zoom APIでは実現できなかったチャットへの自動投稿を、AppleScriptを使い実現しました。

ZoomのUIはバージョンアップにより変更される可能性があるため、動作しなくなった場合は、再度UI構造を確認することをお勧めします。

この方法を使えば、Zoomミーティング中にプログラムから自動投稿を行うことが可能です。

1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?