Jump to content

Recommended Posts

Posted (edited)

I see that there is not a lot of forum activity surrounding AutoIT automation of how ZOOM meetings work?  Is this not allowed or something?

The problem I am trying to address involves piano lessons on ZOOM.  I have a tablet on the music stand of the piano.  As we all know, tablets have both front facing and rear facing cameras but often, the piano teacher needs an overhead shot to see the fingering.

So, I connected an external usb camera above.  All works great except for the fact that it is cumbersome changing cameras from the touch screen because the button is so small.  Also, right next to the small button is the "stop video" button and that frequently gets pressed by accident and that shuts down all cameras.

The bottom line is that, if you are paying by the minute for a piano lesson, you don't want to be wasting time wrestling with technical issues.

So, I wrote a script to do this.  I created a simple GUI with just a button that will find/start the ZOOM Meeting window and issue {ALTDOWN}N{ALTUP}.  this is the sequence to cycle through the camera.  It is a clumsy solution but it works.

For what it is worth, here is the ugliest code I have ever written ;) enjoy!

#Tidy_ILC_Pos=81 ; keep "most" inline comments at 80 columns
#Region ;**** Directives needed by AUT2EXE ****
#AutoIt3Wrapper_Run_Tidy=Y ; run tidy before compile/build
#AutoIt3Wrapper_outfile=%scriptdir%\temp.exe ; build temp exe first
#AutoIt3Wrapper_Icon=allSongs.ico ; include this icon
#AutoIt3Wrapper_Run_Before=del "%out%" ; delete temp exe
#AutoIt3Wrapper_Run_After=move/y "%out%" "%scriptdir%\%scriptfile%.exe" ; move temp exe to real exe
#EndRegion ;**** Directives needed by AUT2EXE ****


#include-once
#include <WindowsConstants.au3>
#include "ColorConstants.au3"

$size = 50
$hZoom = 0

; look for ZOOM or find it already running
$prc = 0
$pid = 0
While $prc + $pid = 0
    $winList = ProcessList("zoom.exe")
    For $i = 1 To $winList[0][0]
        $prc = $winList[$i][0]
        $pid = $winList[$i][1]
    Next
    If $prc + $pid = 0 Then
        Run(@AppDataDir & '\Zoom\bin\Zoom.exe')
        Sleep(1000)
    EndIf
WEnd

$winList = WinList('Zoom')
If $winList[0][0] = 0 Then
    MsgBox(0, 'error', 'error')
    Exit
EndIf
For $i = 1 To $winList[0][0]
    WinActivate($winList[$i][1])
Next

; Create simplest GUI ever
Local $hGUI = GUICreate("ZSC", $size, $size, $size, $size*10, $WS_popup, $WS_EX_TOPMOST)
Local $button = GUICtrlCreateButton("", 0, 0, $size, $size)
GUICtrlSetBkColor(-1, $COLOR_Red)
GUISetState(@SW_SHOW, $hGUI) ; Display the GUI.

; Loop until ZOOM is closed.
While ProcessExists($pid)
    Switch GUIGetMsg()
        Case $button
            For $i = 1 To $winList[0][0]
                WinActivate($winList[$i][1])
            Next
            Send("{ALTDOWN}N{ALTUP}") ; Command + Shift + N: Switch camera
    EndSwitch
WEnd

; Delete the previous GUI and all controls.
GUIDelete($hGUI)

Exit

 

Edited by jaja714
Posted

I'm curious to see if anyone is aware of better ways to do this.  The improvements I am seeking are as follows:

  • Each ZOOM Meeting has multiple window handles.  I was hoping someone on the forum would've tackled the best way to identify the correct one so the GUI could aim the keystrokes better.
  • The rear facing camera is completely unneeded.  I was hoping to use the AU3 Window Info tool but, as is the case with most software, the ZOOM developers seems to have purposely hidden the controls.  I was again hoping someone on the forums would have already tackled that as well.
  • 9 months later...
Posted (edited)

Somewhat old but maybe still of interest.

As I am regularly using Zoom for meetings I needed a possibility to check if Zoom is running and has just been exited in order to know when to run some post meeting tools.

Local $ignoredZoomNames[] = [ _
    "zoom_acc_notify_wnd", _
    "zoom_pt_notification_app_bar_wnd", _
    "ZPPTMainFrmWndClassEx", _
    "ZPToolBarParentWndClass" _
]
Local $searchedForZoomNames[] = [ _
    "VideoFrameWndClass", _
    "ZPContentViewWndClass" _
]
Local $allZoomWinNames[0]

Func IsZoomActive()
    Local $zoomWinNames[0]
    Local $processList = ProcessList()
    for $i = 1 to UBound($processList) - 1
        if $processList[$i][0] <> "Zoom.exe" then _
            ContinueLoop

        Local $winList = _WinAPI_EnumProcessWindows($processList[$i][1], 1)
        Local $winNames = _ArrayExtract($winList, 1, -1, 1)

        for $j = 1 to UBound($winNames)
            Local $winName = $winNames[$j - 1]
            if $winName = "-1" then _
                ContinueLoop

            if _ArraySearch($ignoredZoomNames, $winName) <> -1 then _
                ContinueLoop

            _ArrayAdd($zoomWinNames, $winName)
        Next
    Next

    if UBound($zoomWinNames) == 0 then _
        return false

    for $i = 1 to UBound($zoomWinNames)
        Local $winName = $zoomWinNames[$i - 1]
        if _ArraySearch($allZoomWinNames, $winName) <> -1 then _
            ContinueLoop

        _ArrayAdd($allZoomWinNames, $winName)
    Next

    Local $zoomWinString = _ArrayToString($zoomWinNames, "")
    Local $pattern = '(' & _ArrayToString($searchedForZoomNames) & ')'
    Local $result = StringRegExp($zoomWinString, $pattern, 1)

    return @error == 0
EndFunc

You could use this snipplet to record all new window names while you are using zoom (they get stored in $allZoomWinNames)

This may be useful in order to identify the one you need to send your keystrokes to.

Edited by moldevort

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...