3 Replies Latest reply on Jul 27, 2006 10:36 AM by Applied CD

    Which monitor am I on?

    Applied CD Level 1
      A while back I wrote a behavior to zoom video to full screen and used _system.deskTopRectList[1] as the target. I’ve got a chance to revisit this behavior and I would like to make it a little smarter and zoom to _system.deskTopRectList[x] where x is the deskTopRect that either contains the stage center or contains the greatest stage area (which ever is the standard window behavior). If the script uses the stage center it will have to deal with cases where the stage center may be off screen. Has anyone already gone through the hassle of writing something like this?
        • 1. Re: Which monitor am I on?
          Level 7
          I have used Buddy API in the past to do this (of course!). Take a look
          at baMultiDisplayInfo() - it will tell you which monitor the user has
          configured as their "primary"
          • 2. Re: Which monitor am I on?
            Applied CD Level 1
            Thanks Sean, baMultiDisplayInfo is new and somehow I missed the update to one of the most useful xtras out there.

            I’m not sure it solves the problem though. Maximizing to the primary monitor is easy, _system.deskTopRectList[1] will give you the proper rect and I guess you could extract the same info from baMultiDisplayInfo. The bigger challenge is to simulate the behavior of the maximize box in the window titlebar, to do this you need to maximize to the “closest” monitor, not necessarily the primary monitor. I thought I would be cleaver and use _movie.stage.maximize() rather than _movie.stage.rect =_system.deskTopRectList[1] to get the stage full screen but to my surprise, _movie.stage.maximize() does not simulate the titlebar box, it always goes for the primary, what’s up with that?!? ;-) … Anyway, I’m sure there’s a way to cycle through the deskTopRectList and assemble some representation of the patchwork of display rectangles, gaps and all, then try to figure out where the stage is among them but I’m not sure it’s worth the effort. Every example I’ve seen simply targets the primary and I guess that’s good enough.
            • 3. Re: Which monitor am I on?
              Applied CD Level 1
              Using the area method wasn’t that tough. The following function will return the index to _system.deskTopRectList containing the greatest amount of projector stage:

              on findMonitor
              myAreaList = []
              repeat with myRect in _system.deskTopRectList
              myIntersectRect = myRect.intersect(_movie.stage.rect)
              myArea = (myIntersectRect.right - myIntersectRect.left) * (myIntersectRect.bottom - myIntersectRect.top)
              myAreaList.append(myArea)
              end repeat
              myMonitor = myAreaList.getOne(myAreaList.max())
              return myMonitor
              end

              So for example, if 30% of your stage is on monitor 1, 45% is on monitor 2, and 25% is off screen, this function will return 2. In most cases users will have the window positioned entirely on one monitor, so if 100% of the stage is on monitor 3, this function will return 3. I don’t know what would happen if you called this function with the projector minimized (that can’t happen with the way my project is set up) but I suspect the function will simply return 0. It may not work exactly like the window titlebar maximize box but it’s better than always using _system.deskTopRectList[1]