哈哈哈,cmd系列我又更新了,新增了两个快捷键,Ctrl+alt+D打开/关闭窗口,Ctrl+alt+F窗口化极域(安照某软件来的)其余去前文看(点这)
#include<bits/stdc++.h>
#include<windows.h>
using namespace std;
DWORD WINAPI wind(LPVOID lpParameter)
{
bool f=1;
// 注册两个热键 Ctrl+F4
if (0 == RegisterHotKey(NULL, 1,MOD_CONTROL|MOD_ALT,'D')) {
cout << "RegisterHotKey error : " << GetLastError() << endl;
}
if (0 == RegisterHotKey(NULL, 2,MOD_CONTROL|MOD_ALT,'F')) {
cout << "RegisterHotKey error : " << GetLastError() << endl;
}
// 消息循环
MSG msg = { 0 };
while (GetMessage(&msg, NULL, 0, 0)){
HWND window = GetConsoleWindow();
switch (msg.message) {
case WM_HOTKEY:
{
if (1 == msg.wParam) {
if(f)ShowWindow(window,SW_MINIMIZE);//最小化 hwnd 所代表的窗口
else ShowWindow(window,SW_RESTORE);//最大化 hwnd 所代表的窗口
f=1-f;
}if(2==msg.wParam){
//获取广播窗口句柄
HWND bdCst = FindWindow(NULL, "屏幕广播");
//模拟点击
PostMessage(bdCst, WM_COMMAND, WPARAM((BM_CLICK << 16) | 1004), NULL);
}
break;
}
default:
break;
}
}
}
DWORD WINAPI mouse(LPVOID lpParameter)
{
srand(time(0));
while (1)
{
HWND window = GetConsoleWindow();
SetWindowPos(window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
return 0L;
}
HHOOK kbdHook;
LRESULT CALLBACK HookProc(int nCode, WPARAM wParam, LPARAM lParam){
return FALSE;
}
DWORD WINAPI KeyHookThreadProc(LPVOID lpParameter) {
while (true) {
kbdHook = (HHOOK)SetWindowsHookEx(WH_KEYBOARD_LL, (HOOKPROC)HookProc, GetModuleHandle(NULL), 0);
_sleep(100);
UnhookWindowsHookEx(kbdHook);
//打开符号链接
HANDLE hDevice = CreateFile("\\\\.\\TDKeybd", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if (!GetLastError()) {
BOOL bEnable = TRUE;
//发送控制代码
DeviceIoControl(hDevice, 0x220000, &bEnable, 4, NULL, 0, NULL, NULL);
CloseHandle(hDevice);
}
}
return 0;
}
int main(){
string s;
HANDLE hThread = CreateThread(NULL, 0, mouse, NULL, 0, NULL);
HANDLE hThread2 = CreateThread(NULL, 0, KeyHookThreadProc, NULL, 0, NULL);
HANDLE hThread3 = CreateThread(NULL, 0, wind, NULL, 0, NULL);
cout<< "Microsoft Windows [版本 10.0.19045.3324]\n(c) Microsoft Corporation。保留所有权利。\n\n";
while(1){
cout<<"C:\\Users\\HP\\Desktop>";
getline(cin,s);
if(s=="cmd"){
cout<< "Microsoft Windows [版本 10.0.19045.3324]\n(c) Microsoft Corporation。保留所有权利。\n\n";
}else if(s=="kill")
{
system("TASKKILL /F /IM StudentMain.exe /T");
}else if(s=="smallwin"){
//获取广播窗口句柄
HWND bdCst = FindWindow(NULL, "屏幕广播");
//模拟点击
PostMessage(bdCst, WM_COMMAND, WPARAM((BM_CLICK << 16) | 1004), NULL);
}else{
system(s.c_str());
}
}
}