Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[Help] C++ SetCursorPos() function
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
jeroendeman
Master Cheater
Reputation: 0

Joined: 03 Jan 2007
Posts: 270
Location: netherlands

PostPosted: Fri Oct 24, 2008 3:22 pm    Post subject: Reply with quote

#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(;Wink
{
if(FindWindow(_T("MapleStoryClass"), 0))
{
Sleep(5000);
if(GetAsyncKeyState(VK_F4)){

int x = 375, y = 315;
MoveMouse(int x, int y);
int ClickSpeed = 100;
Click(int ClickSpeed);

cout << "Clicked" << endl;
}
}
else
{
cout << "MapleStory not found." << endl;
Sleep(10000);
}
}

return 0;
}

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);
}

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));
}
Back to top
View user's profile Send private message
Heartless
I post too much
Reputation: 0

Joined: 03 Dec 2006
Posts: 2436

PostPosted: Fri Oct 24, 2008 3:34 pm    Post subject: Reply with quote

slovach wrote:
HornyAZNBoy wrote:
...


Why are you using true as the first parameter? Why are you calling SendInput numerous times when you can do it all at once?


Sorry but I don't know how to do it with only 1 SendInput().

_________________
What dosen't kill you, usually does the second time.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Oct 24, 2008 4:12 pm    Post subject: Reply with quote

HornyAZNBoy wrote:
slovach wrote:
HornyAZNBoy wrote:
...


Why are you using true as the first parameter? Why are you calling SendInput numerous times when you can do it all at once?


Sorry but I don't know how to do it with only 1 SendInput().


That's why it takes an array of INPUT structures.
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Fri Oct 24, 2008 6:22 pm    Post subject: Reply with quote

tdenisenko wrote:
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?


I'm not sure what you mean by "it's CS so it doesn't click", but would be nice if you posted the code you had so we can check for errors.
Back to top
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Sat Oct 25, 2008 1:33 am    Post subject: Reply with quote

sloppy wrote:
tdenisenko wrote:
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?


I'm not sure what you mean by "it's CS so it doesn't click", but would be nice if you posted the code you had so we can check for errors.


SetCursorPos just doesnt work
only working thing is
_PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
_PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));

it clicks that x,y but it doesnt move the mouse to that coords so it doesnt click...

and the last code posted not working also
it has so many errors

here is my code with SetCursorPos..
it doesnt have any errors but SetCursorPos doesnt working for some reason
pls try to fix it

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("Quest AutoClicker"));

   cout << "Quest AutoClicker made by tdenisenko" << endl;

   Sleep(10000);

   for(;;)
   {
      if(FindWindow(_T("MapleStoryClass"), 0))
      {
         Sleep(5000);
       if(GetAsyncKeyState(VK_F4)){

       //bulb
       {int x = 434, y = 284; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDBLCLK, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //questtext
       {int x = 375, y = 315; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //accept
       {int x = 557, y = 442; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //OK
       {int x = 493, y = 336; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //choose quest
       {int x = 91, y = 80; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //forfeit
       {int x = 507, y = 275; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
       //OK
       {int x = 443, y = 335; // co-ordinates relative to window
       POINT pt; pt.x = x; pt.y = y;
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(100); // small delay before the click
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(250);}
      
         cout << "Quest Done!" << endl;
       }
      }
      else
      {
         cout << "MapleStory not found." << endl;
         Sleep(10000);
      }
   }

   return 0;
}

_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Sat Oct 25, 2008 1:35 am    Post subject: Reply with quote

LOOOOOOPS
Back to top
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Sat Oct 25, 2008 2:02 am    Post subject: Reply with quote

slovach wrote:
LOOOOOOPS


what?

_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
blackmorpheus
Expert Cheater
Reputation: 0

Joined: 05 Apr 2008
Posts: 159

PostPosted: Sat Oct 25, 2008 3:13 am    Post subject: Reply with quote

Ofcourse this doesnt work. You have to hold ur F4 for around 5 seconds ( or shorter if ur lucky) before it will finally start the if part.
Try to change Sleep(5000) into Sleep(30).
Back to top
View user's profile Send private message
Cheat Engine User
Something epic
Ban
Reputation: 61

Joined: 22 Jun 2007
Posts: 2071

PostPosted: Sat Oct 25, 2008 3:37 am    Post subject: Reply with quote

tdenisenko wrote:
slovach wrote:
LOOOOOOPS


what?


He wants you to use loops. Probably for SetCursorPos.
Back to top
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Sat Oct 25, 2008 4:32 am    Post subject: Reply with quote

Holland wrote:
tdenisenko wrote:
slovach wrote:
LOOOOOOPS


what?


He wants you to use loops. Probably for SetCursorPos.


how?
please explain

_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
--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?

PostPosted: Sat Oct 25, 2008 5:01 am    Post subject: Reply with quote

Code:
int coords[0] = 434; coords[1] = 284; coords[2] = 375; coords[3] = 315; coords[4] = 557; coords[5] = 442; coords[6] = 493; coords[7] = 336; coords[8] = 91; coords[9] = 80; coords[10] = 507; coords[11] = 275;
coords[12] = 443; coords[13] = 335;
while(int i = 0; i < 3; i=i+2;){
       POINT pt; pt.x = coords[i]; pt.y = coords[i+1];
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(10);
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(75);
}

_________________

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
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Sat Oct 25, 2008 9:27 am    Post subject: Reply with quote

man please post after you fix the errors...

so many errors...
Code:

error C2466: cannot allocate an array of constant size 0
error C2440: 'initializing' : cannot convert from 'int' to 'int []'
error C2143: syntax error : missing ')' before ';'
error C2065: 'i' : undeclared identifier
error C2065: 'i' : undeclared identifier
error C2065: 'i' : undeclared identifier
error C2059: syntax error : ')'
error C2065: 'i' : undeclared identifier
error C2065: 'i' : undeclared identifier
error C2065: 'x' : undeclared identifier
error C2065: 'y' : undeclared identifier
error C2065: 'x' : undeclared identifier
error C2065: 'y' : undeclared identifier

_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Oct 25, 2008 9:45 am    Post subject: Reply with quote

--Pillboi-- wrote:
Code:
int coords[0] = 434; coords[1] = 284; coords[2] = 375; coords[3] = 315; coords[4] = 557; coords[5] = 442; coords[6] = 493; coords[7] = 336; coords[8] = 91; coords[9] = 80; coords[10] = 507; coords[11] = 275;
coords[12] = 443; coords[13] = 335;
while(int i = 0; i < 3; i=i+2;){
       POINT pt; pt.x = coords[i]; pt.y = coords[i+1];
       ClientToScreen(MapleWnd, &pt);
       SetCursorPos(pt.x, pt.y);
       Sleep(10);
       _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y));
       _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(x, y));
       Sleep(75);
}


Holy shit, thats a nightmare...

Code:
POINT pt[7] = { {434, 284}, {375, 315}, {557, 442}, {493, 336}, {91, 80}, {507, 275}, {443, 335} };
for (int i = 0; i < 7; i++)
{
    ClientToScreen(MapleWnd, &pt[i]);
    SetCursorPos(pt[i].x, pt[i].y);
    Sleep(10);
    _PostMessageA(MapleWnd, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt[i].x, pt[i].y));
    _PostMessageA(MapleWnd, WM_LBUTTONUP, 0, MAKELPARAM(pt[i].x, pt[i].y));
    Sleep(100);
}

_________________
Back to top
View user's profile Send private message
tdenisenko
Grandmaster Cheater
Reputation: 0

Joined: 23 Oct 2007
Posts: 799
Location: Turkey

PostPosted: Sat Oct 25, 2008 10:07 am    Post subject: Reply with quote

well lurc this code works like the code last i posted...
SetCursorPos still doesnt work
it clicks the correct x and y but it doesnt move the mouse to that x y so you see only CS clicking

when i move the mouse, mouse moves from his first spot (that means mouse pos never changed) but when clicking you see it changes but only clicks when i move the mouse to correct x and y

so? maybe GG blocks it or its not working on maple?
or what?
i need this much please help

_________________
I am learning C++ and ASM and making trainers!
My Last Chaos Trainer!
LC Trainer by tdenisenko
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Oct 25, 2008 10:10 am    Post subject: Reply with quote

GG Does Block SetCursorPos...
Same exact trampoline as PostMessageA tho, just different skeleton function and different jump addy.

_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites