This repository has been archived on 2022-08-05. You can view files and clone it, but cannot push or open issues or pull requests.
LaptopSimulator2015/Base/Input.cs
CreepyCrafter24 633f91cac6 new file: .gitignore
new file:   1/1.cs
new file:   1/1.csproj
new file:   1/Properties/AssemblyInfo.cs
new file:   Base/Base.csproj
new file:   Base/Input.cs
new file:   Base/Level.cs
new file:   Base/Properties/AssemblyInfo.cs
new file:   LaptopSimulator2015.sln
new file:   LaptopSimulator2015/App.config
new file:   LaptopSimulator2015/CaptchaGenerator.cs
new file:   LaptopSimulator2015/FakeDesktop.Designer.cs
new file:   LaptopSimulator2015/FakeDesktop.cs
new file:   LaptopSimulator2015/FakeDesktop.resx
new file:   LaptopSimulator2015/LaptopSimulator2015.csproj
new file:   LaptopSimulator2015/Program.cs
new file:   LaptopSimulator2015/Properties/AssemblyInfo.cs
new file:   LaptopSimulator2015/Properties/Resources.Designer.cs
new file:   LaptopSimulator2015/Properties/Resources.resx
new file:   LaptopSimulator2015/Properties/Settings.Designer.cs
new file:   LaptopSimulator2015/Properties/Settings.settings
new file:   LaptopSimulator2015/Resources/fans.wav
new file:   LaptopSimulator2015/Resources/pcoptimizerpro.jpeg
new file:   LaptopSimulator2015/Settings.cs
new file:   LaptopSimulator2015/strings.Designer.cs
new file:   LaptopSimulator2015/strings.de.Designer.cs
new file:   LaptopSimulator2015/strings.de.resx
new file:   LaptopSimulator2015/strings.resx
new file:   README.md
new file:   SIT/App.config
new file:   SIT/MainForm.Designer.cs
new file:   SIT/MainForm.cs
new file:   SIT/MainForm.resx
new file:   SIT/Program.cs
new file:   SIT/Properties/AssemblyInfo.cs
new file:   SIT/Properties/Resources.Designer.cs
new file:   SIT/Properties/Resources.resx
new file:   SIT/Properties/Settings.Designer.cs
new file:   SIT/Properties/Settings.settings
new file:   SIT/SIT.csproj
new file:   ToDo.txt
new file:   make.bat
2019-07-23 14:54:05 +02:00

36 lines
948 B
C#

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 Base
{
public class Input
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private 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 (Exception e1)
{
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e1.ToString());
return false;
}
}
}
}