Hier mal meine Procedure mit der du entweder vom gesamten Desktop oder vom aktuellen Fenster ein Screenshot machen kannst.
Musst du ja nicht viel anpassen.
Code: Alles auswählen
Procedure DesktopScreenshot(ImagePath$, Curr = 0, Format = #PB_ImagePlugin_BMP)
Protected iImage.i, iDC.i, iDesktopDC.i, iForegroundWin, R.RECT, iResult.i
Protected X.i, Y.i, Width.i, Height.i
If Curr
iForegroundWin = GetForegroundWindow_()
If GetWindowRect_(iForegroundWin, @R)
X = R\left
Y = R\top
Width = R\right - R\left
Height = R\bottom - R\top
EndIf
If X < 0 Or Y < 0
X = 0
Y = 0
Width = GetSystemMetrics_(#SM_CXSCREEN)
Height = GetSystemMetrics_(#SM_CYSCREEN)
EndIf
Else
X = 0
Y = 0
Width = GetSystemMetrics_(#SM_CXSCREEN)
Height = GetSystemMetrics_(#SM_CYSCREEN)
EndIf
If Trim(ImagePath$) <> ""
iImage = CreateImage(#PB_Any, Width, Height)
If iImage <> 0
iDC = StartDrawing(ImageOutput(iImage))
If iDC
iDesktopDC = GetDC_(GetDesktopWindow_())
BitBlt_(iDC, 0, 0, Width, Height, iDesktopDC, X, Y, #SRCCOPY)
StopDrawing()
ReleaseDC_(GetDesktopWindow_(), iDesktopDC)
EndIf
If SaveImage(iImage, ImagePath$, Format)
iResult = 1
EndIf
Else
iResult = -1
EndIf
Else
iResult = 0
EndIf
ProcedureReturn iResult
EndProcedure