1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62:
| 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.Diagnostics; using System.Runtime.InteropServices;
namespace test { public partial class Form1 : Form { public Form1() { InitializeComponent(); } [DllImport("User32.dll", SetLastError = true)] public static extern int SetForegroundWindow(IntPtr hwnd);
int ID; public void ProzessErstellen(string Programmname) { Process P = new Process(); P.StartInfo.FileName = Programmname; P.Start(); ID = P.Id; Application.DoEvents(); }
public void TextSenden(string Text) {
System.IntPtr MainHandle = Process.GetProcessById(ID).MainWindowHandle; SendKeys.SendWait("{TAB}"); SetForegroundWindow(MainHandle); Application.DoEvents(); } private void button1_Click(object sender, EventArgs e) { ProzessErstellen("alefclient.exe"); Application.DoEvents(); }
public void button2_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); for (int i = 0; i <= 20;i++) { TextSenden(Text); System.Threading.Thread.Sleep(1000); Application.DoEvents();
}
}
} } |
So jetzt zu meinen Problem.
Ich will ihr nen Rollenspiel AFK Bot erstellen.
Aber egal welche Taste ich bei SendKeys rein schreib, im Spiel wird immer der ESC befehl ausgeführt.
Mit Button 1 öffne ich mein spiel und Prozess.
Und mit Button2 starte ich meine Tasteneingabe was so weit ja funzt, bis auf das, dass immer der ESC Befehl ausgeführt wird.(ALso wie wenn ich im spiel ESC drücke dann geh das Menüfenster auf, das passiert bei allen Tasten was ich bei sendkeys rein schreib.)
Kann mir da jemand helfen?
MfG
Moderiert von
Kha: C#-Tags hinzugefügt