Solved

Mouse events at XY on an automated IE object

Posted on 2002-04-25
10
1,598 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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

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 150 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

Independent Software Vendors: 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!

Question has a verified solution.

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

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…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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