星际战甲挂机
Dreamlands · · 个人记录
/*
更新日记:
1.01(2020/3/22):现在用户能够更加容易地更改操作键(作者增加了ctrl等简洁明了,一步到位的更改操作的量)
1.02(2020/3/22):更改窗口界面,显示出了默认操作键 .
*/
#include<bits/stdc++.h>
#include<windows.h>
#include <Windows.h>
#include <stdio.h>
bool f=false,f1=false,f2;
#define shift (GetKeyState(VK_SHIFT)&0x8000)
#define ctrl (GetKeyState(VK_CONTROL)&0x8000)
#define alt (GetKeyState(VK_MENU)&0x8000)
#define tab (GetKeyState(VK_TAB)&0x8000)
#define caps_lock (GetKeyState(VK_CAPITAL)&0x8000)
#define esc (GetKeyState(VK_ESCAPE)&0x8000)
#define enter (GetKeyState(VK_RETURN)&0x8000)
#define space (GetKeyState(VK_SPACE)&0x8000)
#define one (GetKeyState(int('1'))&0x8000)
#define two (GetKeyState(int('2'))&0x8000)
#define three (GetKeyState(int('3'))&0x8000)
#define four (GetKeyState(int('4'))&0x8000)
#define five (GetKeyState(int('5'))&0x8000)
#define six (GetKeyState(int('6'))&0x8000)
#define seven (GetKeyState(int('7'))&0x8000)
#define eight (GetKeyState(int('8'))&0x8000)
#define nine (GetKeyState(int('9'))&0x8000)
void MouseLeftDown() { //鼠标左键按下
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &Input, sizeof(INPUT));
}
void MouseLeftUp() { //鼠标左键放开
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &Input, sizeof(INPUT));
}
void MouseMiddleDown() { //鼠标中键按下
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
SendInput(1, &Input, sizeof(INPUT));
}
void MouseMiddleUp() { //鼠标中键放开
INPUT Input = { 0 };
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
SendInput(1, &Input, sizeof(INPUT));
}
void ld() {
int a,b,i;
b=500;//根据计算机cpu好坏以及个人需求决定间隔时间,此处b=1000时,为1秒
MouseLeftUp();
Sleep(550);
MouseLeftDown();
Sleep(2500);
MouseMiddleDown();
MouseMiddleUp();
// Sleep(b);
return;
}
using namespace std;
int main() {
cout<<"默认操作如下:\n";
cout<<"按下ctrl+1开启 ctrl+2关闭(按下ctrl+1开,按下ctrl+2关).\n";
cout<<"按下ctrl+3彻底关闭exe. \n";
cout<<"ctrl+4隐藏,ctrl+5显示,ctrl+6最大化\n";
cout<<"请勿把鼠标指针移动到此程序上——Destiny\n";
HWND hWnd= GetForegroundWindow();
srand((unsigned)time(NULL));
while(1) {
if(ctrl&&one) {
f=true;
}
if(ctrl&&two) {
f=false;
}
if(ctrl&&three) {
return 0;
}
if(ctrl&&four) {
ShowWindow(hWnd,SW_HIDE);
}
if(ctrl&&five) {
ShowWindow(hWnd,SW_SHOW);
}
if(ctrl&&six) {
if(f2==0) {
f2=1;
} else {
f2=0;
}
}
if(f2==1) {
ShowWindow(hWnd,SW_RESTORE);
}
if(f==true) {
ld();
}
}
return 0;
}
/*
补:
GetKeyState括号中的是一个int变量,可将VK_SHIFT改为:
int('q'),q为按键名称
MessageBox+cout都会与getkeystate会发生冲突 ???
正在测试ing
*/