Hello everyone
I need to write a code that opens up internet explorer to www.way2sms.com, logs in with my userid and password, navigates to the "Quick Sms" page, enters text in the field and sends the sms.
Need urgent help.. please
Printable View
Hello everyone
I need to write a code that opens up internet explorer to www.way2sms.com, logs in with my userid and password, navigates to the "Quick Sms" page, enters text in the field and sends the sms.
Need urgent help.. please
Search (http://www.vbforums.com/search.php) for "website login" or "website fill form", there are a lot of examples. This is one of them http://www.vbforums.com/showthread.p...=website+login
this is quite a simple one
vb Code:
Set wb = CreateObject("internetexplorer.application") wb.navigate2 "http://wwwf.way2sms.com/content/index.html" wb.Visible = True Do Until wb.readystate = 4 DoEvents Loop Set f = wb.document.Forms(0) f.All("password").Value = "pass" f.All("username").Value = "789894588" f.submit
Like most advertising supported Web pages, webscraping to get access to its services may be against the provider's Terms and Conditions. The site's T&Cs document mentions a number of requirements your program may be violating.
I thought this sort of topic was prohibited in these forums, but a moderator might clarify that.
as i am not a member of that site and can not login, i am unable to see any of the pages after the login page
Quote:
and close internet explorer.
vb Code:
wb.quit set wb = nothing
msconn.
userid is 9998461800
password is puri332434
my code is
Private Sub Command1_Click()
WebBrowser1.Navigate "http://wwwe.way2sms.com/content/index.html"
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
WebBrowser1.Document.loginForm.username.Value = "9998461800"
WebBrowser1.Document.loginForm.password.Value = "puri332434"
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
WebBrowser1.Document.loginForm.submit
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
End Sub
Private Sub Command2_Click()
WebBrowser1.Document.All.wayquicksms1.Click
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
End Sub
Private Sub Command3_Click()
WebBrowser1.Document.rtform.MobNo.Value = "9998461800"
WebBrowser1.Document.rtform.TextArea.Value = "hi"
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
WebBrowser1.Document.All.send.Click
End Sub
now i can click on the "quicksms" tab
but cant enter text in the form that loads
i cant find the name of the form that loads
please help
i even tried sendkeys after the "quicksms" tab has been pressed
but the quicksms opens up a "frame" rather than a form..
can that be the problem.. if so.. how do i tackle it?
there are several examples on using frames within a webbrowser (or IE) in this forum, note iframes are a bit different to webpage frames, but both types are includes in the frames collection
THANKS WESTCONN.. IT WORKED!
NOW JUST ONE FINAL STEP TO GO..
heres the problem..
my code is
Private Sub Form_Load()
WebBrowser1.Navigate "http://wwwe.way2sms.com//content/index.html"
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
WebBrowser1.Document.All.username.Value = "9998461800"
WebBrowser1.Document.All.password.Value = "puri332434"
WebBrowser1.Document.loginForm.submit
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
End Sub
'now i need to wait so that the login is done and the next page is loaded
Private Sub Command1_Click()
WebBrowser1.Document.All.wayquicksms1.Click
End Sub
'wait for the frame to load, then type and send sms
Private Sub Command2_Click()
WebBrowser1.Document.frames("frame").Document.All("MobNo").Value = "9998461800"
WebBrowser1.Document.frames("frame").Document.All("textArea").Value = "Hello"
Do Until WebBrowser1.ReadyState = 4
DoEvents
Loop
WebBrowser1.Document.frames("frame").Document.All("Send").Click
End Sub
AS YOU CAN SEE, I NEED TO WRITE A CODE BETWEEN THE BUTTON CLICKS WHICH ALLOW ME TO WAIT UNTIL THE NEXT FORM OR FRAME IS LOADED, THEN PERFORM THE NEXT TASK..
i tried this
DO UNTIL WEBBROWSER1.READYSTATE = 4
DO EVENTS
LOOP
but still keeps giving me errors
CAN U WRITE A CODE FOR ME TO WAIT SAY 2 TO 3 SECONS?
THANK YOU
ALMOST RESOLVED
I think you can use the Sleep API if you want.
Example:
...:wave:Code:Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
MsgBox "Going to sleep for 2 seconds. Are you ready ?"
Sleep 2000
MsgBox "Ok. I am back"
End Sub
you can try like this to wait for the frame to load
vb Code:
wb.document.All.wayquicksms1.Click Set f = wb.document.frames(0) Do Until f.document.readystate = "complete" DoEvents Loop
it says "variable not defined and points to f"
So define it. I think it should be Dim f As HTMLDocument
i also tried this
Private Sub Command1_Click()
WebBrowser1.Document.All.wayquicksms1.Click
Do Until WebBrowser1.Document.frames("frame").Document.ReadyState = "complete"
DoEvents
Loop
WebBrowser1.Document.frames("frame").Document.All("MobNo").Value = "9998461800"
WebBrowser1.Document.frames("frame").Document.All("textArea").Value = "Hello"
End Sub
but it says "object vaiable or with block variable not set"
At what line of code? You'll have to be more precise.
thats where i'm getting the erroe.Code:Private Sub Command1_Click()
Dim f As HTMLDocument
'WebBrowser1.Document.All.wayquicksms1.Click
WebBrowser1.Document.All.wayquicksms1.Click
Set f = WebBrowser1.Document.frames(0)
Do Until f.Document.ReadyState = "complete"
DoEvents
Loop
WebBrowser1.Document.frames("frame").Document.All("MobNo").Value = "9998461800"
WebBrowser1.Document.frames("frame").Document.All("textArea").Value = "Hello"
End Sub
according to the code, it shud click on "quicksms" which it does..
but it should also wait till the frame loads, and write in the texts.. but it gives me the error :-(
are you sure the frame has a name (frame) ?
try
f.Document.All("MobNo").Value = "9998461800"
as f is already an object of the frame element
as far as i can tell f should be an htmwindow2, i use object
tried :-(Code:Private Sub Command1_Click()
Dim f As Object
WebBrowser1.Document.All.wayquicksms1.Click
Set f = WebBrowser1.Document.frames(0)
Do Until f.Document.ReadyState = "complete"
DoEvents
Loop
f.Document.All("MobNo").Value = "9998461800"
f.Document.All("textArea").Value = "Hello"
End Sub
but still the same error.
object variable or with block variable not set.
god!! i just need the entire process to happen in 1 event instead of 3
why is that too much to ask :-(
i also tried
dim f as htmlwindow2
no luck
this almost works for me, problem with pop-upblocker dialog has to be dismissed manually, message was sentvb Code:
wb.navigate2 "http://wwwf.way2sms.com/content/index.html" wb.Visible = True Do Until wb.readystate = 4 DoEvents Loop Set f = wb.document.Forms(0) f.All("password").Value = "puri332434" f.All("username").Value = "9998461800" f.submit Do Until wb.readystate = 4 And Not wb.busy DoEvents Loop 'Do While wb.busy 'DoEvents 'Loop wb.document.All.wayquicksms1.Click Set f = wb.document.frames(0) Do Until f.document.readystate = "complete" 'And Not wb.busy DoEvents Loop f.document.All("MobNo").Value = "9998461800" f.document.All("textArea").Value = "Hello" f.document.All("Send").Click
it says "object doesn't support this property or method"Code:wb.navigate2 "http://wwwf.way2sms.com/content/index.html"
wb.Visible = True
Do Until wb.readystate = 4
DoEvents
Loop
Set f = wb.document.Forms(0)
f.All("password").Value = "puri332434"
f.All("username").Value = "9998461800"
f.submit
Do Until wb.readystate = 4 And Not wb.busy
DoEvents
Loop
'Do While wb.busy
'DoEvents
'Loop
wb.document.All.wayquicksms1.Click
Set f = wb.document.frames(0)
Do Until f.document.readystate = "complete" 'And Not wb.busy
DoEvents
Loop
f.document.All("MobNo").Value = "9998461800"
f.document.All("textArea").Value = "Hello"
f.document.All("Send").Click
how come it works for u??
Imbakaran, please tell me that in post #8 you did not put your real UserID and Password on a public forum. If you did your account is anybodies on the internet until you change your password. Forums such as this and many others are meant to be found by search engines. That is why you should never put any personal information on one.