Monitoring a part of the screen
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
Must be Thumb%i% := new ThumbnailGui(hThumb%i%, 600, 600, WinExist("A"), source%i%_X, source%i%_Y, source%i%_W, source%i%_H, true)
Re: Monitoring a part of the screen
Yes the video now occupies the entire gui
I made some mistake in entering the coordinates hence its not showing the video itself properly
but it is working
I made some mistake in entering the coordinates hence its not showing the video itself properly
but it is working
Re: Monitoring a part of the screen
Okay, a new complication
I have adjusted the coordinates, w&h e.t.c and its working well
Now I have this gui showing the video feed in place of the native zoom application's.
The Guis are positioned in a "top & bottom" layout.
Along with these guis, the zoom video feed is also displayed (naturally)
This is a distracting factor. To eliminate that, I made the following Gui that shows a black rectangle in the place of the zoom's video feed
The problem is, on pressing "F1" the "Video feed monitoring" Gui is showing this black rectangle as it is comes in the way of the video shown in zoom.
if there a way to make the "Video feed monitoring" Gui show what's beneath the "black rectangle" gui ?
I have adjusted the coordinates, w&h e.t.c and its working well
Now I have this gui showing the video feed in place of the native zoom application's.
The Guis are positioned in a "top & bottom" layout.
Along with these guis, the zoom video feed is also displayed (naturally)
This is a distracting factor. To eliminate that, I made the following Gui that shows a black rectangle in the place of the zoom's video feed
Code: Select all
^b::
#SingleInstance, Force
Gui, Info:+ToolWindow -SysMenu -Caption ; +AlwaysOnTop
Gui, Info:Add, Progress, x0 y275 w1980 h535 BackgroundBlack ; Black
Gui, Info:Font, cFF0000 s12 , verdana ;red
Gui, Info:Color, CCCCCC
Gui, Info:Show, NoActivate x10 y-09, uptime ; screen position here
WinSet, TransColor, CCCCCC 255, uptime
Gui, Info:Show
Return
Esc::ExitApp
if there a way to make the "Video feed monitoring" Gui show what's beneath the "black rectangle" gui ?
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
The Gui shows exactly what is being rendered in the source window. I have no Zoom, but I tried Windows Media Player as the source window. If the Media Player window is overlapped with another, the Gui continues to display the video. If your Gui shows the black rectangle, it means, that Zoom stops rendering when overlapped.
Re: Monitoring a part of the screen
Is there no solution for this ?
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
No idea.
Re: Monitoring a part of the screen
Just for updating you, these are my observations,
1. BLACK BAR GUI
running your script before the black bar gui script is not blocking the video feed shown in your gui.
i.e
run your script,
open zoom (that is already running and has both the participants)
press "F1"
- (the video from zoom is now shown in your gui)
next
run the black bar gui
open zoom
press the hotkey for the said gui ( which is ctrl b )
- (a black rectangle is shown in place of the zoom video)
but the video feed shown in your gui doesn't show the black rectangle.
2.
Returning to the desktop while the feed in your gui is on, freezes it.
That's not happening when chrome is opened
i.e the video feed in the gui runs as usual
1. BLACK BAR GUI
running your script before the black bar gui script is not blocking the video feed shown in your gui.
i.e
run your script,
open zoom (that is already running and has both the participants)
press "F1"
- (the video from zoom is now shown in your gui)
next
run the black bar gui
open zoom
press the hotkey for the said gui ( which is ctrl b )
- (a black rectangle is shown in place of the zoom video)
but the video feed shown in your gui doesn't show the black rectangle.
2.
Returning to the desktop while the feed in your gui is on, freezes it.
That's not happening when chrome is opened
i.e the video feed in the gui runs as usual
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
When you press F1 the hWnd of the Zoom window must be passed as the fourth parameter here
Code: Select all
Thumb%i% := new ThumbnailGui(hThumb%i%, 400, 300, WinExist("A"), source%i%_X, source%i%_Y, source%i%_W, source%i%_H, true)
I don't quite understand, what you mean by «Returning to the desktop». Anyway, I've not encountered such behavior.
Re: Monitoring a part of the screen
I didn't understand this
What I meant was, on opening the desktop ( Windows + D ) the gui video feed gets frozen
But that doesn't happen when chrome is opened
Gui video feed on - open desktop - gui video feed freezes
Gui video feed on - open chrome - gui video feed is normal
When you press F1 the hWnd of the Zoom window must be passed as the fourth parameter here
What I meant was, on opening the desktop ( Windows + D ) the gui video feed gets frozen
I don't quite understand, what you mean by «Returning to the desktop». Anyway, I've not encountered such behavior.
But that doesn't happen when chrome is opened
Gui video feed on - open desktop - gui video feed freezes
Gui video feed on - open chrome - gui video feed is normal
Re: Monitoring a part of the screen
Also, I tried pasting this code into a main script that I have.
My script basically opens zoom , copies the link , sends it to a contact in Whatsapp and return to zoom
on returning to zoom, the two blank guis were shown, but pressing F1 didn't display the feed from zoom into the gui.
Instead it showed the following error message
" Error: DwmRegisterThumbnail failed
My script basically opens zoom , copies the link , sends it to a contact in Whatsapp and return to zoom
on returning to zoom, the two blank guis were shown, but pressing F1 didn't display the feed from zoom into the gui.
Instead it showed the following error message
" Error: DwmRegisterThumbnail failed
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
You can find out what you need here: WinExist()
Video freezes not because you open the desktop, but because the Zoom window gets minimized, and stops rendering.
What exactly did you paste?
Re: Monitoring a part of the screen
I will read about that
Last edited by Fulminare on 08 Sep 2021, 20:09, edited 2 times in total.
Re: Monitoring a part of the screen
So the zoom window doesn't get minimised when chrome or other apps are opened ?
I pasted your code
using - #include somehow didn't work
I pasted your code
using - #include somehow didn't work
-
- Posts: 4562
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: Monitoring a part of the screen
Code: Select all
#SingleInstance
Send ^#6
Sleep 100
Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x451 y0 w950 h530
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x451 y520 w950 h530
source1_X := 139, source1_Y := 280, source1_W := 710, source1_H := 525 ; first area in the source window
source2_X := 971, source2_Y := 275, source2_W := 945, source2_H := 530 ; second area in the source window
;Sleep 1000
Send {F1}
Return
F1::
Loop 2 {
i := A_Index
Thumb%i% := new ThumbnailGui(hThumb%i%, 950, 530, WinExist("Zoom Meeting"), 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)
}
}
It's working now
Instead of placing "send {F1}" before the first return, I placed it at the end of the script.
Zoom is getting minimised when desktop is opened, but that's not happening when I open any other application such as chrome, OBS, Whatsapp e.t.cI don't know what exactly happens.
hence, the gui video feed freezes on opening the desktop.
Re: Monitoring a part of the screen
@teadrinker
There is something strange happening with your code
see
When I run that It acknowledges the " Send {F1} ( I have added that in line 9 )command and automatically pulls the display feed from zoom ( for the purpose of testing I have changed WinExist("Zoom Meeting") to WinExist("A") )
But when I include that in the following function, only the two blank guis are shown. Of course, on pressing F1 the zoom feed gets shown in the guis. but it is not acknowledging the Send {F1} command when included in the function
Can you please help by telling why does this happen ?
There is something strange happening with your code
see
Code: Select all
Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x451 y0 w950 h530
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x451 y520 w950 h530
source1_X := 139, source1_Y := 280, source1_W := 710, source1_H := 525 ; first area in the source window
source2_X := 971, source2_Y := 275, source2_W := 945, source2_H := 530 ; second area in the source window
Sleep 100
Send, {F1}
Return
F1::
Loop 2 {
i := A_Index
Thumb%i% := new ThumbnailGui(hThumb%i%, 950, 530, 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)
}
}
When I run that It acknowledges the " Send {F1} ( I have added that in line 9 )command and automatically pulls the display feed from zoom ( for the purpose of testing I have changed WinExist("Zoom Meeting") to WinExist("A") )
But when I include that in the following function, only the two blank guis are shown. Of course, on pressing F1 the zoom feed gets shown in the guis. but it is not acknowledging the Send {F1} command when included in the function
Code: Select all
^!v::
x:= 272 ;x coordinate of pixel to check.
y:= 83 ;y coordinate of pixel to check.
targetcolor:= 0x1A1A1A ;color to be matched in hexadecimal blue-green-red (BGR) format.
Loop
{
PixelGetColor, currentcolor, x, y
if (currentcolor=targetcolor)
{
#Include C:\Users\user\Desktop\New AutoHotkey Script (4).ahk
}
else
{
;do something
}
}
Can you please help by telling why does this happen ?
Re: Monitoring a part of the screen
It doesn’t make sense to #Include the first script in the place you’ve shown in the second script. You have Return lines and hotkey definitions that will cause the loop to stop executing because the auto-execute section ends. If that’s what you did, then the resulting script looks like this:
When you review the above combined script, does it make sense to you?
Code: Select all
^!v::
x:= 272 ;x coordinate of pixel to check.
y:= 83 ;y coordinate of pixel to check.
targetcolor:= 0x1A1A1A ;color to be matched in hexadecimal blue-green-red (BGR) format.
Loop
{
PixelGetColor, currentcolor, x, y
if (currentcolor=targetcolor)
{
Gui, New, hwndhThumb1 -DpiScale +AlwaysOnTop +Owner, First Area
Gui, Show, x451 y0 w950 h530
Gui, New, hwndhThumb2 -DpiScale +AlwaysOnTop +Owner, Second Area
Gui, Show, x451 y520 w950 h530
source1_X := 139, source1_Y := 280, source1_W := 710, source1_H := 525 ; first area in the source window
source2_X := 971, source2_Y := 275, source2_W := 945, source2_H := 530 ; second area in the source window
Sleep 100
Send, {F1}
Return
F1::
Loop 2 {
i := A_Index
Thumb%i% := new ThumbnailGui(hThumb%i%, 950, 530, 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)
}
}
}
else
{
;do something
}
}
When you review the above combined script, does it make sense to you?
Re: Monitoring a part of the screen
well, like , I thought as the first script works as intended individually, (i.e it takes into account the send {f1} command) and gives the output.)When you review the above combined script, does it make sense to you?
placing it in the "pixel trigger" script would make it work when a pixel changes colour.
regarding the return and the hotkey,
this first script is working (individually that is,) even when I blocked the "F1:: and "return" lines
Code: Select all
Send, {F1}
;Return
;F1::
But the loop is needed for monitoring change in pixel colour.
What should I do ?
Is there a way to search for pixel colour change with out the loop ?
Re: Monitoring a part of the screen
Having a loop isn't the problem. Plopping a full script that includes a fully realized auto-execute section and hotkey definitions in the middle of what is meant to be the flow of code in another script is the problem. Look at what you have as an entire script and pay attention to how the code flows and the placement of commands that are meant to be executed in that flow vs. code that is meant to be triggered when a hotkey is pressed. Try to produce a script that makes sense from that perspective, then post it when you get stuck.
Re: Monitoring a part of the screen
Okay I will do that