GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 3:52 am

All times are UTC




Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
PostPosted: Wed Apr 25, 2012 7:52 pm 
That was my entire code, for the directx side of things.


Top
  
 
PostPosted: Thu Apr 26, 2012 5:21 pm 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
Guest wrote:
That was my entire code, for the directx side of things.



well then what are you exactly trying to do, are you trying to take screenshot of your game or any game is its any games its much more complicated then that. Thats why its not working. This is mean to work from inside your game .???


Top
 Profile  
 
PostPosted: Thu Apr 26, 2012 6:37 pm 
I'm just aiming to make an external program to capture game screenshots every 60 seconds. It's not any game specifically but if it has to be hl2.exe (Counter-Strike:Source)


Top
  
 
PostPosted: Fri Apr 27, 2012 6:06 pm 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
first of all if im not mistaken you can do that with gdi, and also why dont you just use a program like fraps. It wont be a simple bit of code you have to write. sorry but your title was a bit misleading or i just read it wrong.


Top
 Profile  
 
PostPosted: Fri Apr 27, 2012 7:02 pm 
GDI results in black screenshots of the game even with windows aero off hence why I am using DirectX also i want this for personal use and other uses in the future.


Top
  
 
PostPosted: Sat Apr 28, 2012 6:39 am 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
Its not as easy as you think to achive this. you would need to capture the screen handle of what ever app your trying to render then pass it to the backbuffer and render it.

Link 1 explains how fraps works and what it does to achive this.
http://www.woodmann.com/forum/archive/i ... 11023.html


you will need to hook the front buffer of the app your trying to get a screenshot from then, copy it over.


Top
 Profile  
 
PostPosted: Sat Apr 28, 2012 8:20 am 
I took a quick look but that's C++?


Top
  
 
PostPosted: Sat Apr 28, 2012 8:29 am 
- So I should be hooking into my process? If I was to do such things in VB I'd require Easyhook?


Top
  
 
PostPosted: Sat Apr 28, 2012 10:30 am 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
yeah well for vb you would have to use win32 api, linking to external librarys. Im not sure which ones exactly you need to use. but for one in vb it will be quite a tedious problem to get by im not saying its imposible but its not an easy task, programming is programming if you look at the c++ way of doing it then try and convert it to vb step by step. Ive never used easy hook so im not sure, i stopped using vb about a year ago so im a bit rusty, you just need to find a way to get the device context of the dialog you are trying to capture then you should be able to render that to an image. again im just guessing not entirely sure.


Top
 Profile  
 
PostPosted: Sat Apr 28, 2012 12:42 pm 
Well Thanks for your help. Now I have the challenge of getting the smallest grasp of c++ to figure out how to make such a thing work in VB, such a pain!


Top
  
 
PostPosted: Sat Apr 28, 2012 1:41 pm 
Would This work:

Code:
Dim backbuffer As Surface = dxDevice.GetBackBuffer(0, 0, BackBufferType.Mono)
SurfaceLoader.Save(file, ImageFileFormat.Jpg, backbuffer)
backbuffer.Dispose()


Top
  
 
PostPosted: Sat Apr 28, 2012 2:27 pm 
I've since assigned the device I believe and I'm now receiving this error:

Code:
************** Exception Text **************
System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at Microsoft.DirectX.Direct3D.Device..ctor(Int32 adapter, DeviceType deviceType, IntPtr renderWindowHandle, CreateFlags behaviorFlags, PresentParameters[] presentationParameters)
   at WindowsApplication2.Screenshot..ctor(Device Device) in C:\Users\Elliot\Desktop\WindowsApplication2\WindowsApplication2\Screenshot.vb:line 15
   at WindowsApplication2.Form1.Timer1_Tick(Object sender, EventArgs e) in C:\Users\Elliot\Desktop\WindowsApplication2\WindowsApplication2\Form1.vb:line 107
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


Code:
    Public dxDevice As Direct3D.Device
    Public dxsurface As Surface

    Public Sub New(ByVal Device As Direct3D.Device)

        dxDevice = New Device(0, DeviceType.Hardware, IntPtr.Zero, CreateFlags.SoftwareVertexProcessing)
        dxsurface = dxDevice.CreateOffscreenPlainSurface(1024, 768, Format.A8R8G8B8, Pool.SystemMemory)
        dxDevice.GetFrontBufferData(0, dxsurface)

    End Sub



Code:
        SurfaceLoader.Save(file, ImageFileFormat.Jpg, dxsurface)
        dxsurface.Dispose()


Top
  
 
PostPosted: Sat Apr 28, 2012 4:53 pm 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
I dont think you understand what you are doing there is no device you have to have a fully initialized dx device for your own data it is a null device. This code will not work for what your trying to do.


Top
 Profile  
 
PostPosted: Sat Apr 28, 2012 8:59 pm 
Code:
        dxDevice = New Device(0, DeviceType.Hardware, "windows handle code", CreateFlags.SoftwareVertexProcessing)


That'd work wouldn't it?


Top
  
 
PostPosted: Sun Apr 29, 2012 6:44 am 
Grossly Helpful

Joined: Wed Apr 12, 2006 6:22 pm
Posts: 154
Guest wrote:
Code:
        dxDevice = New Device(0, DeviceType.Hardware, "windows handle code", CreateFlags.SoftwareVertexProcessing)


That'd work wouldn't it?



NO! you want access to the dxdevice from within anotherapp you cant create a new one it will just be empty.


Top
 Profile  
 
PostPosted: Sun Apr 29, 2012 11:02 am 
So what you're trying to tell me is that i need to hook into the games directx and link it to dxdevice?


Top
  
 
PostPosted: Thu Aug 02, 2012 10:38 am 
I would also like to know how to get the dxdevice.


Top
  
 
PostPosted: Sat Aug 04, 2012 1:01 am 
P2k
User avatar

Joined: Tue Aug 23, 2005 5:11 am
Posts: 2145
This really belongs in the .NET forum since you are not using VB5/6

The answer is pretty much there is no easy reliable way to hook into a game's directx device and take screenshots. And the ways that do work will likely get you flagged for cheating in any online multiplayer game by injecting your own code into their process.

Why do you want to take screenshots of other people's games anyway? That doesn't really seem like you are doing "Game Programming" (the point of this forum) to me.


Top
 Profile  
 
PostPosted: Sun Aug 05, 2012 4:48 am 
Valve Anticheat and other anticheats are turned off. so it doesnt matter how it gets injected etc


Top
  
 
PostPosted: Wed Oct 10, 2012 3:18 am 
Rookie

Joined: Wed Oct 10, 2012 2:40 am
Posts: 3
With DirectX and will my dxdevice from the application very confused, I do not know?

_________________
My doctor gave me six months to live, but when I couldn't pay the bill, he gave me six months more.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 41 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group