Re: Gtuner IV 1.07 PUBLIC RELEASE: Computer Vision
Posted: Wed Apr 01, 2020 5:40 pm
The blank/black screen issue seems to happen whenever you try to capture a window that renders in a special way.
I'm currently facing the exact same problem when trying to capture a window that uses OpenGL for rendering.
A workaround would be to disable desktop composition but unfortunately this doesn't appear to be possible with Windows 10 as Microsoft has completely removed the option due to the Desktop/UI now heavily relying on it. There's still some ways of achieving this, but If you've updated Windows recently then this probably won't work for you or it'll cause system instability which could eventually lead to a crash.
Another option would be to create an application that uses the GDI+ Library to capture the target window then render it inside a new window and use that new window as the capture target, but when I tested this on my crap PC I was having performance issues and a white flicker from time to time.
(Though that might of been an issue with my implementation, still experimenting with it lol)
EDIT:
Here's a solution that I whipped up in AutoHotkey.
This requires AutoHotkey (Duh) and the Gdip_All.AHK helper library. (Download it & place it in same folder)
WinCap.ahk:
@J2Kbr:
Are there any advanced configuration options that can be used to change how Gtuner captures the window?
I'm currently facing the exact same problem when trying to capture a window that uses OpenGL for rendering.
A workaround would be to disable desktop composition but unfortunately this doesn't appear to be possible with Windows 10 as Microsoft has completely removed the option due to the Desktop/UI now heavily relying on it. There's still some ways of achieving this, but If you've updated Windows recently then this probably won't work for you or it'll cause system instability which could eventually lead to a crash.
Another option would be to create an application that uses the GDI+ Library to capture the target window then render it inside a new window and use that new window as the capture target, but when I tested this on my crap PC I was having performance issues and a white flicker from time to time.
(Though that might of been an issue with my implementation, still experimenting with it lol)
EDIT:
Here's a solution that I whipped up in AutoHotkey.
This requires AutoHotkey (Duh) and the Gdip_All.AHK helper library. (Download it & place it in same folder)
WinCap.ahk:
- Code: Select all
#NoEnv
#SingleInstance, Force
#Include, Gdip_All.AHK
CaptureText := ""
CaptureMargin := [ 0, -32, 0, 0 ]
if (!CaptureText)
{
WinGet WindowList, List
WinList := []
Loop, % WindowList
{
WindowHandle := WindowList%A_Index%
WinGet, WindowStyle, Style, % "ahk_id" WindowHandle
if (WindowStyle & 0x10000000) ; WS_VISIBLE
{
WinGetTitle, WinTitle, % "ahk_id" WindowHandle
if (StrLen(WinTitle) > 0)
{
if (StrLen(WinList) > 1)
{
WinList := WinList "`n"
}
WinList := WinList WinTitle
}
}
}
VarSetCapacity(CaptureHandle, 0)
Gui +Delimiter`n
Gui, Add, DropDownList, vCaptureText w330 gCaptureSelection, % WinList
Gui, Show, w350 h35, % "Select Window"
}
while (!CaptureHandle)
{
WinGet, CaptureHandle, , % CaptureText
Sleep, 10
}
Token := Gdip_Startup()
WinGetPos,,, Width, Height, % "ahk_id" CaptureHandle
Gui, New, +Resize hWndGuiHandle
Gui, Add, Picture, % "x0 y0 w0 h0 0xE hWndGuiPictureHandle"
Gui, Show, % "w" (Width + CaptureMargin[3]) " h" (Height + CaptureMargin[4]), GDI+ WinCap
while (true)
{
WinGetPos,,, Width, Height, % "ahk_id" CaptureHandle
if (Mod(A_Index, 200) == 1)
{
GuiSize()
}
DC := CreateCompatibleDC()
DIB := CreateDIBSection(Width, Height)
SelectObject(DC, DIB)
PrintWindow(CaptureHandle, DC, 2)
DDC := GetDC(GuiPictureHandle)
Bitmap := Gdip_CreateBitmapFromHBITMAP(DIB)
Graphics := Gdip_GraphicsFromHDC(DC)
Gdip_DrawImage(Graphics, Bitmap)
Gdip_DisposeImage(Bitmap)
DeleteObject(Graphics)
BitBlt(DDC, 0, 0, Width, Height, DC, 0, 0)
DeleteObject(DIB)
ReleaseDC(DDC)
DeleteDC(DC)
}
GuiSize:
{
GuiSize()
}
GuiSize()
{
global CaptureHandle, CaptureMargin, GuiHandle, GuiPictureHandle
WinGetPos, CapX, CapY, CapW, CapH, % "ahk_id" CaptureHandle
WinGetPos, WinX, WinY, WinW, WinH, % "ahk_id" GuiHandle
CapW := (CapW + CaptureMargin[3])
CapH := (CapH + CaptureMargin[4])
if ((WinW > CapW) || (WinH > CapH))
{
WinMove, % "ahk_id " GuiHandle, , % WinX, % WinY, % CapW, % CapH
}
else if ((WinW < (CapW / 2)) || (WinH < (CapH / 2)))
{
WinMove, % "ahk_id " GuiHandle, , % WinX, % WinY, % (CapW / 2), % (CapH / 2)
}
WinMove, % "ahk_id" GuiPictureHandle, , % CaptureMargin[1], % CaptureMargin[2], % WinW, % WinH
}
#IfWinActive ahk_class AutoHotkeyGUI
Esc::
GuiClose:
{
ExitApp
}
CaptureSelection:
{
GuiControlGet, CaptureText
Gui, Show, Hide
return
}
@J2Kbr:
Are there any advanced configuration options that can be used to change how Gtuner captures the window?