-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_sequential_screenshot.cpp
58 lines (39 loc) · 1.11 KB
/
test_sequential_screenshot.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//this is a screenshot project .
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <fstream>
int Screenshot();
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
RegisterHotKey(
NULL,
1,
MOD_ALT,
0x42);
//0x42 is 'b'
//when it receives a certain key ,it will modify the msg .then the msg will have valid value
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
if (msg.message == WM_HOTKEY)
{
Screenshot();
}
}
return 0;
}
int Screenshot()
{
/*HWND hWnd = GetConsoleWindow ();
ShowWindow (hWnd, SW_HIDE); //hide the Console Window ,if your build target is console application I guess .
Sleep (1000);*/
static int count = 0 ; // count variable
TCHAR TxtName[10] = {0};
//************************name part ********************
_stprintf(TxtName, _T("D:\\test\\%d.png"), ++count);
std::ofstream f ;
f.open(TxtName,std::ios::app);
f << "the count value now is : " << count ;
return 0;
}