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++ Left click trigger

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
justintcs
Cheater
Reputation: 0

Joined: 11 Sep 2012
Posts: 30
Location: Malaysia

PostPosted: Fri May 31, 2013 4:43 am    Post subject: [HELP] C++ Left click trigger Reply with quote

How can I code something in c++ when I click and hold left click then it will run the hack, and when I release left click it will stop the hack....

Appreciate alot to the helpers, tq

_________________
I'm not perfect , but i'm limited
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri May 31, 2013 5:29 am    Post subject: Reply with quote

One method you can try using is creating a low level mouse hook using:
SetWindowsHookEx

Monitor for when the left mouse button is down inside the mouse proc callback, like this:
Code:
BOOL g_MouseIsDown = false;

/**
 * Low-level Mouse Callback
 */
LRESULT CALLBACK MouseCallback( int nCode, WPARAM wParam, LPARAM lParam )
{
    if (nCode == HC_ACTION)
    {
        switch (wParam)
        {
        case WM_LBUTTONDOWN:
            g_MouseIsDown = true;
            break;
        case WM_LBUTTONUP:
            g_MouseIsDown = false;
            break;       
        }
    }
   
    return CallNextHookEx( NULL, nCode, wParam, lParam );
}

/**
 * Low-level Mouse Hook
 */
SetWindowsHookEx( WH_MOUSE_LL, reinterpret_cast< HOOKPROC >( MouseCallback ), g_WindowHinstance, NULL );


Then inside a thread to run your hack you can have something like:
Code:

BOOL g_ThreadIsRunning  = true;
BOOL g_MouseIsDown      = false;

DWORD ThreadCallback( LPVOID lpParam )
{
    while (g_ThreadIsRunning)
    {
        // Skip if mouse is not down..
        if (!g_MouseIsDown)
        {
            Sleep( 10 );
            continue;
        }
   
        // Do your hack stuff here..
        memset( 0x123456, 0x90, 5 ); // Just as an example..
        Sleep( 10 );
    }

    return ERROR_SUCCESS;
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
justintcs
Cheater
Reputation: 0

Joined: 11 Sep 2012
Posts: 30
Location: Malaysia

PostPosted: Fri May 31, 2013 5:58 am    Post subject: Reply with quote

Thx alot man ... you saved my bloody brain... haha Laughing
_________________
I'm not perfect , but i'm limited
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
Page 1 of 1

 
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