我是编程新手。
我打算制作一个程序,它可以将输入/文本发送到一个名为 minecraft 的游戏——它是一个用 Java 制作的游戏。
我正在尝试使用 SendMessage API,但我不知道如何使用它..
到目前为止,这是我的代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace MinecraftTest2_Sendinput
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImportAttribute("User32.dll")]
private static extern int FindWindow(String ClassName, String
WindowName);
[DllImportAttribute("User32.dll")]
private static extern int SetForegroundWindow(int hWnd);
[System.Runtime.InteropServices.PreserveSig]
[DllImport("User32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Ansi)]
public static extern int SendMessage(int hWnd, uint Msg, int wParam, long lParam);
private void button1_Click(object sender, EventArgs e)
{
int hWnd = FindWindow(null, "Minecraft");
if (hWnd > 0)
{
SetForegroundWindow(hWnd);
//I need to call the SendMessage here! but what should i type in the arguments?
}
}
}
}