192 lines
5.2 KiB
C
192 lines
5.2 KiB
C
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
//#define _UNICODE
|
|
//#define UNICODE
|
|
|
|
#include <windows.h>
|
|
#include <direct.h>
|
|
#include <fcntl.h>
|
|
#include <io.h>
|
|
#include <stdio.h>
|
|
#include <tchar.h>
|
|
#include <locale.h>
|
|
#include <string.h>
|
|
#include <wchar.h>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
|
|
|
|
|
|
void printGetKeyboardType();
|
|
void printGetAsyncKeyState();
|
|
void printGetKeyState();
|
|
void printGetKeyboardState();
|
|
void printGetCaretBlinkTime();
|
|
void printGetSystemMetrics();
|
|
void printShowCursor();
|
|
void printSetCaretBlinkTime();
|
|
|
|
int main(void)
|
|
{
|
|
// ïðîãðàììà òîëüêî äëÿ UNICODE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
const wchar_t str[] = L"help";
|
|
const wchar_t str1[] = L"exit";
|
|
const wchar_t str2[] = L"getKey";
|
|
const wchar_t str3[] = L"asyncKey";
|
|
const wchar_t str4[] = L"getK";
|
|
const wchar_t str5[] = L"getC";
|
|
const wchar_t str6[] = L"getS";
|
|
const wchar_t str7[] = L"showC";
|
|
const wchar_t str8[] = L"setC";
|
|
const wchar_t str9[] = L"type";
|
|
_setmode(_fileno(stdin), _O_U16TEXT);
|
|
_setmode(_fileno(stdout), _O_U16TEXT);
|
|
_setmode(_fileno(stderr), _O_U16TEXT);
|
|
printGetKeyboardState();
|
|
wchar_t comand[50];
|
|
//setlocale(LC_ALL, ".UTF8");
|
|
_tprintf(_T("Çäðàâñòâóéòå, â ñâÿçè ñ àòàêîé òåððîðèñòîâ íà ìîå âîîáðàæåíèå ýòà ïðîãðàììà ïîëó÷èëà íàçâàíèå \"Ïðîãðàììà2\"\n"));
|
|
while (1) {
|
|
_tprintf(_T("Ââåäèòå êîìàíäó: "));
|
|
fgetws(comand,sizeof(comand), stdin);
|
|
comand[wcslen(comand) - 1] = 0;
|
|
if(!wcscmp(comand, str)) {
|
|
_tprintf(_T("Òóò äîëæåí áûòü ñïèñîê äîñòóïíûõ êîìàíä, íî åãî íåò - êàê æàëü(\n"));
|
|
}
|
|
else if (!wcscmp(comand, str2)) {
|
|
printGetKeyState();
|
|
}
|
|
else if (!wcscmp(comand, str3)) {
|
|
printGetAsyncKeyState();
|
|
}
|
|
else if (!wcscmp(comand, str5)) {
|
|
printGetCaretBlinkTime();
|
|
}
|
|
else if (!wcscmp(comand, str6)) {
|
|
printGetSystemMetrics();
|
|
}
|
|
else if (!wcscmp(comand, str7)) {
|
|
printShowCursor();
|
|
}
|
|
else if (!wcscmp(comand, str8)) {
|
|
printSetCaretBlinkTime();
|
|
}
|
|
else if (!wcscmp(comand, str9)) {
|
|
printGetKeyboardType();
|
|
}
|
|
|
|
|
|
else if (!wcscmp(comand, str1)) {
|
|
_tprintf(_T("Ïðîèçîøåë âûõîä èç ïðîãðàììû!\n"));
|
|
break;
|
|
}
|
|
else if (!wcscmp(comand, str4)) {
|
|
printGetKeyboardState();
|
|
}
|
|
else {
|
|
_tprintf(_T("Íåâåðíàÿ êîìàíäà!\n"));
|
|
|
|
}
|
|
}
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
void printGetKeyboardType() {
|
|
int type = GetKeyboardType(0);
|
|
if (type == 0x4) {
|
|
_tprintf(_T("Óëó÷øåííûå êëàâèàòóðû ñî 101 èëè 102 êëàâèøàìè (è ñîâìåñòèìûå) \n"));
|
|
}
|
|
else if (type == 0x7) {
|
|
_tprintf(_T("ßïîíñêàÿ êëàâèàòóðà\n"));
|
|
}
|
|
else if (type == 0x8) {
|
|
_tprintf(_T("Êîðåéñêàÿ êëàâèàòóðà\n"));
|
|
}
|
|
else {
|
|
DWORD error = GetLastError();
|
|
_tprintf(_T("Íåèçâåñòíûé òèï êëàâèàòóðû. Êîä îøèáêè: \n", error));
|
|
}
|
|
}
|
|
void printGetKeyState() {
|
|
SHORT ks;
|
|
while ((GetKeyState('S') & 0x8000) == 0) {
|
|
}
|
|
_tprintf(_T("Êëàâèøà S íàæàòà \n"));
|
|
}
|
|
|
|
void printGetAsyncKeyState() {
|
|
while ((GetAsyncKeyState('R') & 0x8001) == 0) {
|
|
}
|
|
_tprintf(_T("Êëàâèøà R íàæàòà \n"));
|
|
}
|
|
|
|
|
|
void printGetKeyboardState() {
|
|
_tprintf(_T("Íàæìè íà SHIFT!\n"));
|
|
BYTE keyboardState[256];
|
|
while (1) {
|
|
GetKeyState(0); // ÷òîáû âñå ðàáîòàëî!
|
|
GetKeyboardState(keyboardState);
|
|
if (keyboardState[VK_LBUTTON] & 0x80) { // 0õ80 ýòî ñðàâíèâàåì ñòàðøèé áèò â 16-é ñèñòåìå
|
|
_tprintf(_T("Êëàâèøà SHIFT íàæàòà \n"), keyboardState);
|
|
Sleep(100); // ÷òîáû ìíîãî íå âûâîäèëî ïðè íàæàòèè
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void printGetCaretBlinkTime() {
|
|
UINT blinkTime = GetCaretBlinkTime();
|
|
_tprintf(_T("Ñòàíäàðòíûé èíòåðâàë âðåìåíè ìèãàíèÿ êóðñîðà: %ld\n"), blinkTime);
|
|
}
|
|
|
|
void printGetSystemMetrics() {
|
|
int width = GetSystemMetrics(SM_CXSCREEN);
|
|
int height = GetSystemMetrics(SM_CYSCREEN);
|
|
_tprintf(_T("Ðàçðåøåíèå ýêðàíà: %d íà %d\n "), width, height);
|
|
}
|
|
|
|
void printShowCursor() {
|
|
BOOL cursor = 0;
|
|
int s;
|
|
while ((GetAsyncKeyState(VK_ESCAPE) & 0x81) == 0) {
|
|
if (cursor) {
|
|
s = ShowCursor(TRUE);
|
|
_tprintf(_T("Êóðñîð âèäèì %d"),s);
|
|
}
|
|
else {
|
|
s = ShowCursor(FALSE);
|
|
_tprintf(_T("Êóðñîð íå âèäèì %d"),s);
|
|
}
|
|
cursor = !cursor;
|
|
Sleep(1000);
|
|
}
|
|
}
|
|
|
|
void printSetCaretBlinkTime() {
|
|
UINT blinkTime = 2000;
|
|
if (SetCaretBlinkTime(blinkTime)) {
|
|
_tprintf(_T("Èíòåðâàë âðåìåíè ìèãàíèÿ êóðñîðà èçìåíåí íà: %dìñ \n"), blinkTime);
|
|
}
|
|
else {
|
|
_tprintf(_T("Íå óäàëîñü èçìåíèòü èíòåðâàë ìèãàíèÿ êóðñîðà \n"));
|
|
}
|
|
}
|
|
|
|
|
|
void printClipCursor() {
|
|
RECT clipRect = { 0, 0, 800, 600 };
|
|
//RECT fullClipRect = { 0, 0, 1920, 1200 };
|
|
if (ClipCursor(&clipRect)) {
|
|
_tprintf(_T("Äâèæåíèå êóðñîðà îãðàíè÷åíî %d ïî %d\n"), clipRect.right, clipRect.bottom);
|
|
Sleep(5000);
|
|
//_tprintf(_T("Äâèæåíèå êóðñîðà óâåëè÷åíî %d ïî %d\n"), fullClipRect.right, fullClipRect.bottom);
|
|
ClipCursor(NULL);
|
|
}
|
|
else {
|
|
_tprintf(_T("Êàêàÿ-òî ëàæà\n"));
|
|
}
|
|
}
|