-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyLibrary.h
More file actions
186 lines (179 loc) · 5.24 KB
/
MyLibrary.h
File metadata and controls
186 lines (179 loc) · 5.24 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#include<windows.h>
#include<bits/stdc++.h>
#pragma comment(lib, "winmm.lib")
#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
HCRYPTPROV prov;
HWND hwnd = GetDesktopWindow();
HDC hdc = GetWindowDC(hwnd);
POINT cursor;
int cursor_freq = 0;
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
using namespace std;
void full_screen()
{
HWND hwnd = GetForegroundWindow();
int cx = GetSystemMetrics(SM_CXSCREEN);
int cy = GetSystemMetrics(SM_CYSCREEN);
LONG l_WinStyle = GetWindowLong(hwnd,GWL_STYLE);
SetWindowLong(hwnd,GWL_STYLE,(l_WinStyle | WS_POPUP | WS_MAXIMIZE) & ~WS_CAPTION & ~WS_THICKFRAME & ~WS_BORDER);
SetWindowPos(hwnd, HWND_TOP, 0, 0, cx, cy, 0);
}
void gotoxy(short x,short y) {
COORD pos={x,y};
HANDLE hOut=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut,pos);
}
void SetColorAndBackground(int ForgC, int BackC) {
WORD wColor = ((BackC & 0x0F) << 4) + (ForgC & 0x0F);
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), wColor);
}
void Typer(string totype, int sleeptime,bool isendl) {
int len = totype.length();
for (int i = 0; i < len; i++) {
cout << totype[i];
Sleep(sleeptime);
}if (isendl)cout << endl;
}
int ClrScr(){
gotoxy(0,0);
for(int i=0;i<100;i++){
for(int i=0;i<100;i++){
cout<<" ";
}cout<<endl;
}gotoxy(0,0);
}
void ErrorIcon(int looptimes,bool ShowLooptimes){
int j=0;
for (int i = 0; i < looptimes; i++)
{
cout<<"\rLoop: "<<j+1<<" of "<<looptimes;
GetCursorPos(&cursor);
DrawIcon(hdc, cursor.x * 1.75, cursor.y * 1.75, LoadIcon(NULL, IDI_ERROR));
Sleep(0.5);
j++;
}
}
void WarningIcon(int looptimes,bool ShowLooptimes){
int j=0;
for (int i = 0; i < looptimes; i++)
{
if(ShowLooptimes)cout<<"\rLoop: "<<j+1<<" of "<<looptimes;
GetCursorPos(&cursor);
DrawIcon(hdc, cursor.x * 1.75, cursor.y * 1.75, LoadIcon(NULL, IDI_WARNING));
Sleep(0.5);
j++;
}
}
void InfoIcon(int looptimes,bool ShowLooptimes){
int j=0;
for (int i = 0; i < looptimes; i++)
{
if(ShowLooptimes)cout<<"\rLoop: "<<j+1<<" of "<<looptimes;
GetCursorPos(&cursor);
DrawIcon(hdc, cursor.x * 1.75, cursor.y * 1.75, LoadIcon(NULL, IDI_INFORMATION));
Sleep(0.5);
j++;
}
}
int random()
{
if (prov == NULL)
if (!CryptAcquireContext(&prov, NULL, NULL, PROV_RSA_FULL, CRYPT_SILENT | CRYPT_VERIFYCONTEXT))
ExitProcess(1);
int out;
CryptGenRandom(prov, sizeof(out), (BYTE*)(&out));
return out & 0x7fffffff;
}
void MouseError(int looptimes,bool ShowLooptimes){
int j=0;
for (int i = 0; i < looptimes; i++)
{
if(ShowLooptimes)cout<<"\rLoop: "<<j+1<<" of "<<looptimes;
GetCursorPos(&cursor);
SetCursorPos(cursor.x + (random() % 3 - 1) * (random() % (cursor_freq / 2200 + 2)), cursor.y + (random() % 3 - 1) * (random() % (cursor_freq / 2200 + 2)));
j++;
Sleep(0.2);
}
}
int ToTop(){
HWND hWnd = ::GetForegroundWindow();
::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 100, 100, SWP_NOMOVE | SWP_NOSIZE);
return FALSE;
}
void ShakeWindow(int looptimes,int ShakeSize,bool ShowLooptimes){
RECT rect;
HWND hwnd = NULL,oldhwnd = NULL;
int j=0,x,y,width,height;
for(int i=0;i<looptimes;i++)
{
if(ShowLooptimes)cout<<"\rLoop: "<<j+1<<" of "<<looptimes;
hwnd = GetForegroundWindow();
if(hwnd!=oldhwnd)
{
GetWindowRect(hwnd,&rect);
x = rect.left;
y = rect.top;
width = rect.right - x;
height = rect.bottom - y;
oldhwnd = hwnd;
}
MoveWindow(hwnd,x-ShakeSize,y,width,height,TRUE);
Sleep(5); //ÔÝÍ£5ºÁÃë
MoveWindow(hwnd,x-ShakeSize,y-10,width,height,TRUE);
Sleep(5);
MoveWindow(hwnd,x,y-ShakeSize,width,height,TRUE);
Sleep(5);
MoveWindow(hwnd,x,y,width,height,TRUE);
Sleep(5);j++;
}
}
bool DisableConsoleWindowCloseButton()
{
HWND consoleWnd = GetConsoleWindow();
if (NULL == consoleWnd)
{
return false;
}
HMENU systemMenu = GetSystemMenu(consoleWnd, FALSE);
if (NULL == systemMenu)
{
return false;
}
return EnableMenuItem(systemMenu, SC_CLOSE, MF_BYCOMMAND | MF_DISABLED) != FALSE;
}
bool DisableConsoleWindowSize()//Unusable
{
HWND consoleWnd = GetConsoleWindow();
if (NULL == consoleWnd)
{
return false;
}
HMENU systemMenu = GetSystemMenu(consoleWnd, FALSE);
if (NULL == systemMenu)
{
return false;
}
return EnableMenuItem(systemMenu, SC_SIZE, MF_BYCOMMAND | MF_GRAYED) != FALSE;
}
bool DisableConsoleWindowMinisizeButton()//Unusable
{
HWND consoleWnd = GetConsoleWindow();
if (NULL == consoleWnd)
{
return false;
}
HMENU systemMenu = GetSystemMenu(consoleWnd, FALSE);
if (NULL == systemMenu)
{
return false;
}
return EnableMenuItem(systemMenu, SC_MINIMIZE, MF_BYCOMMAND | MF_GRAYED) != FALSE;
}
/*int screenfuck(){ //Unusable[ERROR]
for (int i = 0; i < 30; i++)
{
StretchBlt(hdc, 50, 50, cx * 1.75 - 100, cy * 1.75 - 100, hdc, 0, 0, cx * 1.75, cy * 1.75, SRCCOPY);
Sleep(300);
}
}*/