| View previous topic :: View next topic |
| Author |
Message |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 08, 2008 10:41 am Post subject: PostMessage Doesn't work... |
|
|
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 |
|
 |
slippppppppp Grandmaster Cheater
Reputation: 0
Joined: 08 Aug 2006 Posts: 929
|
Posted: Fri Aug 08, 2008 10:46 am Post subject: |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Aug 08, 2008 10:46 am Post subject: |
|
|
| 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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 08, 2008 10:47 am Post subject: |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Fri Aug 08, 2008 10:53 am Post subject: |
|
|
You have a correct trampoline?
You have gotten the handle to MapleStory's window correctly?
_________________
|
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 08, 2008 10:55 am Post subject: |
|
|
| Lol Im not even testing with maple now. Im testing with a dummy program.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Aug 08, 2008 10:56 am Post subject: |
|
|
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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 08, 2008 10:57 am Post subject: |
|
|
| I did try making an export. Doesn't work.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Fri Aug 08, 2008 11:48 am Post subject: |
|
|
| 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.
_________________
- Retired. |
|
| Back to top |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Fri Aug 08, 2008 1:39 pm Post subject: |
|
|
| LOL I made a mistake. THis code works in maple but it doesn't work on my dummy... So why?
|
|
| Back to top |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Fri Aug 08, 2008 2:33 pm Post subject: |
|
|
| 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 |
|
 |
dnsi0 I post too much
Reputation: 0
Joined: 04 Jan 2007 Posts: 2674
|
Posted: Sun Aug 10, 2008 2:42 pm Post subject: |
|
|
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 |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Sun Aug 10, 2008 4:10 pm Post subject: |
|
|
| if you're using dummy program, use mouse_event -_-.
|
|
| Back to top |
|
 |
LolSalad Grandmaster Cheater
Reputation: 1
Joined: 26 Aug 2007 Posts: 988 Location: Australia
|
Posted: Sun Aug 10, 2008 4:51 pm Post subject: |
|
|
| 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 |
|
 |
sponge I'm a spammer
Reputation: 1
Joined: 07 Nov 2006 Posts: 6009
|
Posted: Mon Aug 11, 2008 12:28 am Post subject: |
|
|
| 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 |
|
 |
|