Re: Monitoring a part of the screen
Posted: 06 Sep 2021, 10:14
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)
Let's help each other out
https://www.autohotkey.com/boards/
https://www.autohotkey.com/boards/viewtopic.php?f=76&t=94376
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
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.
When you press F1 the hWnd of the Zoom window must be passed as the fourth parameter here
I don't quite understand, what you mean by «Returning to the desktop». Anyway, I've not encountered such behavior.
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?
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)
}
}
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.
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)
}
}
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
}
}
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
}
}
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?
Code: Select all
Send, {F1}
;Return
;F1::