Results 1 to 7 of 7

Thread: Alt + Printscreen & Then Save [Resolved]

  1. #1

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166

    Alt + Printscreen & Then Save [Resolved]

    How would I save my active window as an image whether it be a gif, jpg, etc...? I know how to send keys for the Alt & Print Screen but then how do I take that and save that image? Thanks.
    Last edited by jordan23; Jul 12th, 2004 at 01:48 PM.

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Here you go :
    PHP Code:
    private Image GetScreenCapture(bool FullScreen)
            {                                    
                if (
    FullScreen)SendKeys.SendWait("{PRTSC 2}");
                else 
    SendKeys.SendWait("%{PRTSC}");        
                
                
    IDataObject objData=Clipboard.GetDataObject();
                return (
    Image)objData.GetData(DataFormats.Bitmap);
            }

            private 
    void button1_Click(object senderSystem.EventArgs e)
            {    
                
    //Take shot !
                
    GetScreenCapture(true).Save(@"c:\test.bmp");
                
    pictureBox1.Image GetScreenCapture(true);
            } 

  3. #3

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Thanks for the code, the only thing is that when I go to open test.bmp it says it is not a valid file. It put the screen shot in the picture box but the file is not valid. Any ideas??

  4. #4

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Here is the exact message.
    Attached Images Attached Images  

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Replace the old line with this one(and specifiy the format you want to save the image to :

    PHP Code:
    //Take shot ! 
    GetScreenCapture(true).Save(@"c:\test.bmp",ImageFormat.Bmp); 

  6. #6

    Thread Starter
    Addicted Member jordan23's Avatar
    Join Date
    Dec 2002
    Posts
    166
    Thanks again Pirate!!

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Glad to help.

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