# Forum > MMO > Guild Wars 2 >  c# Send key to Gw2 to move characters

## Ancitique

Hi !

I'am new on this forum and i'am here to learn and share my knowlegde to other members.

I want to send key to GW2.exe to do a simple farm bot or anti afk kick. So i want to send Z en S to GW2 in c# i had read that gw2 use directinput but i don't find how to do this with SendInput. Can anybody help me please ?

Thanks a lot

----------


## Ploxasarus

PostMessage works fine.



```
        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll", SetLastError = true)]
        private static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);


        private void Move_Tick(object sender, EventArgs e)
        {
            const int WM_KEYDOWN = 0x100;
            const int WM_KEYUP = 0x101;

            IntPtr hWnd = FindWindow(null, "Guild Wars 2");

            PostMessage(hWnd, WM_KEYDOWN, 0x26, 0x11480001);
            Thread.Sleep(100);
            PostMessage(hWnd, WM_KEYUP, 0x26, 0x11480001);
        }
```

This is just an example as this only does W, but it does work ( even downsized ).

----------


## andrewfam

> PostMessage works fine.
> 
> 
> 
> ```
>         [DllImport("user32.dll", SetLastError = true)]
>         static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
>         [DllImport("user32.dll", SetLastError = true)]
>         private static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);
> ...


I'm digging up an old thread here because this method is still working today.
Can someone please explain to me what the hex value 0x11480001 stand for? If I change this value to something else the function is no longer work.
On the other hand, if I change 0x26 (up arrow key) to something else the function still work as expected.
Thanks,

----------

