controlling mouse cursor or triggering mouseover event

jjones32

New Member
Joined
Aug 25, 2011
Messages
5
Is there any way to use vb macro code to trigger a mouseover event for an image or table cell when navigating a particular website or moving the mouse cursor over the image which will trigger the mouseover event itself.

So basically I need to be able to do either of the following:

1) use code to trigger the mouseover event either by referencing the image or the table cell that the image is in (these are on a ie webpage)

2) identify the coordinates of the image or table cell and use code to move the actual cursor to that location which will trigger the mouseover event automatically.

This one has me stumped so any help would be greatly appreciated.
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
IE itself. My program basically opens IE, navigates to a website that requires username and password. My code submits the login information causing the home page of the website to come up. Here is where I have these dynamic pull down menu choices that I need to select. The pulldown menu choices are shown when the mouse pointer is on the image (which is also a cell in a table). So my thought is using vba to maybe move the mouse pointer to that location somehow triggering the pulldown choices or just triggering the mouseover event directly somehow. My problem is that I'm not able to call for a mouseclick on the table cell element until the mouseover event happens revealing the other choices. Any thoughts? See my generic code below:


Code:
Dim IEApp As Object 'Variable for Internet Explorer Object
Dim IEhandle As Long 'Internet Explorer handle
Dim XLhandle As Long 'Excel handle
Dim UserN As Variant
Dim PassW As Variant

Dim btnInput As Object 
Dim ElementCol As Object 
Dim Link As Object
Dim lnk 

'Identify HANDLE for current Excel
XLhandle = Application.hwnd

'Open up Internet Explorer session
Set IEApp = CreateObject("InternetExplorer.Application")
IEApp.Navigate ("[URL]http://ntreis.marketlinx.com/TempoCommon/Authentication/Login.aspx?ReturnUrl=%2f[/URL]")
IEApp.StatusBar = True
IEApp.Toolbar = True
IEApp.Visible = True
IEApp.Resizable = True
IEApp.AddressBar = True

'Wait until IE has finished loading itself.
Do While IEApp.busy: DoEvents: Loop
Do Until IEApp.ReadyState = 4: DoEvents: Loop
Application.Wait Now + TimeValue("00:00:01")

'Identify HANDLE for current Internet Explorer Window#1
IEhandle = IEApp.hwnd


'Enter username and password in textboxes
Set UserN = IEApp.Document.getElementsByName("LoginCtrl$txtLoginUsername")
If Not UserN Is Nothing Then
UserN(0).Value = "********"
End If

Set PassW = IEApp.Document.getElementsByName("LoginCtrl$txtPassword")
If Not PassW Is Nothing Then
PassW(0).Value = "********"
End If
' click 'Submit' button
Set ElementCol = IEApp.Document.getElementsByTagName("INPUT")
For Each btnInput In ElementCol
If btnInput.Value = "Login" Then
btnInput.Click
Exit For
End If
Next btnInput
'Wait for webpage to load
Do While IEApp.busy: DoEvents: Loop
Do Until IEApp.ReadyState = 4: DoEvents: Loop
Application.Wait Now + TimeValue("00:00:01")


' Below is how I can select the main option choice. It works by clicking on the link or
' table cell that is assigned to a link. A mouseover in this same table cell (or image)
' area causes more link choices (table cells) to pop up. Those are the choices that I
' need to select but somehow need to get access to those links or trigger the mouseover
' event, etc..

Set Link = IEApp.Document.getElementById("ctl05_02")
Link.Click
 
Upvote 0
I need vba to move the mouse to a set location (image for example). Im able to move it with setCursorPos x, y but program can be flaky if window is shifted or view option is at different percentage, etc.. Didn't know if there was a way have vba to identify coordinates of image and have cursor move to that location which will trigger the desired mouseover event.
 
Upvote 0
jjones32,

Check out the following:

Automation of an system issue.
http://www.vbaexpress.com/forum/showthread.php?t=35623
check out autoit
http://autoitscript.com/autoit3
it's a free, high level basic based programming language that makes working with all areas of the windows API pretty simple.
including sending directly to any standard control.
there's a great support forum over there also and feel free to pm me here or there (Cameronsdad is my name over there) if you go that route and have any questions
Easy to learn BASIC-like syntax
Simulate keystrokes and mouse movements
Manipulate windows and processes
Interact with all standard windows controls
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top