iam trying to set controlls in Java Edition Minecraft via my C# App:
using System;
using WindowsInput.Native;
using WindowsInput;
using System.Threading;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace MinecraftController
{
class Program
{
const UInt32 WM_KEYDOWN = 0x0100;
const int VK_F5 = 68;
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
[STAThread]
static void Main(string[] args)
{
while (true)
{
Process[] processes = Process.GetProcesses();
Process mc;
foreach (Process proc in processes)
{
if (proc.ProcessName.ToLower().Contains("java"))
{
if (proc.MainWindowTitle.ToLower().Contains("minecraft"))
{
Console.WriteLine(proc.ProcessName);
Console.WriteLine(proc.MainWindowTitle);
mc = proc;
PostMessage(mc.MainWindowHandle, WM_KEYDOWN, 17, 0);
}
}
}
Thread.Sleep(5000);
}
}
}
}
I tried to every numbers, and 0x format, and i changed int to string, byte, decimal. Everything gives me result SOH\SOH]SOH
. I tried to use WindowsInput library with VK, but a result is the same every time. Have you idea what to do, to have correct key biddings via c# app? I want to create bot to minecraft, i dont want to cheat, just make some fun for my kid.