Capturing Screen

Hello, I've been wondering how is it possible to capture the screen in my Visual C++ 2005 Windows Forms application.

With Thanks,
                    Gal Beniamini.


Answer this question

Capturing Screen

  • AmarAtAIR

    You could use a 3rd party product that contains a simple COM component called Print Screen Deluxe from American Systems.  Go to www.americansys.com.

    Your code could look like this:

    void Foo()
    {
        CInterface psd;

        psd.CreateDispatch("PrintScreenDeluxe.Interface");
        psd.CaptureFullScreen();
        psd.SaveFile("c:\\tmp\\FullScreen.BMP");
        psd.ReleaseDispatch();

    }

    I hope this helps.

     



  • Bigforky

    On your keyboard towards the right side there is a button called insert, straight above that is a small button called prt scr/sysrq, push that button to take a picture of the current screen, it saves the image to the clipboard meaning that if you open an advanced word application such as WordPad or Microsoft Office Word then when you paste it pastes the image onto the Word Application. There you go!

  • Waterbaby

    Send a VK_SNAPSHOT, then copy it from the clipboard (OpenClipboard, GetClipboardData etc)

    // Simulate a key press
    keybd_event( VK_SNAPSHOT, 0x41,KEYEVENTF_EXTENDEDKEY | 0,  0 );

    // Simulate a key release
    keybd_event( VK_SNAPSHOT,0x41,KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,0);

    credit: copied from usenet


  • Swammie

    You could use another 3rd party product, he generates screenshots in a bmp files and avi files, search about Camtasia in Google or MSN Search.

     

     



  • snehalppatel

    Hello Sniper167, thanks for the answer, however, I meant capturing the screen programatically so that the application will capture the current screen.

    With Thanks,
                        Gal Beniamini.

  • Irv154449

    As you are writing a managed (/CLR) app, you need to add user32.lib to your linker settings under properties: Configuration properties - Linker - Input - Additional Dependencies, so you should make it say:

    $(NoInherit) user32.lib

    or just

    user32.lib

    if it's already blank to begin with. 

    Also make sure your app under Configuration Properties - General is set to "Common Language Runtime Support /clr" and not "Pure MSIL Common Language Runtime Support (/clr:pure)"

    I just tested with a default wizard generated app, and it worked (I went into mspaint and the screen was in the clipboard, and I could paste it in).

     


  • Romain Larmet

    Thanks very much!!! You helped me out a lot.

    With Thanks,
                        Gal Beniamini.

  • Gaetano77


    Hello Ted, Thanks for your answer, however, I have a small problem. I tried using the commands you suggested but I get the following errors:
    *************************************************************************
    1>MyApp.obj : error LNK2028: unresolved token (0A00000E) "extern "C" void __stdcall keybd_event(unsigned char,unsigned char,unsigned long,unsigned long)" ( keybd_event@@$$J216YGXEEKK@Z) referenced in function "private: void __clrcall MyApp::Form1::button2_Click(class System::Object ^,class System::EventArgs ^)" ( button2_Click@Form1@MyApp@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>MyApp.obj : error LNK2019: unresolved external symbol "extern "C" void __stdcall keybd_event(unsigned char,unsigned char,unsigned long,unsigned long)" ( keybd_event@@$$J216YGXEEKK@Z) referenced in function "private: void __clrcall MyApp::Form1::button2_Click(class System::Object ^,class System::EventArgs ^)" ( button2_Click@Form1@MyApp@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
    1>C:\Documents and Settings\Gal Beniamini\My Documents\Visual Studio 2005\Projects\MyApp\Debug\MyApp.exe : fatal error LNK1120: 2 unresolved externals
    *************************************************************************
    With Thanks,
                          Gal Beniamini.


  • Capturing Screen