Autor Beitrag
pflaumenlaub
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Sa 25.04.09 14:22 
ausblenden volle Höhe C#-Quelltext
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 user profile iconKha: C#-Tags hinzugefügt
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: Sa 25.04.09 17:03 
Hier wird dir doch schon geholfen, oder? (Sei froh, dass ich dort nicht auf den Doppel-Post hinweise; bei mycsharp werden doppelte Fragen ruck-zuck geschlossen.) Jürgen
pflaumenlaub Threadstarter
Hält's aus hier
Beiträge: 5



BeitragVerfasst: Sa 25.04.09 21:15 
Ist doch nen anderes Forum.
Darf ich nur in einem Forum meine Frage stellen?
Hätte halt gern mehre Meinungen.

MfG
JüTho
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2021
Erhaltene Danke: 6

Win XP Prof
C# 2.0 (#D für NET 2.0, dazu Firebird); früher Delphi 5 und Delphi 2005 Pro
BeitragVerfasst: So 26.04.09 13:22 
Die Begründung findest du unter myCSharp.de Punkt 2. Du solltest wenigstens Querverweise setzen, damit andere Helfer wissen, was es schon als Lösungshinweise gibt, und sich nicht überflüssigerweise doppelte Arbeit machen - denn jede Hilfe ist freiwillig und umsonst, aber sie kostet die Zeit der Helfer. Jürgen