|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
Pingo Grandmaster Cheater Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Fri Apr 19, 2013 4:06 am Post subject: Emulate mouse click? |
|
|
So it shows up in Spy++.
I'v tried mouse_event, PostMessage, SendMessage
My last try was CallWindowProc
Im using Solitaire as my test platform but the game i wish to do it for is a directx game which seems to be eating the messages when in fullscreen only. In windowed mode it works.
In solitaire i get this when i click
Im doing this in C# btw. The code works fine in solitaire but doesnt show in Spy++.
It clicks every 5 seconds after i stop moving my mouse.
Heres the code, i use a special injector i made to inject managed dlls.
Code: | #region API
[DllImport("user32", EntryPoint = "GetWindowLong")]
static extern IntPtr GetWindowLong(IntPtr hWnd, GWL nIndex);
[DllImport("user32", EntryPoint = "GetWindowLongPtr")]
static extern IntPtr GetWindowLongPtr(IntPtr hWnd, GWL nIndex);
[DllImport("user32")]
static extern IntPtr CallWindowProc(IntPtr lpPrevWndFunc, IntPtr hWnd, WM Msg, int wParam, int lParam);
#endregion
#region enum
public enum GWL
{
GWL_WNDPROC = -4,
GWL_HINSTANCE = -6,
GWL_HWNDPARENT = -8,
GWL_STYLE = -16,
GWL_EXSTYLE = -20,
GWL_USERDATA = -21,
GWL_ID = -12
}
public enum WM
{
WM_MOUSEFIRST = 0x200,
WM_MOUSEMOVE = 0x200,
WM_LBUTTONDOWN = 0x201,
WM_LBUTTONUP = 0x202,
WM_LBUTTONDBLCLK = 0x203,
WM_RBUTTONDOWN = 0x204,
WM_RBUTTONUP = 0x205,
WM_RBUTTONDBLCLK = 0x206,
WM_MBUTTONDOWN = 0x207,
WM_MBUTTONUP = 0x208,
WM_MBUTTONDBLCLK = 0x209,
WM_MOUSEWHEEL = 0x20A,
WM_MOUSEHWHEEL = 0x20E
}
#endregion
public static int DllMain(string arg)
{
new Thread(Derp).Start();
return 0;
}
static void Derp()
{
Point Current = Cursor.Position;
IntPtr hWnd = Process.GetCurrentProcess().MainWindowHandle;
IntPtr GWL_ = IntPtr.Size == 4 ? GetWindowLong(hWnd, GWL.GWL_WNDPROC) : GetWindowLongPtr(hWnd, GWL.GWL_WNDPROC);
if (GWL_ == IntPtr.Zero)
{
throw new Exception("Could not GetWindowLong");
}
while (true)
{
Thread.Sleep(5000);
if (Cursor.Position == Current)
{
CallWindowProc(GWL_, hWnd, WM.WM_LBUTTONDOWN, 0, 0);
CallWindowProc(GWL_, hWnd, WM.WM_LBUTTONUP, 0, 0);
}
else Current = Cursor.Position;
}
} |
Any idea why these messages wont show up in Spy++.
I know these arnt real mouse clicks, but there must be a way to trick it into thinking it is a real click.
_________________
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
Posted: Sat Apr 20, 2013 6:14 pm Post subject: |
|
|
Hook DirectInput and inject the mouse data into GetDeviceState / GetDeviceData.
_________________
- Retired. |
|
Back to top |
|
|
Pingo Grandmaster Cheater Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Sun Apr 21, 2013 11:42 am Post subject: |
|
|
I will try that. I did however manage to simulate exactly what spy++ was giving me but it still failed. worked fine on another game though.
I'm thinking the game has it's own hook to determine if the key was real or not. I'm not the only person having this issue.
Apparently all methods of simulating keys has been patched.
But i'm gonna try everything i can think of.
I might try finding it if i fail at everything else.
_________________
|
|
Back to top |
|
|
atom0s Moderator Reputation: 198
Joined: 25 Jan 2006 Posts: 8517 Location: 127.0.0.1
|
|
Back to top |
|
|
Pingo Grandmaster Cheater Reputation: 8
Joined: 12 Jul 2007 Posts: 571
|
Posted: Mon Apr 22, 2013 1:44 am Post subject: |
|
|
This believe this is exactly what im after. Gonna go read this now.
I had SetWindowsHook on my list to try.
I'm gonna try this first.
Thanks Wiccaan
_________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|