Printscreen on Windows 7

This forum is for general support of Xbase++
Message
Author
skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Printscreen on Windows 7

#1 Post by skiman »

I'm using the following to take a printscreen to the clipboard. It seems as this isn't working anymore on Windows 7.

DLLFUNCTION keybd_event(mvkey,nscan,flags,xtra) USING STDCALL FROM USER32.DLL

PROCEDURE PrintScreen()
keybd_event(PS_SNAPSHOT,1,0,0)
RETURN

After calling this procedure, the screendump was saved to the clipboard. On Windows 7 this is a big black bitmap.

Anyone who has a printscreen which is doing the same and working on Windows7?
Best regards,

Chris.
www.aboservice.be

User avatar
rdonnay
Site Admin
Posts: 4774
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Printscreen on Windows 7

#2 Post by rdonnay »

Chris -

Try this. I tested it on XP. I don't have my Win 7 computer here at the moment, but I suspect it will work.

Roger

Code: Select all

FUNCTION Main()

SaveScreen2Clipboard()

RETURN nil

PROC appsys ; return

FUNCTION SaveScreen2ClipBoard()

LOCAL oBitmap, oXbp, oSourcePS, oClipBoard

oXbp := AppDeskTop()

oSourcePS := oXbp:LockPS()
oBitmap := GraSaveScreen( oSourcePS, {0,0}, oXbp:currentSize() )

oClipBoard := XbpClipBoard():new():create()
oClipBoard:open()
oClipBoard:setBuffer(oBitMap)
oClipBoard:close()
oClipBoard:destroy()

RETURN nil
The eXpress train is coming - and it has more cars.

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Printscreen on Windows 7

#3 Post by skiman »

Hi Roger,

No, this isn't working on my Windows 7 64 Bit. The result is a black window.
On my XP it is working without problem.
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Printscreen on Windows 7

#4 Post by Auge_Ohr »

hi,

did you have a "clipbrd.exe" on your Win7 PC ?

i have test Roger´s Code, but no Luck under Win7 32bit
btw. if i "press" PrintScreen it work

while GraSaveScreen() is just a UDF, here Code i use

Code: Select all

FUNCTION GraSaveScreen( oSourcePS, aPos, aSize ) 
L[code]OCAL oBitmap   := XbpBitmap():new():create( oSourcePS ) 
LOCAL oTargetPS := XbpPresSpace():new():create() 
LOCAL aSourceRect[4], aTargetRect 

  aSourceRect[1] := aSourceRect[3] := aPos[1] 
  aSourceRect[2] := aSourceRect[4] := aPos[2] 
  aSourceRect[3] += aSize[1] 
  aSourceRect[4] += aSize[2] 

  aTargetRect    := {0, 0, aSize[1], aSize[2]} [code]
[/code]

oBitmap:presSpace( oTargetPS )
oBitmap:make( aSize[1], aSize[2] )

GraBitBlt( oTargetPS, oSourcePS, aTargetRect, aSourceRect )

RETURN oBitmap[/code]

edit : sorry i have to correct, Roger´s Code does get "manuell" PrintScreen into "clipbrd.exe"

this Code does work on my Win7 32bit

Code: Select all

#INCLUDE "xbp.ch"
#INCLUDE "Gra.ch"
#INCLUDE "DLL.ch"
#INCLUDE "Appevent.ch"

#define VK_SNAPSHOT     0x2C
#define KEYEVENTF_KEYUP 0x2

DLLFUNCTION keybd_event(mvkey,nscan,flags,xtra) USING STDCALL FROM USER32.DLL

FUNCTION Main()
 keybd_event(VK_SNAPSHOT, 0, 0, 0)
 keybd_event(VK_SNAPSHOT, 0, KEYEVENTF_KEYUP, 0)

* keybd_event(VK_SNAPSHOT,1,0,0)
 SLEEP(100)
 SaveScreen2Clipboard()

RETURN nil

PROC appsys ; return
edit : correction ... "sometimes" it work ... depends on how many "Windows" i have open ...

... hm .. a SLEEP(100) between keybd_event() and SaveScreen2Clipboard() "seems" to help
greetings by OHR
Jimmy

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Printscreen on Windows 7

#5 Post by skiman »

Hi Jimmy,

No, it isn't working on My Windows 7 64 Bit.
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Printscreen on Windows 7

#6 Post by Auge_Ohr »

skiman wrote:No, it isn't working on My Windows 7 64 Bit.
as i say : did you have "Clipbrd.exe" on your PC ?
greetings by OHR
Jimmy

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Printscreen on Windows 7

#7 Post by skiman »

Hi,

When I press printscreen and do a paste in Paint, the window appears. So I suppose it should work.

Anyway, I can't ask this kind of questions to my customers. I thought that there would be an easy solution for this rather simple task. It seems as it is not that simple. :(
Best regards,

Chris.
www.aboservice.be

User avatar
Auge_Ohr
Posts: 1422
Joined: Wed Feb 24, 2010 3:44 pm

Re: Printscreen on Windows 7

#8 Post by Auge_Ohr »

skiman wrote:When I press printscreen and do a paste in Paint, the window appears. So I suppose it should work.
i know this, but i "think" it is not the same as XbpClipBoard()

as i say i have download "Clipbrd.RAR" for some Reason and this work for me.
to verify i must deinstall it so try it yourself on your Machine.
greetings by OHR
Jimmy

Cliff Wiernik
Posts: 605
Joined: Thu Jan 28, 2010 9:11 pm
Location: Steven Point, Wisconsin USA
Contact:

Re: Printscreen on Windows 7

#9 Post by Cliff Wiernik »

I will test on my Win7 64bit program and my print screen to printer process I use. I think it works but will validate just to be certain.

Cliff.

skiman
Posts: 1195
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Printscreen on Windows 7

#10 Post by skiman »

Hi Cliff,

Have you found some time to test your printscreen function?
Best regards,

Chris.
www.aboservice.be

Post Reply