Answer the question
In order to leave comments, you need to log in
How to implement pressing Ctrl and Shift keys in C/C++ language?
Having read articles on MSDN related to pressing and subsequent output, I would like to see an example of a working code. We need to add them to the program.
I will be grateful.
#include "stdafx.h"
#include <cstring>
#include <iostream>
#include <stdio.h>
#include <conio.h>
#include <windows.h>
using namespace std;
#define STR_SIZE 256
int main() {
setlocale(LC_ALL, "rus");
HANDLE hIn, hOut;
DWORD size = STR_SIZE;
char result[STR_SIZE];
FreeConsole();
AllocConsole();
SetConsoleOutputCP(1251);
hIn = GetStdHandle(STD_INPUT_HANDLE);
hOut = GetStdHandle(STD_OUTPUT_HANDLE);
GetDC(NULL); // дескриптор стола
POINT p; // структура для координат
COORD cord; // структура COORD, которая указывает позицию курсора
cord.X = 0; // координата X структуры COORD
cord.Y = 0; // координата Y структуры COORD
while (1) {
wsprintf(result, "Позиция курсора: ");
WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
GetCursorPos(&p);
wsprintf(result, "x = %4ld, y = %4ld\r\n", p.x, p.y);
WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cord);
}
return 0;
}
Answer the question
In order to leave comments, you need to log in
See an example of using SendInput
here: https://batchloaf.wordpress.com/2012/10/18/simulat...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question