170 lines
3.4 KiB
C++
170 lines
3.4 KiB
C++
#include <stdio.h>
|
||
#include <windows.h>
|
||
#include <stdio.h>
|
||
#include <locale.h>
|
||
#include <conio.h>
|
||
//4 вариант
|
||
//GetKeyboardType V
|
||
//GetKeyboardStateV
|
||
//GetAsyncKeyStateV
|
||
//GetCursorPosV
|
||
//SetKeyboardStateV
|
||
//GetSystemParametersInfoV
|
||
//SetKeyboardStateV
|
||
//SetCaretBlinkTimeV
|
||
//ClipCursor
|
||
//SetSystemParametersInfoV
|
||
|
||
int getKeyboardType(){
|
||
setlocale(LC_ALL, "Rus");
|
||
printf("Keyboard type: ");
|
||
switch(GetKeyboardType(0)){
|
||
case 1:
|
||
printf(" 83-key keyboard for IBM PC/XT-compatible computers\n");
|
||
break;
|
||
case 2:
|
||
printf("102-key Olivetti keyboard\n");
|
||
break;
|
||
case 3:
|
||
printf("IBM PC/AT-compatible keyboard (84 keys)\n");
|
||
break;
|
||
case 4:
|
||
printf("Extended IBM keyboard (101- or 102 keys)\n");
|
||
break;
|
||
case 5:
|
||
printf(" Nokia 1050 Keyboard\n");
|
||
break;
|
||
case 6:
|
||
printf("Nokia 9140 Keyboard\n");
|
||
break;
|
||
case 7:
|
||
printf("Japanese keyboard\n");
|
||
break;
|
||
default:
|
||
printf("Error or unknown keyboard type\n");
|
||
break;
|
||
}
|
||
return 0;
|
||
}
|
||
int getKeyboardState(BYTE massive[256]){
|
||
|
||
|
||
|
||
if (GetKeyboardState(massive) == 0)
|
||
{
|
||
printf("KS - Error\n");
|
||
}
|
||
else
|
||
{
|
||
printf("KS - notError\n");
|
||
}
|
||
|
||
if (massive[VK_CONTROL] & 0x80)
|
||
{
|
||
printf("CONTROL has been pressed\n");
|
||
}
|
||
else
|
||
{
|
||
printf("CONTROL not been pressed\n");
|
||
}
|
||
return 0;
|
||
}
|
||
int getAsyncKeyState(){
|
||
int i = 0;
|
||
printf("Please, press CONTROL\n");
|
||
while (i != 1){
|
||
if (GetAsyncKeyState(VK_CONTROL) != 0){
|
||
i = 1;
|
||
printf("Control pressed\n");
|
||
}
|
||
|
||
}
|
||
return 0;
|
||
}
|
||
int getCursorPos(){
|
||
POINT pt;
|
||
|
||
if (GetCursorPos(&pt) == 0){
|
||
printf("CP - Error\n");
|
||
}
|
||
else{
|
||
printf("CP - notError\n");
|
||
}
|
||
return 0;
|
||
}
|
||
int setKeyboardState(){//переделать
|
||
BYTE state[256];
|
||
state[VK_CONTROL] = 0x80;
|
||
SetKeyboardState(state);
|
||
getKeyboardState(state);
|
||
return 0;
|
||
}
|
||
|
||
int systemParametersInfo(){//передалтьV
|
||
PVOID parametr;
|
||
UINT uint;
|
||
if (SystemParametersInfo(SPI_GETBEEP, uint, parametr, uint) ==0)
|
||
{
|
||
printf("SPI - Error\n");
|
||
}
|
||
else
|
||
{
|
||
printf("SPI - notError\n");
|
||
}
|
||
return 0;
|
||
}
|
||
int setSystemParametrsInfo(){
|
||
PVOID parametr;
|
||
UINT uint;
|
||
if (SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 1, parametr, uint) == 0){
|
||
printf("SPI - SetError\n");
|
||
}
|
||
else{
|
||
printf("SPI - SetNotError\n");
|
||
}
|
||
getAsyncKeyState();
|
||
SystemParametersInfo(SPI_SETMOUSEBUTTONSWAP, 0, parametr, uint);
|
||
return 0;
|
||
|
||
}
|
||
int setCarietBlinkTime(){
|
||
if (SetCaretBlinkTime(1000) == 0){
|
||
printf("CBT - Error\n");
|
||
}
|
||
else{
|
||
printf("CBT - notError\n");
|
||
}
|
||
return 0;
|
||
}
|
||
int clipCursour(){//переделатьV
|
||
RECT rcOldClip;
|
||
RECT rcNewClip;
|
||
GetClipCursor(&rcOldClip);
|
||
|
||
rcNewClip.bottom = 100;
|
||
rcNewClip.left = 100;
|
||
rcNewClip.top = 100;
|
||
rcNewClip.right = 200;
|
||
|
||
ClipCursor(&rcNewClip);
|
||
getAsyncKeyState();
|
||
ClipCursor(&rcOldClip);
|
||
|
||
return 0;
|
||
|
||
}
|
||
int main() {
|
||
|
||
BYTE massive[256];
|
||
setlocale(LC_ALL, "Rus");
|
||
getKeyboardType();
|
||
getKeyboardState(massive);
|
||
getCursorPos();
|
||
setKeyboardState();
|
||
systemParametersInfo();
|
||
setCarietBlinkTime();
|
||
setSystemParametrsInfo();
|
||
//clipCursour();
|
||
return 0;
|
||
}
|