Discovery Gaming Community
Print Screen button not taking Screenshots - Printable Version

+- Discovery Gaming Community (https://discoverygc.com/forums)
+-- Forum: Welcome (https://discoverygc.com/forums/forumdisplay.php?fid=399)
+--- Forum: Help & Support (https://discoverygc.com/forums/forumdisplay.php?fid=26)
+---- Forum: Tutorials & Tools (https://discoverygc.com/forums/forumdisplay.php?fid=178)
+----- Forum: Community Technical Guides (https://discoverygc.com/forums/forumdisplay.php?fid=745)
+----- Thread: Print Screen button not taking Screenshots (/showthread.php?tid=188263)

Pages: 1 2


Print Screen button not taking Screenshots - ronillon - 05-25-2021

As you might know, it is possible to take screenshots in Freelancer without the use of external programs.

If everything works fine, you press "Print Screen" key and a BMP file with screenshot is created in c:\Users\%username%\Pictures\FreelancerShots\
This should work pretty much everywhere in Freelancer, from the MAIN MENU to the Bar on Planet Curacao.

Recently this stopped working for me.
And it appears that it does not work for others and has not worked for others in the past: Screenshots for Freelancer

Of course it is possible to take screenshots using external tools like Steam, Xfire, Fraps, programs associated with your GPU and many others.
But I decided to figure out why the native screenshot functionality was no longer working.

It turned out, that the culprit was Avast Antivirus Anti-Malware Shield.
Disabling this shield or setting Freelancer as exception in the shield settings solved the issue.

Hope this helps someone


RE: Print Screen button not taking Screenshots - Xenon - 05-25-2021

after taking a print screen, go to desktop and create a new BMP or paint file, then right click on it, then select edit, and cltr+v, then save Wink


RE: Print Screen button not taking Screenshots - ronillon - 05-25-2021

You can also CTRL+V to Discord or other apps.


RE: Print Screen button not taking Screenshots - Xenon - 05-25-2021

(05-25-2021, 04:21 AM)ronillon Wrote: You can also CTRL+V to Discord or other apps.

Thats amazing!


RE: Print Screen button not taking Screenshots - Save My Soul - 05-26-2021

Or you can just press Win+PrtScr if you're using Windows 10. And you'll find that images in "...\Pictures\Screenshots".


RE: Print Screen button not taking Screenshots - sindroms - 05-26-2021

How on earth did you manage to break this...


RE: Print Screen button not taking Screenshots - Laz - 05-26-2021

If you can convince @Alex. to implement this, here is some code wrote that makes print screen not use the stupid FL system, and instead takes nice .png files that are properly categorised by date.

Code:
#define min std::min
#define max std::max
#include <gdiplus.h>
#undef min
#undef max


    using namespace Gdiplus;

    int GetEncoderClsid(const WCHAR* format, CLSID* pClsid)
    {
        UINT  num = 0;          // number of image encoders
        UINT  size = 0;         // size of the image encoder array in bytes

        ImageCodecInfo* pImageCodecInfo = nullptr;

        GetImageEncodersSize(&num, &size);
        if (size == 0)
            return -1;  // Failure

        pImageCodecInfo = (ImageCodecInfo*)(malloc(size));
        if (pImageCodecInfo == nullptr)
            return -1;  // Failure

        GetImageEncoders(num, size, pImageCodecInfo);

        for (UINT j = 0; j < num; ++j)
        {
            if (wcscmp(pImageCodecInfo[j].MimeType, format) == 0)
            {
                *pClsid = pImageCodecInfo[j].Clsid;
                free(pImageCodecInfo);
                return j;  // Success
            }
        }
        free(pImageCodecInfo);
        return -1;  // Failure
    }


    DWORD PrintScreen()
    {
        char directory[MAX_PATH];
        if (!GetScreenShotPath(directory))
        {
            return DWORD(-1);
        }

        // get the device context of the screen
        HDC hScreenDC = GetDC(nullptr);

        // and a device context to put it in
        HDC hMemoryDC = CreateCompatibleDC(hScreenDC);

        int width = GetDeviceCaps(hScreenDC, HORZRES);
        int height = GetDeviceCaps(hScreenDC, VERTRES);

        // maybe worth checking these are positive values
        HBITMAP hBitmap = CreateCompatibleBitmap(hScreenDC, width, height);

        // get a new bitmap
        HBITMAP hOldBitmap = HBITMAP(SelectObject(hMemoryDC, hBitmap));

        BitBlt(hMemoryDC, 0, 0, width, height, hScreenDC, 0, 0, SRCCOPY);
        hBitmap = (HBITMAP)SelectObject(hMemoryDC, hOldBitmap);

        std::time_t rawtime;
        std::tm* timeinfo;
        char buffer[80];

        std::time(&rawtime);
        timeinfo = std::localtime(&rawtime);

        std::strftime(buffer, 80, "%Y-%m-%d", timeinfo);
        std::puts(buffer);

        std::string dir = std::string(directory) + "/" + std::string(buffer) + "/";
        std::filesystem::create_directories(dir);

        std::strftime(buffer, 80, "%H-%M-%S", timeinfo);
        std::puts(buffer);
        std::string file = std::string(buffer) + ".png";

        GdiplusStartupInput gdiplusStartupInput;
        ULONG_PTR gdiplusToken;
        GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
        Bitmap* image = new Bitmap(hBitmap, nullptr);

        CLSID myClsId;
        GetEncoderClsid(L"image/png", &myClsId);

        Status status = image->Save((WCHAR*)Utils::String::stows(dir + file).c_str(), &myClsId, nullptr);
        delete image;

        GdiplusShutdown(gdiplusToken);

        // clean up
        DeleteDC(hMemoryDC);
        DeleteDC(hScreenDC);

        return DWORD(-1);
    }
    
    void HackPrintScreen()
    {
        #define PrintScreenEntryPoint ((PBYTE)0x425170)
        ProtectExecuteReadWrite(PrintScreenEntryPoint, 5);
        PrintScreenEntryPoint[0] = 0xe9;
        *(DWORD*)(PrintScreenEntryPoint + 1) = PBYTE(PrintScreen) - PrintScreenEntryPoint - 5;
    }



RE: Print Screen button not taking Screenshots - Kauket - 05-26-2021

(05-26-2021, 01:26 PM)sindroms Wrote: How on earth did you manage to break this...

It stopped working for me the other day too. Just printed out only black screens or not taking anything at all. I thought it was because of my tv connected via hdmi shut off. The screen goes black for a blink of a moment


RE: Print Screen button not taking Screenshots - Hokan - 05-26-2021

Alternatively, If you're using Win 10 you can press and hold the keys: WIN+SHIFT+S.
It will freeze your screen so that you can then make a selection which is saved to your clipboard. Then you can paste it and save it.


RE: Print Screen button not taking Screenshots - St.Denis - 05-26-2021

I have Windows 10 and all I need to do is press PrtSc and the picture is saved in a Freelancer Folder in Pictures.