Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Click Button On Other App (AOL Toolbar)

Posted on 2006-03-30
Medium Priority
Last Modified: 2010-04-07
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?
Question by:adamwj
  • 3
  • 2
  • 2
LVL 28

Expert Comment

ID: 16339045
Have you tried sending a BM_CLICK message to the button?

Author Comment

ID: 16339085
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. :|

Author Comment

ID: 16339345
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?  
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

AtanAsfaloth earned 2000 total points
ID: 16340211
Between the events, move the mouse over the button using this http://www.vb-helper.com/howto_move_mouse.html and the move the mouse back, that'll probably work...
LVL 28

Expert Comment

ID: 16343897
Have you tried using PostMessage instead of SendMessage?

Author Comment

ID: 16344059
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!

Expert Comment

ID: 16348663
Glad to help :)

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month15 days, 17 hours left to enroll

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question