Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Mouse events at XY on an automated IE object

Posted on 2002-04-25
10
Medium Priority
?
1,667 Views
Last Modified: 2010-05-02
I control numerous instances of IE using automation (MS Internet Controls). In some SSL forms the objects 'clicked' do not have their names visible so it is hard to control them in code. Is there a way to set the mouse pointer to a given location on the IE object and 'click' on this point in code ?

Cheers !

Stewart
0
Comment
Question by:nvms
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6968752
Private Declare Sub mouse_event Lib "user32" _
(ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

Private Declare Function SetCursorPos Lib "user32.dll" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Private Const MOUSEEVENTF_ABSOLUTE = &H8000 '  absolute move
Private Const MOUSEEVENTF_LEFTDOWN = &H2 '  left button down
Private Const MOUSEEVENTF_LEFTUP = &H4 '  left button up

then to simulate a left click
SetCursorPos <x-coord>, <y-coord>
mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

Note: for winNT the mouse_event function has been superceded, use SendInput instead.
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6968756
also, you don't need the Sleep declare, this was just a section of code i've used.
0
 
LVL 28

Expert Comment

by:AzraSound
ID: 6968765
This is an issue because you dont know if the IE window is maximized, if the button is even scrolled into view, etc.  Is there anything you can use to identify these buttons in the html?  Maybe you can rely on sourceindex?  Which index of the button it is if you loop through all the buttons on the form?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:nvms
ID: 6970498
hmmmm well I can set the window state to maximised during the initation process so the location of the image I wish to click should be predicatable, assuming the author the doesn't change things around. In most cases the 'button' is a gif image and the code is hidden.

Appreciate greatly the dialogue. If Bobbit31's code (no relation to the famous eunich? :)  does the trick I finalise this query.

Deep thanks as always

Stewart Wood
0
 

Author Comment

by:nvms
ID: 6974636
That worked well, is there an equally simply process to send key strokes after a particular X,Y co-ordinate has been clicked ?  50 more points for the additional query...

Excellent watching my mouse pointer wander programatically over my desktop !

Stewart
0
 

Author Comment

by:nvms
ID: 6974676
That worked well, is there an equally simply process to send key strokes after a particular X,Y co-ordinate has been clicked ?  50 more points for the additional query...

Excellent watching my mouse pointer wander programatically over my desktop !

Stewart
0
 
LVL 18

Accepted Solution

by:
bobbit31 earned 600 total points
ID: 6977474
sure:

to send key strokes (using api):

Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_CAPITAL = &H14

'' simply an example that presses caps lock
keybd_event VK_CAPITAL, 0, 0, 0
keybd_event VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0

or you can use SendKeys:

ie:

'' press abcd
SendKeys "abcd"
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6986942
You could get a workaround at www.angelfire.com/realm/vb-shard/index.html
0
 

Author Comment

by:nvms
ID: 6991049
Thanks Mr Bobbit..... haven't tested it but i am sure it will work

Regards

Stewart
0
 
LVL 18

Expert Comment

by:bobbit31
ID: 6991568
no prob, glad to help!
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

722 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