C# Simulated Mouseclicks

10/28/2011 22:44 djb#1
Hey guys, I'm working on a pixel based bot and right now I have a class set up for input that looks like this
Code:
class PushKey
    {
        [DllImport("user32.dll", SetLastError = true)]
        static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
        [DllImport("user32.dll")]
        private static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, IntPtr dwExtraInfo);


 public static void leftClick()
        {
           const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002;
        const UInt32 MOUSEEVENTF_LEFTUP = 0x0004;
            mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, new IntPtr());
            mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, new IntPtr());
            MessageBox.Show("mouseclicked");
        }
}
This code works if i want to use it anywhere else, but when i attempt to use it on the game, the hook is blocked im assuming, and although the click is executed (message box pops up) the click doesnt actually work. Does anyone know a way I can get around this to make it look like the input is really coming from my mouse? ive searched for days on this and havent found a better way.

any insight would be greatly appreciated
10/28/2011 23:14 theoneofgod#2
I'm guessing the games protection is blocking the input. Not sure how else you could do it, if this is for iSRO and you are running a x64 system, it should work fine.