CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Nov 2018
    Posts
    7

    Question Taking a screen shot of a game (Counter-Strike 1.6)

    Hello guys. I am trying to take a screen shot while I am ingame (counter-strike). When I try to take a screenshot it gives me a black picture. It happens only when I am in-game (when I am in desktop and take a screenshot, it works). Someone told me that this game uses OpenGL and maybe that is the problem. This is the code I use:

    Code:
    private Image CaptureScreen()
            {
                Rectangle screenSize = Screen.PrimaryScreen.Bounds;
                Bitmap target = new Bitmap(screenSize.Width, screenSize.Height);
                using (Graphics g = Graphics.FromImage(target))
                {
                    g.CopyFromScreen(0, 0, 0, 0, new Size(screenSize.Width, screenSize.Height));
                }
                return target;
            }
    thanks in advance.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Search bing or google for "taking a screenshot of open gl".

  3. #3
    Join Date
    Nov 2018
    Posts
    7

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Thanks. I already searched and found many articles but none of them worked, it givea me a black screen with white empty square on the left corner of the screen shot image.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Maybe counterstrike is hooking the open gl call and preventing you from taking the screen shot?

  5. #5
    Join Date
    Nov 2018
    Posts
    7

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Yes that makes sense. I found an article says that the only way to do it is to use the injection method. Can you help me find something about it? I have searched and nothing comes up

  6. #6
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Quote Originally Posted by Ornakash View Post
    Yes that makes sense. I found an article says that the only way to do it is to use the injection method. Can you help me find something about it? I have searched and nothing comes up
    My point is that the game is hooking to prevent you from screen capturing. It is unlikely you'll be able to undo what they are doing with your own hook. Try searching bing or google for "how to hook a process." There's lots of info out there.

  7. #7
    Join Date
    Nov 2018
    Posts
    7

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Oh, thanks. Ill try now

  8. #8
    Join Date
    Nov 2018
    Posts
    7

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Quote Originally Posted by Arjay View Post
    My point is that the game is hooking to prevent you from screen capturing. It is unlikely you'll be able to undo what they are doing with your own hook. Try searching bing or google for "how to hook a process." There's lots of info out there.
    I couldn't find a way to do this using C#. Some people say that it's not possible to hook a process in C#. Is it the only way to do it? I know C# better than CPP.

    Source: https://support.microsoft.com/he-il/...n-visual-c-net
    Last edited by Ornakash; November 25th, 2018 at 06:40 PM.

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Taking a screen shot of a game (Counter-Strike 1.6)

    Quote Originally Posted by Ornakash View Post
    I couldn't find a way to do this using C#. Some people say that it's not possible to hook a process in C#. Is it the only way to do it? I know C# better than CPP.

    Source: https://support.microsoft.com/he-il/...n-visual-c-net
    The article you are linking to shows you how to hook a process in c#. Not sure why you are questioning whether it can be done when you have an article that shows you how to do it.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured