• Home
  • Index
  • Search
  • Download
  • Server Rules
  • House Roleplay Laws
  • Player Utilities
  • Player Help
  • Forum Utilities
  • Returning Player?
  • Toggle Sidebar
Interactive Nav-Map
Tutorials
New Wiki
ID reference
Restart reference
Players Online
Player Activity
Faction Activity
Player Base Status
Discord Help Channel
DarkStat
Server public configs
POB Administration
Missing Powerplant
Stuck in Connecticut
Account Banned
Lost Ship/Account
POB Restoration
Disconnected
Member List
Forum Stats
Show Team
View New Posts
View Today's Posts
Calendar
Help
Archive Mode




Hi there Guest,  
Existing user?   Sign in    Create account
Login
Username:
Password: Lost Password?
 
  Discovery Gaming Community Welcome Help & Support Tutorials & Tools Community Technical Guides
1 2 Next »
Print Screen button not taking Screenshots

Server Time (24h)

Players Online

Active Events - Scoreboard
Corsair Kills - 1 / 1,000
Lawful Kills - 13 / 1,000
Red Hessian Kills - 1 / 1,000
Unlawful Kills - 8 / 1,000

Latest activity

Print Screen button not taking Screenshots
Offline Laz
05-26-2021, 01:40 PM,
#7
(Sorta) Retired Code Monkey
Posts: 1,905
Threads: 106
Joined: Jan 2014

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;
    }

Reply  


Messages In This Thread
Print Screen button not taking Screenshots - by ronillon - 05-25-2021, 04:10 AM
RE: Print Screen button not taking Screenshots - by Xenon - 05-25-2021, 04:19 AM
RE: Print Screen button not taking Screenshots - by ronillon - 05-25-2021, 04:21 AM
RE: Print Screen button not taking Screenshots - by Xenon - 05-25-2021, 04:24 AM
RE: Print Screen button not taking Screenshots - by Save My Soul - 05-26-2021, 10:15 AM
RE: Print Screen button not taking Screenshots - by sindroms - 05-26-2021, 01:26 PM
RE: Print Screen button not taking Screenshots - by Kauket - 05-26-2021, 01:43 PM
RE: Print Screen button not taking Screenshots - by Save My Soul - 05-26-2021, 02:42 PM
RE: Print Screen button not taking Screenshots - by Laz - 05-26-2021, 01:40 PM
RE: Print Screen button not taking Screenshots - by Hokan - 05-26-2021, 01:43 PM
RE: Print Screen button not taking Screenshots - by St.Denis - 05-26-2021, 02:26 PM
RE: Print Screen button not taking Screenshots - by Skorak - 05-26-2021, 02:44 PM

  • View a Printable Version
  • Subscribe to this thread


Users browsing this thread:
1 Guest(s)



Powered By MyBB, © 2002-2026 MyBB Group. Theme © 2014 iAndrew & DiscoveryGC
  • Contact Us
  •  Lite mode
Linear Mode
Threaded Mode