[c++] Hilfe bei Sendmessage

09/28/2013 15:02 Blackhawk6464#1
Hallo Leute,
ich bin neu hier und hoffe mein Post ist hier richtig.

Ich möchte mir einen einfachen Bot basteln für LoL und ich bin gerade dabei das starten zu automatisieren.

Jetzt zu meinen Problem:

Ich benutze Sendmessage um ein Mauscklick zu simulieren.Ich Versuche den Play Button vom Patcher zu betätigen. Sendmessage gibt auch keine Fehlermeldung wieder aber es passiert nichts.

Hier mein Code:
Code:
lMouseClick(HWND handle, WORD x, WORD y)
{
    if(!SendMessage(handle, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y))
       {
           return false;
       }
    Sleep(100);
    
    if(!SendMessage(handle, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y)))
        {
            return false;
        }
    
    return true;
}
Dazu noch ne kleine Frage. Muss man die x/y Koords vom Button relativ zum Fenster oder den Bildschirm nehmen?
09/28/2013 16:34 qkuh#2
Relativ zum Fenster
10/01/2013 21:36 cookie69#3
Quote:
Originally Posted by Blackhawk6464 View Post
Hallo Leute,
ich bin neu hier und hoffe mein Post ist hier richtig.

Ich möchte mir einen einfachen Bot basteln für LoL und ich bin gerade dabei das starten zu automatisieren.

Jetzt zu meinen Problem:

Ich benutze Sendmessage um ein Mauscklick zu simulieren.Ich Versuche den Play Button vom Patcher zu betätigen. Sendmessage gibt auch keine Fehlermeldung wieder aber es passiert nichts.

Hier mein Code:
Code:
lMouseClick(HWND handle, WORD x, WORD y)
{
    if(!SendMessage(handle, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(x, y))
       {
           return false;
       }
    Sleep(100);
    
    if(!SendMessage(handle, WM_LBUTTONUP, MK_LBUTTON, MAKELPARAM(x, y)))
        {
            return false;
        }
    
    return true;
}
Dazu noch ne kleine Frage. Muss man die x/y Koords vom Button relativ zum Fenster oder den Bildschirm nehmen?
It is better to use PostMessage and mouse coords are not needed (but you can keep them).

replace your code by this one and test:

BOOL MouseClick(HWND handle, WORD x, WORD y)
{
PostMessage(handle, WM_LBUTTONDOWN, MK_LBUTTON, NULL);
Sleep(100);
PostMessage(handle, WM_LBUTTONUP, MK_LBUTTON, NULL);

return TRUE;
}


If it is not working, make sure that handle is a good window handle (HWND handle = FindWindow(NULL,<Gamewindowtitle>); )
And if it is not working too, you should make a trampoline function to bypass game guard! => PM me for that!
10/05/2013 18:42 qkuh#4
cookie's post can be ignored. Does not make any sense related to your issue. I could help you in 2 days. If you are interested PM me.
10/05/2013 20:18 cookie69#5
Quote:
Originally Posted by qkuh View Post
cookie's post can be ignored. Does not make any sense related to your issue. I could help you in 2 days. If you are interested PM me.
My bad! I didn't understood his problem (I don't speak German)