Monitoring a part of the screen

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Monitoring a part of the screen

Post by Fulminare » 02 Sep 2021, 21:31

I don't know if this is the right platform to post this question, but anyway.

The specific coordinates of the screen will be entered.

Is there a way to monitor what happens in that part of the screen and send the real time output to some other application ? (I am sorry for being vague but at this point I haven't figured out which application. If anyone knows such a program please let me know.)

Regards.

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 02:54

What do you mean by "output"?

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 03 Sep 2021, 03:24

teadrinker wrote:
03 Sep 2021, 02:54
What do you mean by "output"?
Say for instance there is a video playing in the selected area

That is the output which is to be rerouted

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 07:22

Do you mean to show this video in another window on the same desktop?

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 03 Sep 2021, 07:47

Yes

Basically I want the video from zoom meeting displayed in another window

(as stated earlier , I am not aware of such a program, so I am taking it one step at a time)

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Monitoring a part of the screen

Post by boiler » 03 Sep 2021, 08:06

If you just want to monitor it but not necessarily see smooth video, you can capture an image of that area and display a thumbnail or full-size image of it. You could update it continuously as some rate, but it wouldn't be full video speed.

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 08:22

Try to run this code, activate the Zoom window, and press F1.

Code: Select all

DWM_TNP_RECTDESTINATION      := 0x00000001
DWM_TNP_SOURCECLIENTAREAONLY := 0x00000010

X := 0, Y := 0, W := 400, H := 250
Gui, New, +HwndhGui +AlwaysOnTop +Owner -DpiScale
hLib := DllCall("LoadLibrary", "Str", "Dwmapi.dll", "Ptr")
Return

$F1::
if hThumb
   DllCall("dwmapi\DwmUnregisterThumbnail", "Ptr", hThumb)
DllCall("dwmapi\DwmRegisterThumbnail", "Ptr", hGui, "Ptr", WinExist("A"), "PtrP", hThumb)
Gui, %hGui%: Show, x%X% y%Y% w%W% h%H%
VarSetCapacity(DWM_THUMBNAIL_PROPERTIES, 48, 0)
NumPut(DWM_TNP_RECTDESTINATION|DWM_TNP_SOURCECLIENTAREAONLY, DWM_THUMBNAIL_PROPERTIES)
NumPut(W, DWM_THUMBNAIL_PROPERTIES, 12)
NumPut(H, DWM_THUMBNAIL_PROPERTIES, 16)
NumPut(true, DWM_THUMBNAIL_PROPERTIES, 44, "UInt")
DllCall("dwmapi\DwmUpdateThumbnailProperties", "Ptr", hThumb, "Ptr", &DWM_THUMBNAIL_PROPERTIES)
Return

GuiClose:
   DllCall("dwmapi\DwmUnregisterThumbnail", "Ptr", hThumb)
   DllCall("FreeLibrary", "Ptr", hLib)
   ExitApp

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Monitoring a part of the screen

Post by malcev » 03 Sep 2021, 08:30

If you just want to monitor it but not necessarily see smooth video, you can capture an image of that area and display a thumbnail or full-size image of it. You could update it continuously as some rate, but it wouldn't be full video speed.
You are not right.
There are different apis that allow You to do it.

User avatar
boiler
Posts: 16931
Joined: 21 Dec 2014, 02:44

Re: Monitoring a part of the screen

Post by boiler » 03 Sep 2021, 08:49

I am right that that I can help him do what I described using screen capture techniques. I didn't say it's not possible to capture video. I said by continuously capturing screen shots, it would not be video quality. But I understand that you would rather tell people that they are wrong than have any kind of nuance in your posts. If you have techniques to help him capture video, then it would probably be better for you to tell OP how to do it rather than just tell people what they are doing is not right.

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 03 Sep 2021, 08:50

@teadrinker

WOW !

Pretty Amazing !

This is fantastic


I am sorry for asking you more questions. I usually try to tinker with the code myself, but this seems to be beyond my comprehension

How to get 2 guis that display the feed from each of the participants ?

One gui for displaying my feed

And another for the feed of the person that I am having the meeting with

I.e the gui should take the video from a part of the screen and display it

malcev
Posts: 1769
Joined: 12 Aug 2014, 12:37

Re: Monitoring a part of the screen

Post by malcev » 03 Sep 2021, 08:55

boiler, for example capturing with this api You can get +- 60 fps (as I remember)
https://docs.microsoft.com/en-us/windows/win32/api/dxgi1_2/nn-dxgi1_2-idxgioutputduplication
But topic starter does not need capturing, therefore the best variants I think with thumbnail api or magnifier api.

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 09:20

I have no Zoom to test, but I think you need something like this:

Code: Select all

Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x0 y0 w300 h300
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x0 y350 w300 h300
source1_X := 0, source1_Y := 0, source1_W := 300, source1_H := 300   ; first area in the source window
source2_X := 300, source2_Y := 0, source2_W := 300, source2_H := 300 ; second area in the source window
Return

F1::
   Loop 2 {
      i := A_Index
      Thumb%i% := new ThumbnailGui(hThumb%i%, 300, 300, WinExist("A"), source%i%_X, source%i%_Y, source%i%_W, source%i%_H, true)
   }
   Return

class ThumbnailGui
{
   __New(hWndThumb, thumbW, thumbH, hWndSource, sourceX, sourceY, sourceW, sourceH, clientOnly := false) {
      this.hLib := DllCall("LoadLibrary", "Str", "dwmapi.dll")
      if DllCall("dwmapi\DwmRegisterThumbnail", "Ptr", hWndThumb, "Ptr", hWndSource, "PtrP", hThumbnailId) != 0
         throw "DwmRegisterThumbnail failed"
      this.ThumbnailId := hThumbnailId
      this.SetSourceRegion(sourceX, sourceY, sourceW, sourceH, clientOnly)
      this.SetThumbRegion(thumbW, thumbH)
   }
   __Delete() {
      DllCall("dwmapi\DwmUnregisterThumbnail", "Ptr", this.ThumbnailId)
      DllCall("FreeLibrary", "Ptr", this.hLib)
   }
   SetSourceRegion(X, Y, W, H, clientOnly) {
      this.SetRegion(DWM_TNP_RECTSOURCE := 0x2, X, Y, W, H, clientOnly)
   }
   SetThumbRegion(W, H) {
      this.SetRegion(DWM_TNP_RECTDESTINATION := 0x1, 0, 0, W, H)
   }
   SetRegion(flag, X, Y, W, H, clientOnly := false) {
      static DWM_TNP_SOURCECLIENTAREAONLY := 0x10
           , DWM_TNP_RECTDESTINATION := 0x1
           , DWM_TNP_RECTSOURCE := 0x2
      VarSetCapacity(DWM_THUMBNAIL_PROPERTIES, 48, 0)
      flags := flag | DWM_TNP_SOURCECLIENTAREAONLY*(flag = DWM_TNP_RECTSOURCE)
      NumPut( flags     , DWM_THUMBNAIL_PROPERTIES)
      NumPut( X         , DWM_THUMBNAIL_PROPERTIES,  4 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( Y         , DWM_THUMBNAIL_PROPERTIES,  8 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( W + X     , DWM_THUMBNAIL_PROPERTIES, 12 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( H + Y     , DWM_THUMBNAIL_PROPERTIES, 16 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( clientOnly, DWM_THUMBNAIL_PROPERTIES, 44, "UInt")
      this.UpdateThumbnailProperties(&DWM_THUMBNAIL_PROPERTIES)
   }
   UpdateThumbnailProperties(pProp) {
      DllCall("dwmapi\DwmUpdateThumbnailProperties", "Ptr", this.ThumbnailId, "Ptr", pProp)
   }
}
Last edited by teadrinker on 03 Sep 2021, 10:01, edited 2 times in total.

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 03 Sep 2021, 09:38

in the 5th and the 6th lines

how to enter the coordinates of a rectangle ?

I tried using x value for the top left and Y value for the bottom right

didn't work though


it is currently showing two blank gui windows

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 09:44

source1_X — left, relative to the client area of the source window
source1_Y — top, relative to the client area of the source window
source1_W — width
source1_H — height

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 03 Sep 2021, 09:57

Some bugs fixed:

Code: Select all

Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x0 y0 w300 h300
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x0 y350 w300 h300
source1_X := 0, source1_Y := 0, source1_W := 300, source1_H := 300   ; first area in the source window
source2_X := 300, source2_Y := 0, source2_W := 300, source2_H := 300 ; second area in the source window
Return

F1::
   Loop 2 {
      i := A_Index
      Thumb%i% := new ThumbnailGui(hThumb%i%, 300, 300, WinExist("A"), source%i%_X, source%i%_Y, source%i%_W, source%i%_H, true)
   }
   Return

class ThumbnailGui
{
   __New(hWndThumb, thumbW, thumbH, hWndSource, sourceX, sourceY, sourceW, sourceH, clientOnly := false) {
      this.hLib := DllCall("LoadLibrary", "Str", "dwmapi.dll")
      if DllCall("dwmapi\DwmRegisterThumbnail", "Ptr", hWndThumb, "Ptr", hWndSource, "PtrP", hThumbnailId) != 0
         throw "DwmRegisterThumbnail failed"
      this.ThumbnailId := hThumbnailId
      this.SetSourceRegion(sourceX, sourceY, sourceW, sourceH, clientOnly)
      this.SetThumbRegion(thumbW, thumbH)
   }
   __Delete() {
      DllCall("dwmapi\DwmUnregisterThumbnail", "Ptr", this.ThumbnailId)
      DllCall("FreeLibrary", "Ptr", this.hLib)
   }
   SetSourceRegion(X, Y, W, H, clientOnly) {
      this.SetRegion(DWM_TNP_RECTSOURCE := 0x2, X, Y, W, H, clientOnly)
   }
   SetThumbRegion(W, H) {
      this.SetRegion(DWM_TNP_RECTDESTINATION := 0x1, 0, 0, W, H)
   }
   SetRegion(flag, X, Y, W, H, clientOnly := false) {
      static DWM_TNP_SOURCECLIENTAREAONLY := 0x10
           , DWM_TNP_RECTDESTINATION := 0x1
           , DWM_TNP_RECTSOURCE := 0x2
      VarSetCapacity(DWM_THUMBNAIL_PROPERTIES, 48, 0)
      flags := flag | DWM_TNP_SOURCECLIENTAREAONLY*(flag = DWM_TNP_RECTSOURCE)
      NumPut( flags     , DWM_THUMBNAIL_PROPERTIES)
      NumPut( X         , DWM_THUMBNAIL_PROPERTIES,  4 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( Y         , DWM_THUMBNAIL_PROPERTIES,  8 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( X + W     , DWM_THUMBNAIL_PROPERTIES, 12 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( Y + H     , DWM_THUMBNAIL_PROPERTIES, 16 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( clientOnly, DWM_THUMBNAIL_PROPERTIES, 44, "UInt")
      this.UpdateThumbnailProperties(&DWM_THUMBNAIL_PROPERTIES)
   }
   UpdateThumbnailProperties(pProp) {
      DllCall("dwmapi\DwmUpdateThumbnailProperties", "Ptr", this.ThumbnailId, "Ptr", pProp)
   }
}

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 05 Sep 2021, 23:50

teadrinker wrote:
03 Sep 2021, 09:44
source1_X — left, relative to the client area of the source window
source1_Y — top, relative to the client area of the source window
source1_W — width
source1_H — height
The bottom Left coordinates are : x26 y804

The top Right coordinates are : x966 y275

So is it something like this ?

Code: Select all

source1_X := 26, source1_Y := 275 source1_W := 300, source1_H := 300   ; first area in the source window

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 06 Sep 2021, 01:17

Code: Select all

; The bottom Left coordinates are : x26 y804
; The top Right coordinates are : x966 y275

source1_X := 26
source1_Y := 275
source1_W := 966 - 26  ; 940
source1_H := 804 - 275 ; 529

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 06 Sep 2021, 01:42

It is working

I have Changed the gui size to

Code: Select all

Gui, Show, x0 y350 w600 h400
I tried altering the w&h of source 1 & 2

But I am not able to get it to fill the newly sized gui

the gui has been resized, the video feed inside remains the same

teadrinker
Posts: 4326
Joined: 29 Mar 2015, 09:41
Contact:

Re: Monitoring a part of the screen

Post by teadrinker » 06 Sep 2021, 06:36

Show your code in full.

Fulminare
Posts: 369
Joined: 26 Jun 2021, 20:15

Re: Monitoring a part of the screen

Post by Fulminare » 06 Sep 2021, 08:30

Code: Select all

Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x0 y0 w600 h600
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x0 y350 w600 h600
source1_X := 20, source1_Y := 275, source1_W := 300, source1_H := 300   ; first area in the source window
source2_X := 971, source2_Y := 275, source2_W := 300, source2_H := 300 ; second area in the source window
Return

F1::
   Loop 2 {
      i := A_Index
      Thumb%i% := new ThumbnailGui(hThumb%i%, 300, 300, WinExist("A"), source%i%_X, source%i%_Y, source%i%_W, source%i%_H, true)
   }
   Return

class ThumbnailGui
{
   __New(hWndThumb, thumbW, thumbH, hWndSource, sourceX, sourceY, sourceW, sourceH, clientOnly := false) {
      this.hLib := DllCall("LoadLibrary", "Str", "dwmapi.dll")
      if DllCall("dwmapi\DwmRegisterThumbnail", "Ptr", hWndThumb, "Ptr", hWndSource, "PtrP", hThumbnailId) != 0
         throw "DwmRegisterThumbnail failed"
      this.ThumbnailId := hThumbnailId
      this.SetSourceRegion(sourceX, sourceY, sourceW, sourceH, clientOnly)
      this.SetThumbRegion(thumbW, thumbH)
   }
   __Delete() {
      DllCall("dwmapi\DwmUnregisterThumbnail", "Ptr", this.ThumbnailId)
      DllCall("FreeLibrary", "Ptr", this.hLib)
   }
   SetSourceRegion(X, Y, W, H, clientOnly) {
      this.SetRegion(DWM_TNP_RECTSOURCE := 0x2, X, Y, W, H, clientOnly)
   }
   SetThumbRegion(W, H) {
      this.SetRegion(DWM_TNP_RECTDESTINATION := 0x1, 0, 0, W, H)
   }
   SetRegion(flag, X, Y, W, H, clientOnly := false) {
      static DWM_TNP_SOURCECLIENTAREAONLY := 0x10
           , DWM_TNP_RECTDESTINATION := 0x1
           , DWM_TNP_RECTSOURCE := 0x2
      VarSetCapacity(DWM_THUMBNAIL_PROPERTIES, 48, 0)
      flags := flag | DWM_TNP_SOURCECLIENTAREAONLY*(flag = DWM_TNP_RECTSOURCE)
      NumPut( flags     , DWM_THUMBNAIL_PROPERTIES)
      NumPut( X         , DWM_THUMBNAIL_PROPERTIES,  4 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( Y         , DWM_THUMBNAIL_PROPERTIES,  8 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( W + X     , DWM_THUMBNAIL_PROPERTIES, 12 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( H + Y     , DWM_THUMBNAIL_PROPERTIES, 16 + 16*(flag = DWM_TNP_RECTSOURCE) )
      NumPut( clientOnly, DWM_THUMBNAIL_PROPERTIES, 44, "UInt")
      this.UpdateThumbnailProperties(&DWM_THUMBNAIL_PROPERTIES)
   }
   UpdateThumbnailProperties(pProp) {
      DllCall("dwmapi\DwmUpdateThumbnailProperties", "Ptr", this.ThumbnailId, "Ptr", pProp)
   }
}

Post Reply

Return to “Ask for Help (v1)”