Autor Beitrag
InCoBra
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 43



BeitragVerfasst: Di 09.09.08 16:31 
Hallo,

ich versuche eine Software zu entwickeln, die zum Beispiel Daten aus einem per Bluetooth angeschlossenen Wiimote ausliest (das habe ich schon fertig), und dann (da liegt das Problem) an die geöffnete Anwendung einen bestimmten Tastendruck zu schicken. Problem ist, dass mit SendKeys, etc. die Spiele nicht darauf reagieren.

Der C++ - Code hier (www.codeproject.com/...ys_cpp_Article.aspx) funktioniert bei den meisten Spielen, aber ich weiß nicht wie ich das in C# implementieren soll...

Gruß,
InCoBra
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4805
Erhaltene Danke: 1061

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Di 09.09.08 16:38 
InCoBra Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 43



BeitragVerfasst: Mi 10.09.08 18:18 
Das hat leider nicht funktioniert...

So müsste es doch eigentlich gehen:
ausblenden 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:
    class Program
    {
        [DllImport("user32.dll")]
        static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);

        public static void SendKey()
        {
            keybd_event((byte)0x41, (byte)0x451, (UIntPtr)0);
            keybd_event((byte)0x41, (byte)0x451 | 2, (UIntPtr)0);
        }

        [DllImport("kernel32.dll")]
        static extern void Sleep(Int32 time);

        static void Main(string[] args)
        {
            Console.ReadLine();
            Sleep(3000);
            SendKey();
            Console.WriteLine("A");
            Console.ReadLine();
        }
    }


Ich habe es mehrfach mit Project64 versucht und es funktioniert nicht...
Mit GlovePIE und dem Programm unter dem oben angegebenen Link funktioniert das ganze wunderbar...

Gruß