Added Input class
This commit is contained in:
parent
c8496f3baf
commit
01abd93de8
33
W32/KeyboardReader.cs
Normal file
33
W32/KeyboardReader.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace CC_Functions.W32
|
||||
{
|
||||
public static class KeyboardReader
|
||||
{
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||
static extern short GetKeyState(int keyCode);
|
||||
public static bool IsKeyDown(Keys key)
|
||||
{
|
||||
try
|
||||
{
|
||||
int state = 0;
|
||||
short retVal = GetKeyState((int)key);
|
||||
if ((retVal & 0x8000) == 0x8000)
|
||||
state |= 1;
|
||||
if ((retVal & 1) == 1)
|
||||
state |= 2;
|
||||
return 1 == (state & 1);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -46,6 +46,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Hooks.cs" />
|
||||
<Compile Include="KeyboardReader.cs" />
|
||||
<Compile Include="Power.cs" />
|
||||
<Compile Include="Privileges.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
Reference in New Issue
Block a user