-
Jun 30th, 2006, 07:30 AM
#1
Thread Starter
Fanatic Member
Capture Game Screen (Game Uses DirectX)
I need to capture the screen when a game is running.
The problem is that when I make my app use keybd_event API to simulate the PrintScreen button, or when I use BitBlt to capture the screen, the window that the game is in is just black.
I need to capture the screen because I want to look for certain pixels within the game window, but atm the whole thing is just black.
Any way to capture the pixels in the window or somehow compare the pixels to a picture I have (sort of like an OCR but I want to find shapes, not text)
-
Jun 30th, 2006, 07:54 AM
#2
Re: Capture Game Screen (Game Uses DirectX)
if u manually press print screen does it work??
is there a screenshot hotkey for the game? maybe send that key?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jun 30th, 2006, 08:11 AM
#3
Thread Starter
Fanatic Member
Re: Capture Game Screen (Game Uses DirectX)
The strange thing is that if I manually press print screen then it works fine, but if I make the prog do it it just captures blackness
-
Jul 10th, 2006, 01:20 PM
#4
Thread Starter
Fanatic Member
Re: Capture Game Screen (Game Uses DirectX)
I'm using the keybd_event API to send the printscrn key.
Is the game somehow detecting this and preventing my app from capturing the screen or what?
Is it possible to programmatically capture the screen within a game?
-
Jul 10th, 2006, 03:53 PM
#5
Addicted Member
Re: Capture Game Screen (Game Uses DirectX)
If pressing the print screen key is the only way to grab the image. Then, use it. In your program add a timer. In the timer check the clipboard for an image. If there's an image then transfer it to a picturebox,clear the clipboard and then analyze it.
Something like:
VB Code:
Private Sub Timer1_Timer()
If Clipboard.GetFormat(vbCFBitmap) Then
Picture1.Picture = Clipboard.GetData(vbCFBitmap)
Clipboard.Clear
'analyze picture
End If
End Sub
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
-
Jul 11th, 2006, 12:23 AM
#6
New Member
Re: Capture Game Screen (Game Uses DirectX)
Hi
Please excuse me for sticking my nose in here but how might you then store/write that graphic file to a predetermined folder with say an automated date and time stamp as the file name...!
-
Jul 11th, 2006, 02:38 AM
#7
Thread Starter
Fanatic Member
Re: Capture Game Screen (Game Uses DirectX)
The problem is that I want to analyze the screen in real-time (or as close to it as I can get) so that I can basically have my program understand what is happening in the game without me having to press PrintScrn every second.
I want it to capture the screen continuously and then it will work like an OCR and look for certain things within the game screen.
@berzerkart, you would use SavePicture Picture1.Picture, App.Path & "\" & Now & ".bmp"
-
Jul 11th, 2006, 09:30 AM
#8
Addicted Member
Re: Capture Game Screen (Game Uses DirectX)
hmmm. That's a tough one.
Is the game somehow detecting this and preventing my app from capturing the screen or what?
I doubt it. Because the first thing it would do is block the print screen button. It's more likely that it's blocking keys to prevent cheating.
You tried to BitBlt. Maybe it's using DirectX. Does that use the same draw method. Would you have to grab it differently from DirectX ?
This is what I use.
VB Code:
'
Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Const VK_SNAPSHOT = &H2C
'The following command copies the full windows desktop to the clipboard (the equivalent of PrintScrn):
call keybd_event(vbKeySnapshot, 0, 0, 0)
'The following command copies the active application window to the clipboard (the equivalent of Alt+PrintScrn):
call keybd_event(vbKeySnapshot, 1, 0, 0)
Keith_VB6
If you have any further questions, just ask.
If this solves things, then please mark the thread resolved.
[Thread Tools] --> [Mark Thread Resolved]
-
Jul 13th, 2006, 03:50 AM
#9
Thread Starter
Fanatic Member
Re: Capture Game Screen (Game Uses DirectX)
That's basically what I was using
VB Code:
Public Function SaveScreen(pstrFileName As String) As Boolean
'To get the Entire Screen
Call keybd_event(vbKeySnapshot, 1, 0, 0)
'To get just the Active Window
'Call keybd_event(vbKeySnapshot, 0, 0, 0)
On Error GoTo SaveErr
SavePicture Clipboard.GetData(vbCFBitmap), pstrFileName
SaveScreen = True
SaveErr:
End Function
Is there some other way to 'see' what's on the screen?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|