Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // EditMacroConsole.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <windows.h>
- #include <iostream>
- #include <fstream>
- using namespace std;
- void pressG()
- {
- INPUT ip;
- ip.type = INPUT_KEYBOARD;
- ip.ki.wScan = 0;
- ip.ki.time = 0;
- ip.ki.dwExtraInfo = 0;
- ip.ki.wVk = 0x47; //Hex code for 'D' 51 for Q
- ip.ki.dwFlags = 0; //Press the key down ?
- SendInput(1, &ip, sizeof(INPUT)); //Use function
- Sleep(50); //Sleep so it doesn't spam the key press
- ip.ki.dwFlags = KEYEVENTF_KEYUP; //Release the key
- SendInput(1, &ip, sizeof(INPUT)); //Use function
- }
- int main()
- {
- while (true) {
- if (GetAsyncKeyState('G') != 0) {
- cout << "G was pressed!" << endl;
- bool waitforup = false;
- bool mousenotpressed = true;
- bool waitforupright = false;
- bool mousenotpressedright = true;
- while (mousenotpressed == true && waitforup == false && mousenotpressedright == true) {
- if (GetAsyncKeyState(VK_LBUTTON) != 0 || GetAsyncKeyState(VK_RBUTTON) != 0) {
- if (GetAsyncKeyState(VK_LBUTTON)) {
- waitforup = true;
- mousenotpressed = false;
- cout << "Left Mouse pressed" << endl;
- }
- else {
- waitforupright = true;
- mousenotpressedright = false;
- cout << "Right Mouse pressed" << endl;
- }
- }
- }
- while (waitforup == true && mousenotpressed == false && waitforupright == false) {
- if (GetAsyncKeyState(VK_LBUTTON) == 0) {
- pressG();
- waitforup = false;
- mousenotpressed = true;
- cout << "Left Mouse released!" << endl;
- }
- }
- while (waitforupright == true && mousenotpressedright == false && waitforup == false) {
- if (GetAsyncKeyState(VK_RBUTTON) == 0) {
- pressG();
- waitforupright = false;
- mousenotpressedright = true;
- cout << "Right Mouse released!" << endl;
- }
- }
- }
- }
- }
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
- // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement