No internet connection
  1. Home
  2. How to

Toggle Video screen size

By Mike Wax @mikewax
    2023-01-12 03:03:21.613Z

    I'm trying to toggle between the Video screen size. So first it should make the Video Fullscreen, then if that's checked, then make the Video Half Size, and vice versa.

    I'm having a hard time since it seems like the Video right-click menu is not accessible. I was able to active Fullscreen, but no idea how to toggle/check if it's checked, etc.

    Here's where I'm at so far.
    Thank you for the help!!!

    sf.ui.proTools.appActivate();
    
    const videoWin = sf.ui.app("com.avid.AvidVideoEngine").windows.whoseTitle.is(" ");
    
    // If the Video window is not open, open it.
    if (!videoWin.first.exists) {
        sf.ui.proTools.menuClick({
            menuPath: ["Window", "Video"]
        });
    
        sf.wait({ intervalMs: 1000 });
    }
    
    sf.ui.app("com.avid.AvidVideoEngine").windows.whoseTitle.is(" ").first.mouseClickElement({
        isRightClick: true,
        relativePosition: { x: 500, y: 200 }
    });
    
    sf.keyboard.press({
        keys: "down",
        repetitions: 4
    });
    
    sf.keyboard.press({
        keys: "return"
    });
    
    • 2 replies
    1. Kitch Membery @Kitch2023-01-13 21:23:12.809Z

      Hi Mike,

      Yeah, the Menu is not accessible by SoundFlow unfortunately, so try this workaround.

      sf.ui.proTools.appActivate();
      
      const avidVideoEngine = sf.ui.app('com.avid.AvidVideoEngine');
      let videoWindow = avidVideoEngine.invalidate().windows.first;
      
      // If the Video window is not open, open it.
      if (!videoWindow.exists) {
          sf.ui.proTools.menuClick({
              menuPath: ["Window", "Video"]
          });
      
          videoWindow.elementWaitFor();
      }
      
      let videoFrame = videoWindow.invalidate().frame;
      let screenFrame = sf.ui.screens.mainScreen.invalidate().frame;
      const headerHeight = 38;
      let isFullscreen = videoFrame.w === screenFrame.w && videoFrame.h === screenFrame.h - headerHeight;
      const menuClickOffset = 100
      
      
      if (isFullscreen) {
          videoWindow.mouseClickElement({
              isRightClick: true,
              relativePosition: { x: menuClickOffset, y: menuClickOffset, },
          });
      
          //Click the Position of the "Half Size" menu Item 
          videoWindow.mouseClickElement({
              relativePosition: { x: menuClickOffset + 33, y: menuClickOffset + 33, },
          });
      } else {
          videoWindow.mouseClickElement({
              isRightClick: true,
              relativePosition: { x: menuClickOffset, y: menuClickOffset, },
          });
      
          //Click Position of the "Fullscreen" menu item.
          videoWindow.mouseClickElement({
              relativePosition: { x: menuClickOffset + 20, y: menuClickOffset + 90, },
          });
      }
      

      Let me know how it goes, there may be some adjustments that need to be done.

      1. Mike Wax @mikewax
          2023-01-14 01:59:17.289Z

          Hey @Kitch,

          Looks like this gets me to Fullscreen, but doesn't allow me to toggle between two different modes.

          I found this from a post (i forget who posted it) and this seems to work by adding in the globalState

          
          const videoWin = sf.ui.app("com.avid.AvidVideoEngine").windows.whoseTitle.is(" ");
          
          // If the Video window is not open, open it.
          if (!videoWin.first.exists) {
              sf.ui.proTools.menuClick({
                  menuPath: ["Window", "Video"]
              });
          
              sf.wait({ intervalMs: 1000 });
          }
          
          sf.ui.app('com.avid.AvidVideoEngine').windows.whoseTitle.is(' ').first.popupMenuOpenFromElement({
              relativePosition: { "x": 5, "y": 26 },
              isRightClick: true,
              timeout: 1,
              onError: "Continue"
          });
          
          globalState.state = !globalState.state
          
          if (globalState.state) {
              sf.keyboard.press({
                  keys: "down",
                  repetitions: 4,
                  fast: true
              });
          
              sf.keyboard.press({
                  keys: "return",
                  fast: true
              });
          } else {
              sf.keyboard.press({
                  keys: "down, down, return",
                  fast: true
              });
          }
          

          Thank you so much for your help!!