Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <cstring>
- #include <iostream>
- #include <stdio.h>
- #include <conio.h>
- #include <windows.h>
- #include <winuser.h>
- #define STR_SIZE 256
- #define BUFSIZE 65535
- #define SHIFTED 0x8000
- 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
- //------------------------------------------------------------------
- HWND hwndMain;
- HACCEL haccl;
- UINT uMsg;
- UINT wParam;
- LONG lParam;
- HWND hwnd;
- MSG msg;
- switch (wParam)
- {
- case 0x10:
- /*SHIFT key.*/
- printf("SHIFT pressed", wParam);
- break;
- case 0x11:
- /*CTRL key.*/
- printf("CTRL pressed", wParam);
- break;
- case 0x12:
- /*ALT key. */
- printf("ALT pressed", wParam);
- break;
- default:
- printf("OTHER pressed", wParam);
- /* Обработка воспроизводимых символов. */
- break;
- }
- while (GetMessage(&msg, (HWND)NULL, 0, 0))
- {
- if (TranslateAccelerator(hwndMain, haccl, &msg) == 0)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- //-----------------------------------------------------------------------------
- while (1) {
- wsprintf(result, "Позиция курсора: ");
- WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
- GetCursorPos(&p);
- wsprintf(result, "x = %4ld, y = %4ldrn", p.x, p.y);
- WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
- SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cord);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment