How do I check a Check Box using this example http://www.mjtnet.com/forum/viewtopic.php?t=1461
I want to check the "Keep me logged in" check box at http://www.facebook.com/login.php
I know the name (persistent) and value (1) but I can't get the script to check the check box.
Thanks for any help.
VBscript Check Box Form Fill Question
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Send a space to it:
Press Tab
Send>space
Press Tab
Send>space
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
You can use the tag's click method. Something like:
Code: Select all
Sub ClickIt(fieldname)
Dim FormNr
Dim ItemNr
Dim TheForm
if IE.Document.All.Tags("FORM").Length = 0 then
MsgBox("No form found in page")
else
for FormNr = 0 to IE.Document.Forms.Length - 1
Set TheForm = IE.Document.Forms(FormNr)
for ItemNr = 0 to TheForm.Elements.Length - 1
if TheForm.Elements(ItemNr).Name = fieldname then
TheForm.Elements(ItemNr).Click
exit for
end if
next
next
end if
End Sub
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
I haven't actually tested the code I posted, but you're calling it wrong anyway. It's a Sub, so you should use:
VBRun>ClickIt,Persistent
VBRun>ClickIt,Persistent
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
Thank you for all your help, Marcus.
Here is the working script if anyone is interested.
Here is the working script if anyone is interested.
Code: Select all
VBSTART
Dim IE
Sub CreateIE
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible=1
End Sub
Sub Navigate(URL)
IE.Navigate URL
do while IE.Busy
loop
End Sub
Sub KillIE
IE.Quit
Set IE = nothing
End Sub
Sub WebFormFill(fieldname,fieldvalue,submit)
Dim FormNr
Dim ItemNr
Dim TheForm
if IE.Document.All.Tags("FORM").Length = 0 then
MsgBox("No form found in page")
else
for FormNr = 0 to IE.Document.Forms.Length - 1
Set TheForm = IE.Document.Forms(FormNr)
for ItemNr = 0 to TheForm.Elements.Length - 1
if TheForm.Elements(ItemNr).Name = fieldname then
TheForm.Elements(ItemNr).Value = fieldvalue
If submit=1 then
TheForm.submit
end if
exit for
end if
next
next
end if
End Sub
'This function extracts text from a specific tag by name and index
'e.g. TABLE,0 (1st Table element) or P,1 (2nd Paragraph element)
'set all to 1 to extract all HTML, 0 for only inside text without HTML
Function ExtractTag(TagName,Num,all)
dim t
set t = IE.document.getElementsbyTagname(Tagname)
if all=1 then
ExtractTag = t.Item(Num).outerHTML
else
ExtractTag = t.Item(Num).innerText
end if
End Function
Sub ClickIt(fieldname)
Dim FormNr
Dim ItemNr
Dim TheForm
if IE.Document.All.Tags("FORM").Length = 0 then
MsgBox("No form found in page")
else
for FormNr = 0 to IE.Document.Forms.Length - 1
Set TheForm = IE.Document.Forms(FormNr)
for ItemNr = 0 to TheForm.Elements.Length - 1
if TheForm.Elements(ItemNr).Name = fieldname then
TheForm.Elements(ItemNr).Click
exit for
end if
next
next
end if
End Sub
VBEND
VBRun>CreateIE
VBRun>WaitBusy
VBRun>Navigate,http://www.facebook.com/login.php
VBRun>WaitBusy
wait>1
VBRun>WebFormFill,email,Email Address,0
VBRun>WebFormFill,pass,Password,0
VBRun>ClickIt,persistent
VBRun>WebFormFill,login,Login,1
VBRun>WaitBusy