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 


PostMessage Doesn't work...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Aug 08, 2008 10:41 am    Post subject: PostMessage Doesn't work... Reply with quote

Ok Put entire Code:
Form1:
Code:
Dim lhWnd As Long

Private Sub ACTIMER_Timer()
    Dim lpt As POINTAPI
    GetCursorPos lpt
    PostMessageX lhWnd, WM_LBUTTONDOWN, &H1, MAKELPARAM(lpt.x, lpt.y)
    Delay 0.1
    PostMessageX lhWnd, WM_LBUTTONUP, &H1, MAKELPARAM(lpt.x, lpt.y)
    DoEvents
End Sub

Private Sub Timer1_Timer()
Dim tempwnd As Long
tempwnd = FindWindowA("MapleStoryClass", vbNullString)
If tempwnd <> 0 Then
    lhWnd = tempwnd
End If
DoEvents
End Sub

Private Sub Timer2_Timer()
If GetAsyncKeyState(VK_F12) Then
    If ACTIMER.Enabled = True Then
        ACTIMER.Enabled = False
        Label1.Caption = "AC OFF"
    Else
        ACTIMER.Enabled = True
        Label1.Caption = "AC ON"
    End If
End If
DoEvents
End Sub


Module1:
Code:
Public Type POINTAPI
        x As Long
        y As Long
End Type
Public Declare Function PostMessageX Lib "HookHop.dll" Alias "?PostMessageX@@YA_NPAUHWND__@@IIJ@Z" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Const WM_KEYDOWN = &H100
Public Const VK_F12 = &H7B
Public Const WM_LBUTTONDOWN = &H201
Public Const WM_LBUTTONUP = &H202
Public Const WM_LBUTTONDBLCLK = &H203

Sub Delay(amount As Single)
  Dim StartTime As Single
  Dim CurrentTime As Single
  StartTime = Timer
  Do
    CurrentTime = Timer
    DoEvents
  Loop While CurrentTime < StartTime + amount
End Sub
Function LOWORD(ByVal dw As Long) As Integer
    If dw And &H8000& Then
        LOWORD = dw Or &HFFFF0000
    Else
        LOWORD = dw And &HFFFF&
    End If
End Function

Function LOBYTE(ByVal w As Integer) As Byte
    LOBYTE = w And &HFF
End Function

Function HIBYTE(ByVal w As Integer) As Byte
    HIBYTE = (w And &HFF00&) \ 256
End Function
 Public Function MAKELONG(wLow As Long, wHigh As Long) As Long
   MAKELONG = LOWORD(wLow) Or (&H10000 * LOWORD(wHigh))
 End Function

Public Function MAKELPARAM(wLow As Long, wHigh As Long) As Long
   MAKELPARAM = MAKELONG(wLow, wHigh)
 End Function


Last edited by dnsi0 on Fri Aug 08, 2008 10:55 am; edited 1 time in total
Back to top
View user's profile Send private message
slippppppppp
Grandmaster Cheater
Reputation: 0

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Aug 08, 2008 10:46 am    Post subject: Reply with quote

I don't code in VB, but youll know what i mean.

Dim lpt As POINT
GetCursorPos lpt
PostMessageX lhWnd, WM_LBUTTONDOWN, 0, LPARAM( ptr ) );
PostMessageX lhWnd, WM_LBUTTONUP, 0, LPARAM( ptr ) );
Back to top
View user's profile Send private message AIM Address MSN Messenger
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Aug 08, 2008 10:46 am    Post subject: Reply with quote

Code:
#define MAKELONG(a, b)      ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16))


Uh... Thats what MAKELONG looks like in a C++ header..
& a 0xFFFF then | it to the result of b & 0xFFFF << 16

Anyways this is how mine looked.
Code:
_PostMessageA( hMaple, WM_LBUTTONDOWN, MK_LBUTTON, MAKELPARAM(pt.x,pt.y) );

_________________


Last edited by lurc on Fri Aug 08, 2008 10:47 am; edited 1 time in total
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Aug 08, 2008 10:47 am    Post subject: Reply with quote

I understand that man. But unfortunally vb does not HAVE LPARAM. so...

I made a dll export from c++ and called MAKELPARAM from vb but still doesn't work.
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Fri Aug 08, 2008 10:53 am    Post subject: Reply with quote

You have a correct trampoline?
You have gotten the handle to MapleStory's window correctly?

_________________
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Aug 08, 2008 10:55 am    Post subject: Reply with quote

Lol Im not even testing with maple now. Im testing with a dummy program.
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 Aug 08, 2008 10:56 am    Post subject: Reply with quote

Make an LPARAM function in your DLL and export that as well. Then call that to make the LPARAM inside VB. See if that helps, your LPARAM func might be messing up.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Aug 08, 2008 10:57 am    Post subject: Reply with quote

I did try making an export. Doesn't work.
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 Aug 08, 2008 11:48 am    Post subject: Reply with quote

dnsi0 wrote:
I did try making an export. Doesn't work.


I created a quick example. Attached to this post, refresh if you don't see it.



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Fri Aug 08, 2008 1:39 pm    Post subject: Reply with quote

LOL I made a mistake. THis code works in maple but it doesn't work on my dummy... So why?
Back to top
View user's profile Send private message
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Fri Aug 08, 2008 2:33 pm    Post subject: Reply with quote

dnsi0 wrote:
LOL I made a mistake. THis code works in maple but it doesn't work on my dummy... So why?
Most likely your dummy process does not handle WM_LBUTTONUP/DOWN messages OR you got the wrong handle. For instance a common mistake when using notepad is just to get the window handle when the actual handle you need is the EDIT control.
_________________
Back to top
View user's profile Send private message
dnsi0
I post too much
Reputation: 0

Joined: 04 Jan 2007
Posts: 2674

PostPosted: Sun Aug 10, 2008 2:42 pm    Post subject: Reply with quote

I just made a blank exe (vb) with a button on it that messageboxes "hello".

So I guess it doesn't handle.
Back to top
View user's profile Send private message
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Aug 10, 2008 4:10 pm    Post subject: Reply with quote

if you're using dummy program, use mouse_event -_-.
Back to top
View user's profile Send private message
LolSalad
Grandmaster Cheater
Reputation: 1

Joined: 26 Aug 2007
Posts: 988
Location: Australia

PostPosted: Sun Aug 10, 2008 4:51 pm    Post subject: Reply with quote

Rot1 wrote:
if you're using dummy program, use mouse_event -_-.


The only reason he's using the dummy program is so that he can test PostMessageX. -_-

As sponge said, you don't have the right handle. For it to work with the dummy program you have to get the handle of the button itself.

EnumChildWindows is what I've used in the past to get the handle of the control I want to PostMessage / SendMessage to, if there's a better alternative then I would be glad to know.

_________________
Back to top
View user's profile Send private message MSN Messenger
sponge
I'm a spammer
Reputation: 1

Joined: 07 Nov 2006
Posts: 6009

PostPosted: Mon Aug 11, 2008 12:28 am    Post subject: Reply with quote

LolSalad wrote:
Rot1 wrote:
if you're using dummy program, use mouse_event -_-.


The only reason he's using the dummy program is so that he can test PostMessageX. -_-

As sponge said, you don't have the right handle. For it to work with the dummy program you have to get the handle of the button itself.

EnumChildWindows is what I've used in the past to get the handle of the control I want to PostMessage / SendMessage to, if there's a better alternative then I would be glad to know.
FindWindowEx. Only if you absolutely know the class.
_________________
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