Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- #include <map>
- using namespace std;
- class key {
- public:
- map<string, WORD> keys;
- void add(string name, WORD input) {
- pair<string, WORD> temp(name, input);
- keys.insert(temp);
- }
- key() {
- this->add("tab", 0x09);
- this->add("alt", 0x12);
- this->add("up", 0x26);
- this->add("down", 0x28);
- this->add("left", 0x25);
- this->add("right", 0x27);
- this->add("a", 0x41);
- this->add("LCLICK", 0x01);
- this->add("RCLICK", 0x02);
- }
- WORD operator[](string input) {
- WORD returnObject = this->keys[input];
- return returnObject;
- }
- };
- class keyboardInput{
- public:
- INPUT ip;
- key keys;
- keyboardInput() {
- Sleep(5000);
- ip.type = INPUT_KEYBOARD;
- ip.ki.wScan = 0;
- ip.ki.time = 0;
- ip.ki.dwExtraInfo = 0;
- }
- void mouse(int x , int y) {
- ip.type = INPUT_MOUSE;
- ip.mi.mouseData = 0;
- ip.mi.dx = x * (65536 / GetSystemMetrics(SM_CXSCREEN));
- ip.mi.dy = y * (65536 / GetSystemMetrics(SM_CXSCREEN));
- ip.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
- SendInput(1, &ip, sizeof(INPUT));
- Sleep(500);
- ip.type = INPUT_KEYBOARD;
- }
- void press(WORD keyPress) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void press(string input) {
- WORD keyPress = this->keys[input];
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void press(WORD keyPress ,WORD keyPress2) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- ip.ki.wVk = keyPress2;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void press(WORD keyPress, int numberOfSeconds) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- Sleep(numberOfSeconds);
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void release(WORD keyPress) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void release(string input) {
- WORD keyPress = this->keys[input];
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void release(WORD keyPress ,WORD keyPress2) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- ip.ki.wVk = keyPress2;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void tap(WORD keyPress) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- Sleep(500);
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void tap(string input) {
- WORD tempWord = this->keys[input];
- ip.ki.wVk = tempWord;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- Sleep(500);
- ip.ki.wVk = tempWord;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- void hold(WORD keyPress, int time) {
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = 0;
- SendInput(1, &ip, sizeof(INPUT));
- Sleep(time);
- ip.ki.wVk = keyPress;
- ip.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &ip, sizeof(INPUT));
- }
- };
- void main() {
- keyboardInput temp;
- key key;
- temp.tap(key["alt"]);
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment