Guest User

Untitled

a guest
Mar 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <cstring>
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <conio.h>
  6. #include <windows.h>
  7. #include <winuser.h>
  8.  
  9.  
  10. #define STR_SIZE 256
  11. #define BUFSIZE 65535
  12. #define SHIFTED 0x8000
  13.  
  14.  
  15. int main() {
  16.  
  17. setlocale(LC_ALL, "rus");
  18. HANDLE hIn, hOut;
  19. DWORD size = STR_SIZE;
  20. char result[STR_SIZE];
  21.  
  22. FreeConsole();
  23. AllocConsole();
  24. SetConsoleOutputCP(1251);
  25.  
  26. hIn = GetStdHandle(STD_INPUT_HANDLE);
  27. hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  28.  
  29. GetDC(NULL); // дескриптор стола
  30. POINT p; // структура для координат
  31. COORD cord; // структура COORD, которая указывает позицию курсора
  32.  
  33. cord.X = 0; // координата X структуры COORD
  34. cord.Y = 0; // координата Y структуры COORD
  35.  
  36. //------------------------------------------------------------------
  37.  
  38.  
  39. HWND hwndMain;
  40. HACCEL haccl;
  41. UINT uMsg;
  42. UINT wParam;
  43. LONG lParam;
  44. HWND hwnd;
  45. MSG msg;
  46.  
  47. switch (wParam)
  48. {
  49. case 0x10:
  50.  
  51. /*SHIFT key.*/
  52. printf("SHIFT pressed", wParam);
  53.  
  54. break;
  55.  
  56. case 0x11:
  57.  
  58. /*CTRL key.*/
  59. printf("CTRL pressed", wParam);
  60.  
  61. break;
  62. case 0x12:
  63.  
  64. /*ALT key. */
  65. printf("ALT pressed", wParam);
  66.  
  67. break;
  68. default:
  69.  
  70. printf("OTHER pressed", wParam);
  71. /* Обработка воспроизводимых символов. */
  72.  
  73. break;
  74. }
  75.  
  76. while (GetMessage(&msg, (HWND)NULL, 0, 0))
  77. {
  78. if (TranslateAccelerator(hwndMain, haccl, &msg) == 0)
  79. {
  80. TranslateMessage(&msg);
  81. DispatchMessage(&msg);
  82. }
  83. }
  84. //-----------------------------------------------------------------------------
  85.  
  86. while (1) {
  87. wsprintf(result, "Позиция курсора: ");
  88. WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
  89. GetCursorPos(&p);
  90. wsprintf(result, "x = %4ld, y = %4ldrn", p.x, p.y);
  91. WriteConsole(hOut, result, strlen(result), nullptr, nullptr);
  92. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), cord);
  93. }
  94. return 0;
  95. }
Add Comment
Please, Sign In to add comment