Solved

Need help with automatically clicking  a button -->

Posted on 2000-05-17
1
123 Views
Last Modified: 2010-05-02
I have developed a VB application already that automatically selects another window and sends a key-stroke using the ShowWindow API function and the SendKeys function - this works fine.

However I now need to select the other application and then click on a specific button within this window - the other application will be Internet Explorer running a Java application - I would welcome any comments on how to best perform this with VB5.

Thanks.
0
Comment
Question by:DrDread
1 Comment
 
LVL 7

Accepted Solution

by:
Vbmaster earned 100 total points
ID: 2817175
Try the mouse_event API, with the help of this API a mouse-click. Use it with the MOUSEEVENTF_LEFTDOWN message and then send a MOUSEEVENTF_LEFTUP message right after.

   Declare Sub mouse_event Lib "user32" Alias "mouse_event" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

   Public Const MOUSEEVENTF_LEFTDOWN = &H2
   Public Const MOUSEEVENTF_LEFTUP = &H4


You can position the mouse with the help of the SetCursorPos API, but you can try the dx and dy parameters of the mouse_event API first.

   Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Long, ByVal y As Long) As Long
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now