rshaham
asked on
How To Click A Button On A Web Page From VB
I wont to use this site: http://www.cellcom.co.il/support/info/phonebbok/pages/default.aspx (Image with translation attach)
i know how fill the fields "city name" and last name but the code I'm using to find out the search button "Press_Buttun(486 - .WebBrowser1.Location.X, 678 - .WebBrowser1.Location.Y)"
works only if supply 486 and 678 that means the form when web-browser In must be in Only one size and the same with web-Browser control
I found this code but it don't don't work at all:
Dim theElementCollection As System.Windows.Forms.HtmlE lementColl ection = frmMain.WebBrowser1.Docume nt.GetElem entsByTagN ame("input ")
For Each curElement As Windows.Forms.HtmlElement In theElementCollection
If curElement.GetAttribute("n ame").Equa ls("ctl00$ SPWebPartM anager1$g_ 188bf43d_b 2b0_41b1_8 939_2a473c 339706$ctl 02$m_lnk_S earch") Then
curElement.InvokeMember("o nclick")
Exit For
End If
Next
Sample-Project.zip
i know how fill the fields "city name" and last name but the code I'm using to find out the search button "Press_Buttun(486 - .WebBrowser1.Location.X, 678 - .WebBrowser1.Location.Y)"
works only if supply 486 and 678 that means the form when web-browser In must be in Only one size and the same with web-Browser control
I found this code but it don't don't work at all:
Dim theElementCollection As System.Windows.Forms.HtmlE
For Each curElement As Windows.Forms.HtmlElement In theElementCollection
If curElement.GetAttribute("n
curElement.InvokeMember("o
Exit For
End If
Next
this is the problem:
i must run this sub with fix coordinate(486,678)
Press_Buttun(486 - .WebBrowser1.Location.X, 678 - .WebBrowser1.Location.Y)
this is the function itself:
Private Sub Press_Buttun(ByVal x1 As Integer, ByVal y1 As Integer)
Dim handle As IntPtr = search_for_handle(frmMain.Handle, "Internet Explorer_Server")
Dim lParam As IntPtr = ((y1 << 16)) + x1 ' The coordinates
Dim wParam As IntPtr = IntPtr.Zero ' Additional parameters for the click (e.g. Ctrl)
Dim downCode As UInteger = 513 'Left click down code
Dim upCode As UInteger = 514 'Left click up code
SendMessage(handle, downCode, wParam, lParam) ' Mouse button down
SendMessage(handle, upCode, wParam, lParam)
DoEvents()
End Sub
Question.GIFSample-Project.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You're welcome! Thanks for the points!
ASKER