Open Internet Explorer, input username/password, sendkeys, click with CreateObject

238 views
Skip to first unread message

Gábor Molnár

unread,
Oct 23, 2015, 9:22:57 AM10/23/15
to Harbour Users
Hi all,

I'm tried to fill the input fields on the webpage, it's working, but the click on the button isn't. After login i want to download 1 or more files.
Could you help me, please.

I would like this one similar.

Set IE = CreateObject("InternetExplorer.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
IE.Navigate "http://www.cilverphox.com/vbscripts/scratch2.html"
IE.Visible = True

wscript.sleep 1000
IE.Document.All.Item("myInput1").Value = "peanut butter"
IE.Document.All.Item("myInput2").Value = "and"
IE.Document.All.Item("myInput3").Value = "jelly"
 
set objButtons = IE.document.getElementsByTagName("button")
for each objButton in objButtons
strText = objButton.innerhtml
msgbox strText
if (strText = "Bill") then
msgbox "found the button!"
objButton.click
exit for
end if
next


or the other one


Sub workdammit()
    Dim SHELL_OBJECT
    Dim APP_PATH
    Dim ie As Object
    
    SHELL_OBJECT = "WScript.Shell"
    APP_PATH = "www.google.com"
    
    Set objShell = CreateObject(SHELL_OBJECT)
    Set ie = CreateObject("InternetExplorer.Application")
    
    ie.Navigate "www.google.com"
    ie.Visible = True
    
    Application.Wait (Now + TimeValue("0:00:01"))
    objShell.SendKeys "{TAB}"
    objShell.SendKeys "username"
    objShell.SendKeys "{TAB}"
    objShell.SendKeys "password"
    objShell.SendKeys "{Enter}"
End Sub

my solution

 IE = CreateObject("InternetExplorer.Application")
 IE:Navigate2( "http://www.cilverphox.com/vbscripts/scratch2.html" )
 IE:Visible := .T.
 WHILE IE:Busy 
     HB_IDLESLEEP( 1 ) 
ENDDO
IE:Document:All:Item("myInput1"):Value = "peanut butter"
IE:Document:All:Item("myInput2"):Value = "and"
IE:Document:All:Item("myInput3"):Value = "jelly"
Reply all
Reply to author
Forward
0 new messages