 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Thu Oct 23, 2008 4:37 pm Post subject: [Help] C++ SetCursorPos() function |
|
|
i am trying to make an advanced auto clicker that clicks multiple spots in Maple Story.
i know the X and Y coords but i dont know how to use this function
can some1 send me an example?
or say me what should i add this source
| Code: |
#include <windows.h>
#include <tchar.h>
#include <iostream>
using namespace std;
HWND MapleWnd = FindWindow(_T("MapleStoryClass"), 0);
DWORD _PMA = (DWORD)GetProcAddress(LoadLibrary(_T("user32.dll")), "PostMessageA") + 5;
__declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
__asm
{
mov edi, edi
push ebp
mov ebp, esp
jmp dword ptr ds:[_PMA]
}
}
int main()
{
SetConsoleTitle(_T("Auto Clicker for MapleStory")); //Window Title
cout << "Auto Clicker made by tdenisenko" << endl;
cout << "For MapleStory." << endl;
for(;;)
{
if(FindWindow(_T("MapleStoryClass"), 0)) //Find MapleStory
{
Sleep(10000);
/* I NEED THAT SETCURSOR FUNCTION HERE! */
_PostMessageA(MapleWnd, WM_LBUTTONDOWN, 0x01, (MapVirtualKey(0x01, 0) << 16)); //Left mouse button click
Sleep(250);
cout << "Clicked" << endl; //Message
}
else
{
cout << "MapleStory not found." << endl; //If MapleStory isn't opened yet
Sleep(10000);
}
}
return 0;
} |
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Oct 23, 2008 4:58 pm Post subject: |
|
|
First off, WM_LBUTTONDOWN does NOT have the same message parameters as WM_KEYDOWN.
the lParam is the X and Y position, use MAKELPARAM for that.
If you wanna use SetCursorPos, make another trampoline like PostMessageA for it, cause its hooked by GameGuard.
MSDN: http://msdn.microsoft.com/en-us/library/ms645607.aspx
_________________
|
|
| Back to top |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Thu Oct 23, 2008 5:12 pm Post subject: |
|
|
| lurc wrote: | First off, WM_LBUTTONDOWN does NOT have the same message parameters as WM_KEYDOWN.
the lParam is the X and Y position, use MAKELPARAM for that.
If you wanna use SetCursorPos, make another trampoline like PostMessageA for it, cause its hooked by GameGuard.
MSDN: http://msdn.microsoft.com/en-us/library/ms645607.aspx |
i already saw that link
its not helpful
and i am new at C++ i dont understand much
so explain better or give me an example about SetCursorPos usage in Maple
and i dont dont same or diff parameters it just works for me
please post an example
thanks
_________________
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Thu Oct 23, 2008 6:58 pm Post subject: |
|
|
| lurc wrote: | | If you wanna use SetCursorPos, make another trampoline like PostMessageA for it, cause its hooked by GameGuard. |
Example of using SetCursorPos & ClientToScreen,
| Code: | int x = 20, y = 20; // co-ordinates relative to window
POINT pt; pt.x = x; pt.y = y;
ClientToScreen(MapleWnd, &pt);
SetCursorPos(pt.x, pt.y);
Sleep(10); // small delay before the click |
Correct usage of WM_LBUTTONDOWN as lurc was trying to point out,
| Code: | _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
_PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y)); |
The MSDN may be confusing for beginners, but try read over it a few times until you have a better understanding. Alternatively, google everything you are unsure of, as more often than not you will find a dozen examples/answers to your questions.
Last edited by sloppy on Thu Oct 23, 2008 7:03 pm; edited 1 time in total |
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Oct 23, 2008 7:00 pm Post subject: |
|
|
| Code: | | POINT pt = { 20, 30 }; |
Just thought I'd point that out... Much easier this way.
_________________
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Thu Oct 23, 2008 7:04 pm Post subject: |
|
|
Thanks lurc, I could swear there was an easier way but I couldn't remember it. ^^
-edit-
Hah! I just noticed the pun, good one lol.
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Fri Oct 24, 2008 6:09 am Post subject: |
|
|
| What does ClientToScreen() ?
|
|
| Back to top |
|
 |
--Pillboi-- Grandmaster Cheater Supreme
Reputation: 0
Joined: 06 Mar 2007 Posts: 1383 Location: I don't understand the question. Is this a 1 to 10 thing?
|
Posted: Fri Oct 24, 2008 6:14 am Post subject: |
|
|
Search before you ask. [Click]
_________________
Enter darkness, leave the light, Here be nightmare, here be fright...
Earth and Water, Fire and Air. Prepare to meet a creature rare.
Enter now if you dare, Enter now the dragon's lair. |
|
| Back to top |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Fri Oct 24, 2008 9:38 am Post subject: |
|
|
thanks for the replies and solutions guys they are really helpful but i have a different problem now...
it changes the mouse position but its CS so it doesnt click on the buttons
it clicks only when i move the mouse manually...
any helps?
_________________
|
|
| Back to top |
|
 |
blackmorpheus Expert Cheater
Reputation: 0
Joined: 05 Apr 2008 Posts: 159
|
Posted: Fri Oct 24, 2008 11:21 am Post subject: |
|
|
| Code: |
{
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
|
Try this..
|
|
| Back to top |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Fri Oct 24, 2008 11:30 am Post subject: |
|
|
| blackmorpheus wrote: | | Code: |
{
SetCursorPos(x, y);
mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);
mouse_event(MOUSEEVENTF_LEFTUP,0,0,0,0);
}
|
Try this.. |
where is the coords?
just edit the x and y?
edit: when i remove SetCursorPos it still teles to that x and y while mouse click but that SetCursorPos command doesnt work...
can some1 help???
_________________
|
|
| Back to top |
|
 |
Heartless I post too much
Reputation: 0
Joined: 03 Dec 2006 Posts: 2436
|
Posted: Fri Oct 24, 2008 1:10 pm Post subject: |
|
|
Move mouse
| Code: | Void MoveMouse(int x, int y)
{
double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) -1;
double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) -1;
double fx = x*(65535.0f / fScreenWidth);
double fy = y*(65535.0f / fScreenHeight);
INPUT Input;
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
SendInput(true, &Input, sizeof(INPUT));
} |
Click
| Code: | void Click(int ClickSpeed)
{
INPUT Input;
memset(&Input, 0, sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
}
|
_________________
What dosen't kill you, usually does the second time. |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Fri Oct 24, 2008 2:29 pm Post subject: |
|
|
| HornyAZNBoy wrote: | Move mouse
| Code: | Void MoveMouse(int x, int y)
{
double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) -1;
double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) -1;
double fx = x*(65535.0f / fScreenWidth);
double fy = y*(65535.0f / fScreenHeight);
INPUT Input;
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
SendInput(true, &Input, sizeof(INPUT));
} |
Click
| Code: | void Click(int ClickSpeed)
{
INPUT Input;
memset(&Input, 0, sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
}
|
|
Why are you using true as the first parameter? Why are you calling SendInput numerous times when you can do it all at once?
|
|
| Back to top |
|
 |
tdenisenko Grandmaster Cheater
Reputation: 0
Joined: 23 Oct 2007 Posts: 799 Location: Turkey
|
Posted: Fri Oct 24, 2008 3:05 pm Post subject: |
|
|
doesnt work...
maybe i am doing it wrong
can you say me where is the problem?
| Code: |
#include <windows.h>
#include <tchar.h>
#include <iostream>
using namespace std;
HWND MapleWnd = FindWindow(_T("MapleStoryClass"), 0);
DWORD _PMA = (DWORD)GetProcAddress(LoadLibrary(_T("user32.dll")), "PostMessageA") + 5;
__declspec(naked) BOOL WINAPI _PostMessageA(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
__asm
{
mov edi, edi
push ebp
mov ebp, esp
jmp dword ptr ds:[_PMA]
}
}
int main()
{
SetConsoleTitle(_T("AutoClicker"));
cout << "Quest AutoClicker made by tdenisenko" << endl;
Sleep(10000);
for(;;)
{
if(FindWindow(_T("MapleStoryClass"), 0))
{
Sleep(5000);
if(GetAsyncKeyState(VK_F4)){
int x = 375, y = 315;
void MoveMouse(int x, int y);
{
double fScreenWidth = GetSystemMetrics(SM_CXSCREEN) -1;
double fScreenHeight = GetSystemMetrics(SM_CYSCREEN) -1;
double fx = x*(65535.0f / fScreenWidth);
double fy = y*(65535.0f / fScreenHeight);
INPUT Input;
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE;
Input.mi.dx = fx;
Input.mi.dy = fy;
SendInput(true, &Input, sizeof(INPUT));
}
int ClickSpeed = 100;
void Click(int ClickSpeed);
{
INPUT Input;
memset(&Input, 0, sizeof(INPUT));
Input.type = INPUT_MOUSE;
Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
SendInput(1, &Input, sizeof(INPUT));
Sleep(ClickSpeed);
}
cout << "Clicked" << endl;
}
}
else
{
cout << "MapleStory not found." << endl;
Sleep(10000);
}
}
return 0;
} |
_________________
|
|
| 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
|
|