From 834bc9763b8cec5de4ea7affbc53cd3ea21ed91c Mon Sep 17 00:00:00 2001 From: stud144525 Date: Wed, 10 Jan 2024 21:57:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 2-лабораторная.sln | 31 ++++++ 2-лабораторная.vcxproj | 135 +++++++++++++++++++++++ 2-лабораторная.vcxproj.filters | 22 ++++ main.c | 191 +++++++++++++++++++++++++++++++++ 4 files changed, 379 insertions(+) create mode 100644 2-лабораторная.sln create mode 100644 2-лабораторная.vcxproj create mode 100644 2-лабораторная.vcxproj.filters create mode 100644 main.c diff --git a/2-лабораторная.sln b/2-лабораторная.sln new file mode 100644 index 0000000..e97a04b --- /dev/null +++ b/2-лабораторная.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.7.34221.43 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "2-лабораторная", "2-лабораторная.vcxproj", "{A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Debug|x64.ActiveCfg = Debug|x64 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Debug|x64.Build.0 = Debug|x64 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Debug|x86.ActiveCfg = Debug|Win32 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Debug|x86.Build.0 = Debug|Win32 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Release|x64.ActiveCfg = Release|x64 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Release|x64.Build.0 = Release|x64 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Release|x86.ActiveCfg = Release|Win32 + {A2BC3EC1-EEDF-49D6-8CF8-6E2729DC8314}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {783A30ED-544A-488B-A9C1-54377254C64B} + EndGlobalSection +EndGlobal diff --git a/2-лабораторная.vcxproj b/2-лабораторная.vcxproj new file mode 100644 index 0000000..63b394f --- /dev/null +++ b/2-лабораторная.vcxproj @@ -0,0 +1,135 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + 17.0 + Win32Proj + {a2bc3ec1-eedf-49d6-8cf8-6e2729dc8314} + My2лабораторная + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/2-лабораторная.vcxproj.filters b/2-лабораторная.vcxproj.filters new file mode 100644 index 0000000..669bc4e --- /dev/null +++ b/2-лабораторная.vcxproj.filters @@ -0,0 +1,22 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..db6f031 --- /dev/null +++ b/main.c @@ -0,0 +1,191 @@ + +#define _CRT_SECURE_NO_WARNINGS +//#define _UNICODE +//#define UNICODE + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + + + +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) { // 080 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")); + } +}