I did the same thing as you said but still my code is not working to send keystrokes to the game.
here is my code.
namespace onsceeenkeyboard
{
public partial class Form1 : Form
{
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern bool SetForegroundWindow(IntPtr hwnd);
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= 0x08000000;
return param;
}
}
public Form1()
{
InitializeComponent();
Process[] Processes = Process.GetProcessesByName("DOSBox");
IntPtr hWnd = IntPtr.Zero;
Debug.Write("Processes: " + Processes.Length);
foreach (Process p in Processes)
{
// do something
hWnd = p.Handle;
SetForegroundWindow(hWnd);
// p.Kill();
}
}
private void button1_Click(object sender, EventArgs e)
{
SendKeys.Send("{UP}");
}
}
}
No comments:
Post a Comment