GrabDesktop does not grab sections of Desktop
Posted: Sat Apr 10, 2010 10:56 am
Hi
I was programming a small utility to grab a section of the desktop and store it as a BMP picture. For this I used the GrapDesktop function. However it seems to ignores the parameters in the table (x, y, width, height) and just copies the entire desktop whether the parameters are there or not.
I use the Hollywood display as my marker for the area to be copied because it is easy to manipulate and resize. Then I just hide the display while doing the dump. But the dump covers the entire Desktop despite the parameters set in the function call. See code below
Regards
Jesper
runflag=true
@DISPLAY {Sizeable=True, color=#YELLOW, Borderless=True}
CreateBGPic(2,640,480,#RED)
SelectAlphaChannel(2,#BGPIC)
SetAlphaIntensity(50)
Cls()
EndSelect
SetDisplayAttributes({BGPic=2})
Function KeyHandler(msg)
Switch msg.key
Case "F12"
Local x,y,w,h=GetSizeAndPosition()
HideDisplay()
GrabDesktop(10,{x,y,w,h})
ShowDisplay()
SaveBrush(10,"Ram:Screendump.bmp",nil,#IMGFMT_BMP)
Case "ESC"
runflag=false
EndSwitch
EndFunction
Function GetSizeAndPosition()
LOCAL x,y,w,h
x=GetAttribute(#DISPLAY,1,#ATTRXPOS)
y=GetAttribute(#DISPLAY,1,#ATTRYPOS)
w=GetAttribute(#DISPLAY,1,#ATTRWIDTH)
h=GetAttribute(#DISPLAY,1,#ATTRHEIGHT)
Return(x,y,w,h)
EndFunction
InstallEventHandler({OnKeyDown=KeyHandler})
while runflag=true
waitevent
wend
end
I was programming a small utility to grab a section of the desktop and store it as a BMP picture. For this I used the GrapDesktop function. However it seems to ignores the parameters in the table (x, y, width, height) and just copies the entire desktop whether the parameters are there or not.
I use the Hollywood display as my marker for the area to be copied because it is easy to manipulate and resize. Then I just hide the display while doing the dump. But the dump covers the entire Desktop despite the parameters set in the function call. See code below
Regards
Jesper
runflag=true
@DISPLAY {Sizeable=True, color=#YELLOW, Borderless=True}
CreateBGPic(2,640,480,#RED)
SelectAlphaChannel(2,#BGPIC)
SetAlphaIntensity(50)
Cls()
EndSelect
SetDisplayAttributes({BGPic=2})
Function KeyHandler(msg)
Switch msg.key
Case "F12"
Local x,y,w,h=GetSizeAndPosition()
HideDisplay()
GrabDesktop(10,{x,y,w,h})
ShowDisplay()
SaveBrush(10,"Ram:Screendump.bmp",nil,#IMGFMT_BMP)
Case "ESC"
runflag=false
EndSwitch
EndFunction
Function GetSizeAndPosition()
LOCAL x,y,w,h
x=GetAttribute(#DISPLAY,1,#ATTRXPOS)
y=GetAttribute(#DISPLAY,1,#ATTRYPOS)
w=GetAttribute(#DISPLAY,1,#ATTRWIDTH)
h=GetAttribute(#DISPLAY,1,#ATTRHEIGHT)
Return(x,y,w,h)
EndFunction
InstallEventHandler({OnKeyDown=KeyHandler})
while runflag=true
waitevent
wend
end