Morozov_I_V_Labs/Project2/Project1/hello.c
2023-11-23 01:35:15 +03:00

116 lines
3.3 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#define _CRT_SECURE_NO_WARNINGS
#include <windows.h>
#include <direct.h>
#include <stdio.h>
#include <tchar.h>
#include <locale.h>
#include <conio.h>
TCHAR szDrive[] = _T(" A:");
int main()
{
setlocale(LC_ALL, "ru_RU.UTF8");
SetConsoleOutputCP(65001);
SetConsoleCP(65001);
//getKeyboardState();
//getKeyState();
//getAsyncKeyState();
setclipCursor();
//swapMouseButton();
return 0;
}
int getKeyboardState() {
BYTE keystate[256]; static prevKeys[256];
if (GetKeyboardState(keystate))
wprintf(L"Успешно получен статус клавиш\n");
else
wprintf(L"Не получен статус клавиш\n");
wprintf(L"Статус левой кнопки мыши: ");
if ((GetAsyncKeyState(VK_LBUTTON) & 0x8000) != 0)
wprintf(L"Активна \n");
else
wprintf(L"Неактивна\n");
wprintf(L"Статус левго CONTROL: ");
if ((GetAsyncKeyState(VK_LCONTROL) & 0x8000) != 0)
wprintf(L"Активен\n");
else
wprintf(L"Неактивен\n");
return 0;
}
int getKeyState() {
while (TRUE)
{
SHORT keyState = GetKeyState(VK_SPACE);
//if (keyState & 0x8000)
if (keyState)
{
system("cls");
wprintf(L"Нажат Пробел");
}
}
return 0;
}
int getAsyncKeyState() {
POINT pt;
while (TRUE) {
if (GetAsyncKeyState(VK_LBUTTON) & 1)
{
system("cls");
wprintf(L"Нажата левая кнопка мыши\n");
GetCursorPos(&pt);
wprintf(L"Коорднаты курсора: %d,%d\n", pt.x, pt.y);
}
if (GetAsyncKeyState(VK_RBUTTON) & 1)
{
system("cls");
wprintf(L"Нажата правая кнопка мыши\n");
GetCursorPos(&pt);
wprintf(L"Коорднаты курсора: %d,%d\n", pt.x, pt.y);
}
if (GetAsyncKeyState(VK_ESCAPE) & 0x8000) {
system("cls");
wprintf(L"Нажат Выход");
break;
}
}
return 0;
}
int setclipCursor() {
wprintf(L"Ограничение курсора: включено\n");
SetCaretBlinkTime(1000);
SetCursorPos(0, 0);
RECT r;
char string[10] = "";
r.left = 100;
r.top = 100;
r.right = 200;
r.bottom = 200;
ClipCursor(&r);
wprintf(L"Для снятия ведите любой символ с клавиатуры\n");
scanf(" %s", string);
ClipCursor(NULL);
//SetCaretBlinkTime(1000);
wprintf(L"Ограничение курсора: выключено\n");
return 0;
}
int swapMouseButton() {
wprintf(L"Метрика перестановки кнопок мыши: %d\n",GetSystemMetrics(SM_SWAPBUTTON));
SwapMouseButton(TRUE);
wprintf(L"Метрика перестановки кнопок мыши: %d\n", GetSystemMetrics(SM_SWAPBUTTON));
char string[10] = "";
wprintf(L"Для отмены ведите любой символ с клавиатуры\n");
scanf(" %s", string);
SwapMouseButton(FALSE);
wprintf(L"Метрика перестановки кнопок мыши: %d\n", GetSystemMetrics(SM_SWAPBUTTON));
return 0;
}