Created
March 29, 2016 15:46
-
-
Save khuangaf/3a74494e1a816cc660aa to your computer and use it in GitHub Desktop.
Screenshot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdlib> | |
#include <cstddef> | |
#include <windows.h> | |
#include <string> | |
#include <iostream> | |
#define MOD_NOREPEAT 0x4000 | |
#define MOD_ALT 0x0001 | |
using namespace std; | |
void shortCut(int argc, TCHAR *argv[]); | |
int main(int argc, TCHAR *argv[]) | |
{ | |
while(1) | |
shortCut(0, (TCHAR **)'a'); | |
return 0; | |
} | |
void shortCut(int argc, TCHAR *argv[]) | |
{ | |
if (RegisterHotKey(NULL, 1, MOD_ALT | MOD_NOREPEAT, 0x58)) //0x58 is 'x' | |
{ | |
std::cout << "Please hide this window and press ALT+x to screenshot\n"; | |
} | |
MSG msg = { 0 }; | |
if ((GetMessage(&msg, NULL, 0, 0) != 0)) | |
{ | |
if (msg.message == WM_HOTKEY) | |
{ | |
char path[] = "C:\\Windows\\System32\\SnippingTool.exe"; | |
system(path); | |
std::cout << "WM_HOTKEY received\n"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment