Click Button On Other App (AOL Toolbar)

Ok, first off here's my code.  The SetFocusAPI wasn't in there originally and doesn't appear to have helped at all.

Call SendMessage(addresshWnd, WM_SETTEXT, 0&, location.Text)
Call SetFocusAPI(addresshWnd)
Call SendMessage(pns, WM_LBUTTONDOWN, 0, 0&)
Call SendMessage(pns, WM_LBUTTONUP, 0, 0&)

The problem is that visually it works.  I run it, the text is put where I want it in the AOL Toolbar (AOL 9.0)
and when I put a sleep in between the mouse events I can actually SEE it pushing the button and releasing.

Problem is nothing happens.  If I do it manually obviously it does work.  So here I am.. lost.. any ideas?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Have you tried sending a BM_CLICK message to the button?
adamwjAuthor Commented:
Yea, I tried that earlier.  I should have mentioned that.

Same result (nothing).  I'm by no means an expert but seeing it visually happen makes me wonder why it doesn't work. :|
adamwjAuthor Commented:
I just found out if I put a 3 second sleep between the buttonup/buttondown and move the mouse cursor over the icon/button during that sleep it will actually work.

Not sure where to go from here.  Does that sound like normal behavior?  
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Between the events, move the mouse over the button using this and the move the mouse back, that'll probably work...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Have you tried using PostMessage instead of SendMessage?
adamwjAuthor Commented:
Vinny I did try that with the same result.

Atan, that ClientToScreen api was exactly what I needed.  Here's what I have now (working).  Hopefully someone else finds this useful in a search.

Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Const WM_LBUTTONUP = &H202
Const MK_LBUTTON = &H1

Dim p2 as POINTAPI

ClientToScreen pns, p2
SetCursorPos p2.x, p2.y
Call PostMessage(pns, WM_LBUTTONDOWN, MK_LBUTTON, 0)
Call PostMessage(pns, WM_LBUTTONUP, 0, 0)

pns is the hwnd of the aol button I want to click.  

Thanks everyone for the input!
Glad to help :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.