SFML community forums
General => SFML projects => Topic started by: spacechase0 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:
(http://tools.spacechase0.com/files/2012/10/quicksnap-close.png)
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 (http://tools.spacechase0.com/files/2012/10/0.1.1-Quicksnap.zip)
Version 0.1.0: Download (http://tools.spacechase0.com/files/2012/10/QuickSnap.zip)
The source code is here (https://github.com/spacechase0/QuickSnap).
Changelog
[10/25/2012] Initial Release
[11/5/2012] Fixed issue with images being washed out on some computers.
-
Sounds a lot like Microsoft's Clipping Tool.
More interesting question: How far is SFML involved? Would it work cross-platform, etc.?
-
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.
-
Very nice. I would love to take a look at the source code.
-
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).
-
Added the source code here (https://github.com/spacechase0/QuickSnap).
I didn't end up actually cleaning it up much, just organizing it into multiple files. :P
-
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
-
main.cpp, line 10:
Where did you get those numbers from?!?! Hex editor?
Which numbers? I don't see anything, see here (https://github.com/spacechase0/QuickSnap/blob/master/src/main.cpp#L10).
-
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.
-
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 (https://raw.github.com/spacechase0/QuickSnap/master/src/main.cpp) shows it though.
-
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 (http://pastebin.com/tZYQfeCS)
-
Uploaded a new version which fixes an issue with washed-out images on some computers.