I wonna send a MoseClick to a Button via API
The Button is in a Window which is ChildWindow of an Application
Sendmessage(hwnd,WM_LBUTTONDOWN, &H1,lParam)
does not work
funktioniert nicht.
He expected in lParam the MousePosition within the Button, if i get hWND the
Handle of the Button
Whatelse I try to process in lParam f.E. .&H00050005 or a POINTAPI structure
Spy++ tells in lParam stand 007FF29C
This is an undifined moeseposition at X:-3428 and Y:127
The API call fails with return 0
Who has an advise ?
Thanks Tom
Hope this helps
Alex
Thomas Kluge <t...@TomsIT.de> wrote in message
news:#wxNpahXBHA.432@tkmsftngp07...
'Constants
Const MK_LBUTTON = &H1
Const WM_LBUTTONDOWN = &H201
Const WM_LBUTTONUP = &H202
Const WM_KEYDOWN = &H100
Const WM_KEYUP = &H101
Const VK_RETURN = &HD
'Code
'Sends a click to Command1
Call SendMessage(Command1.hwnd, WM_LBUTTONDOWN, ByVal MK_LBUTTON, 0&)
Call SendMessage(Command1.hwnd, WM_LBUTTONUP, ByVal MK_LBUTTON, 0&)
or
'Sends the Enter Key to Command1
Call SendMessage(Command1.hwnd, WM_KEYDOWN, ByVal VK_RETURN, 0&)
Call SendMessage(Command1.hwnd, WM_KEYUP, ByVal VK_RETURN, 0&)
"Thomas Kluge" <t...@TomsIT.de> wrote in message
news:#wxNpahXBHA.432@tkmsftngp07...
Spy shows the following messages (if iclick the mouse left)
no messages to ParentWindow
messages to ChildWindow:
Send: WM_MOUSEACTIVATE hwndToplevelWindow, nHittest HTCLIENT uMouseMsg:
WM_LBUTTONDOWN, hwndTopWindow,02010001
Return:MA_ACTIVATE
Send:WM_SETCURSOR hwndButton, nHittest HTCLIENT wMouseMsg:
WM_LBUTTONDOWN,hwndButton,02010001
Return:false
messages to Button:
Send: WM_MOUSEACTIVATE hwndToplevelWindow, nHittest HTCLIENT uMouseMsg:
WM_LBUTTONDOWN, hwndTopWindow,02010001
Send:WM_SETCURSOR hwndButton, nHittest HTCLIENT wMouseMsg:
WM_LBUTTONDOWN,hwndButton,02010001
Return:false
Processed: WM_LBUTTONDOWN,fwKesys:MK_LBUTTON,wParam=1, lParam=MousePos
Processed: WM_LBUTTONUP,fwKesys:0000,wParam=0, lParam=MousePos
What had i to do in VB6, to get the same result ?
with regards Tom
db <d...@b.com> schrieb in im Newsbeitrag:
NDeC7.3201$8P4.4...@news1.rdc1.mb.home.com...
> > Call SendMessage(theHWND, WM_LBUTTONDOWN, ByVal MK_LBUTTON, 0&)
> > Call SendMessage(theHWND, WM_LBUTTONUP, ByVal MK_LBUTTON, 0&)
If it really requires coordinates, then do this to send the message at
coordinates 30, 10 for example.
Dim xcoord as long
Dim ycoord as long
Dim packed as long
xcoord = 30
ycoord = 10
packed = (ycoord * &H10000) + xcoord
Call SendMessage(theHWND, WM_LBUTTONDOWN, ByVal MK_LBUTTON, packed)
Call SendMessage(theHWND, WM_LBUTTONUP, ByVal MK_LBUTTON, packed)
David
David
"Thomas Kluge" <t...@TomsIT.de> wrote in message
news:e8377WjXBHA.1428@tkmsftngp03...
David
This is the same if i run it from the vb-development or the compiled
version.
The window I have to close is an exteernal program, so i have to simulate
the click event.
Arrrhg, I try it now a have year. It seems tricky
Tom
Thomas Kluge <t...@TomsIT.de> schrieb in im Newsbeitrag:
e8377WjXBHA.1428@tkmsftngp03...
This is the same if i run it from the vb-development or the compiled
version.
The window I have to close is an exteernal program, so i have to simulate
the click event.
Arrrhg, I try it now a have year. It seems tricky
Tom
db <d...@b.com> schrieb in im Newsbeitrag:
CPgC7.3811$8P4.4...@news1.rdc1.mb.home.com...
(Where hWnd is the button's window)
Works great for me on both VB buttons as well
as Windows buttons.
"Thomas Kluge" <t...@TomsIT.de> wrote in message
news:#wxNpahXBHA.432@tkmsftngp07...
that runs through MouseDown and MouseUp too.
But not activating the Event MouseClick. The Window will not be closed.
Any other idea ?
Tom
Samuel B. Quiring <sbq_n...@SpeechStudio.com> schrieb in im Newsbeitrag:
eDyZ2zmXBHA.1428@tkmsftngp03...
David
Tom
db <d...@b.com> schrieb in im Newsbeitrag:
AFzC7.5125$8P4.8...@news1.rdc1.mb.home.com...
Try using PostMessage:
Call PostMessage(Command2.hwnd, WM_LBUTTONDOWN, ByVal MK_LBUTTON, 0&)
Call PostMessage(Command2.hwnd, WM_LBUTTONUP, ByVal MK_LBUTTON, 0&)
My information is that PostMessage works asyncron and SendMessage syncron.
I sent you the test vb
Tom
db <d...@b.com> schrieb in im Newsbeitrag:
iVCC7.5310$8P4.8...@news1.rdc1.mb.home.com...
db <d...@b.com> schrieb in im Newsbeitrag:
iVCC7.5310$8P4.8...@news1.rdc1.mb.home.com...
David
"Thomas Kluge" <t...@TomsIT.de> wrote in message
news:u4#FqX5XBHA.1644@tkmsftngp03...
I got your test. I see what you mean...the target window is getting the
messages but not running it's button_click event. I'm not sure why it's
like that because wrote and app that does exactly the same thing a year ago,
and it works perfectly. The only thing different is that the app that I'm
sending the messages to was written in PowerBuilder, not VB. So, I guess
the results you get depend to some degree on the app that you are trying to
control.
Anyway, I did find a solution that works for closing the VB app. I found
that sending the button down/up message twice will do it. Just verify after
the first down/up message that the window is still there, and if it is, send
the button down/up messages again.
I don't know for sure if this will work in the app you are trying to
control, but if it doesn't, then I'd really need to see the other app to be
able to figure it out.
David
--
Hope this helps ...
Rene Whitworth
R.Whi...@w-s-s.de
Whitworth Software Solutions - Germany
http://www.w-s-s.de
Please reply to the newsgroups ...
"Thomas Kluge" <t...@TomsIT.de> schrieb im Newsbeitrag
news:uj2rEduXBHA.1976@tkmsftngp07...
Rene Whitworth <R.Whi...@w-s-s.de> schrieb in im Newsbeitrag:
OxZ0rrGYBHA.2416@tkmsftngp05...
first thank you for your vb app.
with vb it works fine. Also from 1 compiled app to another.
But if I try to use it to close the foreign window, it does'nt.
spy shows only the WM_LBUTTONDOWN message (twice).
the mous up message does not appear.
The OK -Button shows then an hourglass mousepointer (till waitung the
up-message)
I tried also to set first the WM_MOUSEACTIVATE and SETCURSOR first.
Its a little step foreward (i can now pass through the correct mousepos in
lParam)
Tom
db <d...@b.com> schrieb in im Newsbeitrag:
mq_C7.7798$8P4.1...@news1.rdc1.mb.home.com...