Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: QuickSnap - Screenshot program  (Read 6024 times)

0 Members and 1 Guest are viewing this topic.

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
QuickSnap - Screenshot program
« on: October 25, 2012, 06:17:29 pm »
(Not sure if anything else uses that name. It was the first thing I thought of. :P)

This is just a quick little tool to take screenshots. An IM program called Trillian allows me to directly paste an image from my clipboard into chat. I got tired doing this every time I wanted to screenshot something:

  • PrintScreen
  • G2 (I have a Logitech G19, I set this key to open MS-Paint)
  • Find the newly-opened Paint window
  • Ctrl+V
  • Crop
  • Ctrl+A
  • Ctrl+C

So, I made this. :) It works with multiple monitors (or at least, two same-sized monitors).

Starting the program appears to do nothing. Instead, it needs to be activated by a key combination:

Pressing Ctrl+PAGE_UP will lighten the entire screen, and a small black circle will follow your mouse. Now, click and drag, and a black rectangle will show the selection area. If you aren't happy with that rectangle, you can choose another. Once you've chosen an area, press enter. The white area and black rectangle should disappear, and the new screenshot will appear in your clipboard. It is also saved to "%APPDATA%/quicksnap".

If you want to close it for some reason, press Ctrl+PAGE_DOWN. A window should show up like this:



Pressing the red "No" button will let it continue running, and pressing the green "Yes" button will close it. Once it is closed, you can't do Ctrl+PAGE_UP anymore.

If you hadn't guessed by the "%APPDATA%" comment earlier, it's Windows-only (although it should be fairly easy to port). It would probably work great as a startup program though!

Download
Version 0.1.1: Download
Version 0.1.0: Download

The source code is here.

Changelog
Quote
[10/25/2012] Initial Release
[11/5/2012] Fixed issue with images being washed out on some computers.
« Last Edit: November 05, 2012, 05:29:05 pm by spacechase0 »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: QuickSnap - Screenshot program
« Reply #1 on: October 26, 2012, 03:44:44 pm »
Sounds a lot like Microsoft's Clipping Tool.

More interesting question: How far is SFML involved? Would it work cross-platform, etc.?

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
Re: QuickSnap - Screenshot program
« Reply #2 on: October 26, 2012, 04:47:48 pm »
Never heard of Microsoft's program. :P

At the moment SFML is used for for the global keyboard shortcuts (sf::Keyboard), opening the windows (and drawing on them), and saving the screenshot (sf::Image).

Currently, the windows API is used for:
  • Moving the window to a position - with multiple monitors, the origin isn't always (0, 0). (Just now realized sf::Window has a function for that...)
  • Making the window transparent - I copied some code from a recent forum post around here, which didn't work at first (like they said), but it fixed itself by the time I made the window across both monitors.
  • Forcing a window to always stay on top, and to have focus.
  • Getting the screen origin (see first item :P) and size, for multiple monitor support.
  • Getting the actual snapshot, and putting it in the clipboard.

I think Laurent has some of these (ie. multiple monitor support) planned, but I thought I saw at one point other things probably wouldn't happen (transparent windows, clipboard).

It should be fairly easy to port though, since I have everything OS-specific in separate functions.

Foaly

  • Sr. Member
  • ****
  • Posts: 453
    • View Profile
Re: QuickSnap - Screenshot program
« Reply #3 on: October 26, 2012, 05:52:50 pm »
Very nice. I would love to take a look at the source code.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: QuickSnap - Screenshot program
« Reply #4 on: October 27, 2012, 03:55:59 pm »
Microsoft's program has been part of OneNote's systray icon, which is now the standalone "Clipping Tool". There's no real UI to copy or show though (other than selecting how/where to save).

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
Re: QuickSnap - Screenshot program
« Reply #5 on: October 27, 2012, 04:36:06 pm »
Added the source code here.

I didn't end up actually cleaning it up much, just organizing it into multiple files. :P

Krofna

  • Newbie
  • *
  • Posts: 42
    • View Profile
    • Email
Re: QuickSnap - Screenshot program
« Reply #6 on: October 27, 2012, 09:49:08 pm »
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
« Last Edit: October 27, 2012, 09:50:53 pm by Krofna »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: QuickSnap - Screenshot program
« Reply #7 on: October 27, 2012, 11:33:53 pm »
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
Which numbers? I don't see anything, see here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: QuickSnap - Screenshot program
« Reply #8 on: October 27, 2012, 11:39:48 pm »
There are hex numbers there as const sf::Uint8 FONT[] to use load from memory on them, a bit like what sfml did before default font removal.
Back to C++ gamedev with SFML in May 2023

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: QuickSnap - Screenshot program
« Reply #9 on: October 27, 2012, 11:42:10 pm »
There are hex numbers there as const sf::Uint8 FONT[] to use load from memory on them, a bit like what sfml did before default font removal.
Oh GitHub simply suppressed that in the normal view. The RAW output shows it though.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
Re: QuickSnap - Screenshot program
« Reply #10 on: October 28, 2012, 01:10:44 am »
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
At one point Laurent had posted a code snippet that would dump a file like that. It had a few issues though, at least for me (sometimes it printed 3 extra bytes for a single 0x, which made a bunch of warnings :P), so I had to tweak it some.

Here's the tweaked code: http://pastebin.com/tZYQfeCS

spacechase0

  • Newbie
  • *
  • Posts: 39
    • AOL Instant Messenger - thespacechase0
    • View Profile
    • http://spacechase0.com/
Re: QuickSnap - Screenshot program
« Reply #11 on: November 05, 2012, 05:30:53 pm »
Uploaded a new version which fixes an issue with washed-out images on some computers.