Creating a Bot in c# that runs in the background

04/08/2016 08:40 GaXyLa#1
So
I learned C# a while , and now i want to create a simple bot for Black Desert
that presses a button and simulates the mouse buttons.

Code:
SendKeys.Send("{t}");
Code:
 public static void RightClick(int x, int y)
        {
            Cursor.Position = new Point(x, y);
            mouse_event((int)(MouseEventFlags.RIGHTDOWN), 0, 0, 0, 0);
            mouse_event((int)(MouseEventFlags.RIGHTUP), 0, 0, 0, 0);
}
But my first Problem is, nothing happens in the game client.
i think my program requires admin rights for this, but currently im not sure.

When this is done, how can i program it, that it runs in the background for Black Desert?
So that i can other do things on my pc.
I asked myself a long time, how that is possible.

I hope you guys can help me :)
and sry for my bad englisch, its not my native language^^
04/08/2016 14:42 Yothri#2
Quote:
Originally Posted by GaXyLa View Post
So
I learned C# a while , and now i want to create a simple bot for Black Desert
that presses a button and simulates the mouse buttons.

Code:
SendKeys.Send("{t}");
Code:
 public static void RightClick(int x, int y)
        {
            Cursor.Position = new Point(x, y);
            mouse_event((int)(MouseEventFlags.RIGHTDOWN), 0, 0, 0, 0);
            mouse_event((int)(MouseEventFlags.RIGHTUP), 0, 0, 0, 0);
}
But my first Problem is, nothing happens in the game client.
i think my program requires admin rights for this, but currently im not sure.

When this is done, how can i program it, that it runs in the background for Black Desert?
So that i can other do things on my pc.
I asked myself a long time, how that is possible.

I hope you guys can help me :)
and sry for my bad englisch, its not my native language^^
Start Spy++ and have a look at the wParams when pressing a key in the window.

Use SendMessage() or SendInput() from WINAPI to send keys to the game.
If that doesnt work, xigncode or even the game itselfs blocks it. So you would need to block xigncode to debug the game and maybe call the function itself. Nowadays it can be difficult to simulate this.
04/09/2016 22:29 Ploxasarus#3
Quote:
Use SendMessage() or SendInput() from WINAPI to send keys to the game.
If that doesnt work, xigncode or even the game itselfs blocks it. So you would need to block xigncode to debug the game and maybe call the function itself. Nowadays it can be difficult to simulate this.
Block or unload the xigncode driver and it will work fine.

Code:
            const int WM_KEYDOWN = 0x100;
            const int WM_KEYUP = 0x101;

            PostMessage(hWnd, WM_KEYDOWN, 0x0, 0x0);
            Thread.Sleep(150);
            PostMessage(hWnd, WM_KEYUP, 0x0, 0x0);
That work's fine, but would need to be added/edited with your keycode & you would need to add intptr hwnd = getprocess.