Witam, mam problem z kodem poniżej, pragnę zrobić tak aby program wychwytywał mi to co kliknę w klawiaturę nawet jeśli jego okno będzie zminimalizowane (taki keylogger). Doszedłem do rezultatu poniżej jednak program nie działa ponieważ wykrywa mi błąd jeżeli chodzi o linie "using System.Windows.Forms;". Może mi ktoś naświetlić co jest tutaj źle oraz dlaczego.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace WpfApplication8
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern Int16 GetAsyncKeyState(int vKey);
private void Button_Click(object sender, RoutedEventArgs e)
{
while (true)
for (int key = 0; key < 255;key++)
if (GetAsyncKeyState(key) == -32767)
{
label.Content = "kliknales cos na klawiaturze";
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using System.ComponentModel;
namespace WpfApplication8
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
[DllImport("User32.dll", CharSet = CharSet.Auto)]
public static extern Int16 GetAsyncKeyState(int vKey);
private void Button_Click(object sender, RoutedEventArgs e)
{
while (true)
for (int key = 0; key < 255;key++)
if (GetAsyncKeyState(key) == -32767)
{
label.Content = "kliknales cos na klawiaturze";
}
}
}
}