Im CodeArchiv gibts schon die Windows Variante, also hab ich einfach mal einen Code für Windows und Linux gemacht:
Code: Alles auswählen
;Screenshots unter Windows und Linux erstellen
;Gemischt mit Danilos variante hier: http://www.purearea.net/pb/CodeArchiv/Windows_System/Screenshots/MakeWindowScreenshot.pb
; Autor: DarkDragon/Danilo ;) .
;
#SCREENSHOT_MOUSE = 2
CompilerIf #PB_Compiler_OS = #PB_OS_Windows
Procedure GetCurrentCursor(*pt.Point)
hWindow.l
dwThreadID.l
dwCurrentThreadID.l
Result = 0
If GetCursorPos_(*pt)
hWindow = WindowFromPoint_(*pt\x, *pt\y)
If IsWindow_(hWindow)
dwThreadID = GetWindowThreadProcessId_(hWindow, @nil)
dwCurrentThreadID = GetCurrentThreadId_()
If (dwCurrentThreadID <> dwThreadID)
If AttachThreadInput_(dwCurrentThreadID, dwThreadID, 1)
Result.l = GetCursor_()
AttachThreadInput_(dwCurrentThreadID, dwThreadID, 0)
EndIf
Else
Result.l = GetCursor_()
EndIf
EndIf
EndIf
ProcedureReturn Result
EndProcedure
CompilerEndIf
Procedure MakeDesktopScreenshot(ImageNr,x,y,Width,Height,Flags)
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
RunProgram("import", "-window root -crop "+Str(Width)+"x"+Str(Height)+"+"+Str(x)+"+"+Str(y)+" /tmp/snapshot.bmp", "/", 1)
hImage = LoadImage(ImageNr, "/tmp/snapshot.bmp")
CompilerElse
hImage = CreateImage(ImageNr,Width,Height)
If hImage
hDC = StartDrawing(ImageOutput())
If hDC
DeskDC = GetDC_(GetDesktopWindow_())
If DeskDC
BitBlt_(hDC,0,0,Width,Height,DeskDC,x,y,#SRCCOPY)
EndIf
ReleaseDC_(GetDesktopWindow_(),DeskDC)
EndIf
If (Flags & #SCREENSHOT_MOUSE)
hCursor = GetCurrentCursor(@pt.Point)
DrawImage(hCursor, pt\x-capX, pt\y-capY)
EndIf
StopDrawing()
EndIf
CompilerEndIf
ProcedureReturn hImage
EndProcedure
Procedure ViewImage()
If OpenWindow(1000, 0, 0, ImageWidth(), ImageHeight(), #PB_Window_SystemMenu, "Image")
CreateGadgetList(WindowID())
ImageGadget(1000, 0, 0, ImageWidth(), ImageHeight(), ImageID())
Repeat
Event = WaitWindowEvent()
Delay(10)
Until Event = #PB_Event_CloseWindow
CloseWindow(1000)
EndIf
EndProcedure
Delay(1000)
hImg = MakeDesktopScreenshot(0,100,300,512,256,#SCREENSHOT_MOUSE)
If hImg
ViewImage()
FreeImage(0)
EndIf

[UPDATE] - Mauszeiger hinzugefügt(Windows only, erstmal)