Any Help is much appreciated. I am trying to open a website in IE and click using MouseEvent property. I am able to navigate & click on a button using my code, but the clicking event is not relative to IE browser. I feel its relative to current cursor position. Can you please let me know how to move cursor within IE browser (relative to IE) and click on a button?
Also, The question has been asked in the following thread
http://stackoverflow.com/quest…rer-automation-mouseevent
Code
PrivateDeclareSub mouse_event Lib"user32"(ByVal dwFlags AsLong, _
ByVal dx AsLong, _
ByVal dy AsLong, _
ByVal cbuttons AsLong, _
ByVal dwExtraInfo AsLong)
PrivateConst MOUSEEVENTF_MOVE =&H1' mouse move
PrivateConst MOUSEEVENTF_LEFTDOWN =&H2' left button down
PrivateConst MOUSEEVENTF_LEFTUP =&H4' left button up
PrivateConst MOUSEEVENTF_RIGHTDOWN =&H8' right button down
PrivateConst MOUSEEVENTF_RIGHTUP =&H10' right button up
PrivateConst MOUSEEVENTF_ABSOLUTE =&H8000' absolute move
Sub LeftClick(X AsLong, Y AsLong)
'Move mouse
mouse_event MOUSEEVENTF_MOVE, X, Y,0,0
'Press left click
mouse_event MOUSEEVENTF_LEFTDOWN,0,0,0,0
'Release left click
mouse_event MOUSEEVENTF_LEFTUP,0,0,0,0
EndSub
PrivateSub UploadFile()
Dim IE As InternetExplorerMedium
Set IE =New InternetExplorerMedium
With IE
.Visible =True
' Send the form data To URL As POST binary request
.navigate "URL"
' Wait while IE loading...
While.Busy Or.ReadyState <>4
Application.Wait (Now()+ TimeValue("00:00:01"))
DoEvents
Wend
EndWith
Dim X AsLong
Dim Y AsLong
X =20
Y =120
LeftClick X, Y
Set IE =Nothing
Set objElement =Nothing
EndSub
Display More