We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Click Button On Other App (AOL Toolbar)

adamwj asked
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?
Watch Question

Have you tried sending a BM_CLICK message to the button?


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


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?  
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...

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Have you tried using PostMessage instead of SendMessage?


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 :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.