Here is the situation: I am logging on to an intranet website that has
5 or 6 checkboxes. I want to be able to go to the same site, but
automatically check these 5 boxes. I don't need to do an automatic
submit or anything. Just need to log on to this intranet website and
already have the 5 boxes checked. I do not have access to the source
code of this intranet site. So, I need to write a script or something
on my computer that will log on to the site but then automatically
check the 5 boxes. Any help on this matter would be appreciated.
Thank-you.

Re: Automate IE Checkbox by Gabriel

Gabriel
Thu Oct 06 12:26:42 CDT 2005

Take a look at this code:

Set oWSShell = CreateObject("WScript.Shell")
Set oIE = createobject("internetexplorer.application")

oIE.navigate "http://www.fazenda.sp.gov.br/simp/"

Do until oIE.readystate=4
wScript.Sleep 1000
Loop

oIE.Document.All.item("txtCpf").focus
oIE.Document.All.item("txtCPF").value="12345678"
oWSShell.SendKeys "{TAB}"'
oWSShell.SendKeys "{LEFT}{LEFT}"'
oWSShell.SendKeys "{TAB}"'

wscript.quit



If the controls have a ID, you can press (in the IE) EDIT, View Source code,
to see the ID´s of the controls, then you can access directly like in this
example..

Gretz..

Gabriel.


"lawhurts" <amarhasan@gmail.com> wrote in message
news:1128607168.560744.33460@g44g2000cwa.googlegroups.com...
> Here is the situation: I am logging on to an intranet website that has
> 5 or 6 checkboxes. I want to be able to go to the same site, but
> automatically check these 5 boxes. I don't need to do an automatic
> submit or anything. Just need to log on to this intranet website and
> already have the 5 boxes checked. I do not have access to the source
> code of this intranet site. So, I need to write a script or something
> on my computer that will log on to the site but then automatically
> check the 5 boxes. Any help on this matter would be appreciated.
> Thank-you.
>



Re: Automate IE Checkbox by lawhurts

lawhurts
Thu Oct 06 21:36:32 CDT 2005

I tried putting that code in notepad then renaming to a .vbs file but
it doesn't work - it just opens a shell and then it closes. How do I
implement this code?


Gabriel S. wrote:
> Take a look at this code:
>
> Set oWSShell =3D CreateObject("WScript.Shell")
> Set oIE =3D createobject("internetexplorer.application")
>
> oIE.navigate "http://www.fazenda.sp.gov.br/simp/"
>
> Do until oIE.readystate=3D4
> wScript.Sleep 1000
> Loop
>
> oIE.Document.All.item("txtCpf").focus
> oIE.Document.All.item("txtCPF").value=3D"12345678"
> oWSShell.SendKeys "{TAB}"'
> oWSShell.SendKeys "{LEFT}{LEFT}"'
> oWSShell.SendKeys "{TAB}"'
>
> wscript.quit
>
>
>
> If the controls have a ID, you can press (in the IE) EDIT, View Source co=
de,
> to see the ID=B4s of the controls, then you can access directly like in t=
his
> example..
>
> Gretz..
>
> Gabriel.
>
>
> "lawhurts" <amarhasan@gmail.com> wrote in message
> news:1128607168.560744.33460@g44g2000cwa.googlegroups.com...
> > Here is the situation: I am logging on to an intranet website that has
> > 5 or 6 checkboxes. I want to be able to go to the same site, but
> > automatically check these 5 boxes. I don't need to do an automatic
> > submit or anything. Just need to log on to this intranet website and
> > already have the 5 boxes checked. I do not have access to the source
> > code of this intranet site. So, I need to write a script or something
> > on my computer that will log on to the site but then automatically
> > check the 5 boxes. Any help on this matter would be appreciated.
> > Thank-you.
> >


Re: Automate IE Checkbox by McKirahan

McKirahan
Thu Oct 06 23:10:35 CDT 2005

"lawhurts" <amarhasan@gmail.com> wrote in message
news:1128652592.724032.163490@g14g2000cwa.googlegroups.com...
I tried putting that code in notepad then renaming to a .vbs file but
it doesn't work - it just opens a shell and then it closes. How do I
implement this code?

[snip]


You couldn't see anything because this was missing:
oIE.Visible = True


Will this help? Watch for word-wrap.

Option Explicit
Const cVBS = "SendKeys.vbs"
Dim strIEA
strIEA = "<html><head><title>" & cVBS & "</title></head>"
strIEA = strIEA & "<body><form>"
strIEA = strIEA & "1<input type='checkbox' name='box1' id='box1'>"
strIEA = strIEA & "2<input type='checkbox' name='box2' id='box2'>"
strIEA = strIEA & "3<input type='checkbox' name='box3' id='box3'>"
strIEA = strIEA & "4<input type='checkbox' name='box4' id='box4'>"
strIEA = strIEA & "5<input type='checkbox' name='box5' id='box5'>"
strIEA = strIEA & "6<input type='checkbox' name='box6' id='box6'>"
strIEA = strIEA & "</form></body></html>"
Dim objWSS
Set objWSS = CreateObject("WScript.Shell")
Dim objIEA
Set objIEA = CreateObject("InternetExplorer.Application")
objIEA.Navigate "about:blank"
objIEA.Visible = True
While objIEA.Busy
Wend
objIEA.Document.Body.InnerHTML = strIEA
objIEA.Document.all.item("box1").focus
objWSS.SendKeys " "
objWSS.SendKeys "{TAB}"'
objWSS.SendKeys " "
objWSS.SendKeys "{TAB}"'
objWSS.SendKeys " "
objWSS.SendKeys "{TAB}"'
objWSS.SendKeys " "
objWSS.SendKeys "{TAB}"'
objWSS.SendKeys " "
objWSS.SendKeys "{TAB}"'
Set objWSS = Nothing
Set objIEA = Nothing

It will check 5 of the 6 checkboxes.

Change
objIEA.Navigate "about:blank"
to
objIEA.Navigate "http://your_domain/your_page/htm"
to test it woth your page.


This link may be of interest:

Method: WshShell.SendKeys
http://www.devguru.com/Technologies/wsh/quickref/wshshell_SendKeys.html



Re: Automate IE Checkbox by TDM

TDM
Fri Oct 07 09:55:21 CDT 2005


"McKirahan" <News@McKirahan.com> wrote in message
news:_-mdncQaUPOmaNjeRVn-jw@comcast.com...
> "lawhurts" <amarhasan@gmail.com> wrote in message
> news:1128652592.724032.163490@g14g2000cwa.googlegroups.com...
> I tried putting that code in notepad then renaming to a .vbs file but
> it doesn't work - it just opens a shell and then it closes. How do I
> implement this code?
>
> [snip]

<snip>

Another posible(?) variation to MicKirahan's code ..

While objIEA.Busy
Wend
objIEA.Document.Body.InnerHTML = strIEA
objIEA.Document.all.item("box1").Checked = True
objIEA.Document.all.item("box2").Checked = True
objIEA.Document.all.item("box3").Checked = True
objIEA.Document.all.item("box4").Checked = True
objIEA.Document.all.item("box5").Checked = True
Set objWSS = Nothing
Set objIEA = Nothing


TDM

</snip>



Re: Automate IE Checkbox by lawhurts

lawhurts
Mon Oct 10 12:42:46 CDT 2005

That worked great - thanks for all your help, but I still appear to
have a problem I did not predict initially. I can not do the following:
objIEA.Navigate "http://your_domain/your_page/htm" because it
is an internal link of an intranet website that does not allow direct
access this way. So, is there a way to check the boxes of a window that
is already open? If I already have the IE window open, can I somehow
automatically check the boxes in it? Thanks for all your help.


Re: Automate IE Checkbox by TDM

TDM
Mon Oct 10 14:34:29 CDT 2005


"lawhurts" <amarhasan@gmail.com> wrote in message
news:1128966166.904676.84090@g47g2000cwa.googlegroups.com...
> That worked great - thanks for all your help, but I still appear to
> have a problem I did not predict initially. I can not do the following:
> objIEA.Navigate "http://your_domain/your_page/htm" because it
> is an internal link of an intranet website that does not allow direct
> access this way. So, is there a way to check the boxes of a window that
> is already open? If I already have the IE window open, can I somehow
> automatically check the boxes in it? Thanks for all your help.
>

I am a bit confused by your reference to "direct access in this way". If
you can open up IE(via link) and get there, you should be able to also get
there
via script. Maybe you need to set proxy settings different ?, but again,
if you can get there via a browser launched from a link, I still think
you should be able to get there from script.

Can you give more details ?, error messages etc ??

Thanks.

TDM



Re: Automate IE Checkbox by lawhurts

lawhurts
Tue Oct 11 17:51:29 CDT 2005

I can't use objIEA.Navigate "http://your_domain/your_page/htm" to get
to the page I need to get to because it is a deep link that can only be
accessed once an appropriate log-in has occurred. So, I got to the 1st
page --> enter the login information, do some navigation, and I get to
the page with the checboxes. If I try to copy the address of the final
page with the checkboxes and paste it into a browser it says that I
have been automatically logged off. So, it appears there is some type
of security mechanism that prevents deep linking. So, I need a way to
navigate to the page that is already open. Is there a way to do this?


Re: Automate IE Checkbox by TDM

TDM
Wed Oct 12 12:09:03 CDT 2005


"lawhurts" <amarhasan@gmail.com> wrote in message
news:1129071089.936404.77370@z14g2000cwz.googlegroups.com...
>I can't use objIEA.Navigate "http://your_domain/your_page/htm" to get
> to the page I need to get to because it is a deep link that can only be
> accessed once an appropriate log-in has occurred. So, I got to the 1st
> page --> enter the login information, do some navigation, and I get to
> the page with the checboxes. If I try to copy the address of the final
> page with the checkboxes and paste it into a browser it says that I
> have been automatically logged off. So, it appears there is some type
> of security mechanism that prevents deep linking. So, I need a way to
> navigate to the page that is already open. Is there a way to do this?
>

There is a way, but it gets a bit tricky and requires that you have
access to the tag ID's which you should be able to obtain by looking
at the source. I generally dont support this type of thing
as web pages change, so you then need to change your code. A
while back I put this script together for another post a while ago. It may
help
you at least get an idea of what you need to do. This script visits
a page, goes through 2 select lists and in one, selects USD, in the
other, it selects everything, then submits the page. You will need
to modify this to find your input tags for your login info, then submit
the page. Then, on the next page, I assume it will be the one where
you want to select the checkboxes, you can then do so via code
if you know either the NAME or ID, or perhaps the ALL collection
will work as well. Without really being able to visit the page you mention,
I cant be of much more help than this.

To emphasize why I dont support this type of thing, notice this script
no longer works.

Dim objIe1
Dim objIe1Doc
Dim objFrm
Dim i

Const URL = "http://www.oanda.com/convert/fxdaily"

Set objIe1=WScript.CreateObject("InternetExplorer.Application")

With objIe1
.Visible = True
.Navigate URL
Do Until .ReadyState = 4
WScript.Sleep 50
Loop
End With

Set objIe1Doc = objIe1.Document

With objIe1Doc
For i = 0 To .getElementById("exch").Length - 1
If .getElementById("exch").Item(i).Value = "USD" Then
.getElementById("exch").Item(i).Selected = True
End If
Next
For i = 0 To .getElementById("Currency").Length - 1
.getElementById("Currency").Item(i).Selected = True
Next
.All.dest.click
End With

Set objIeDoc = Nothing

WScript.Sleep 5000

Set objIe1Doc = objIe1.Document

With objIe1Doc
For i = 0 To .Links.Length - 1
If InStr(1, .Links(i).href, "format=CSV", 1) Then
WScript.Echo .Links(i)
.Links(i).Click
Exit For
End If
Next
End With


TDM




Re: Automate IE Checkbox by TDM

TDM
Wed Oct 12 12:41:43 CDT 2005


"TDM" <tdm3@nospam.net> wrote in message
news:edm8m%230zFHA.1924@TK2MSFTNGP14.phx.gbl...
>
> "lawhurts" <amarhasan@gmail.com> wrote in message
> news:1129071089.936404.77370@z14g2000cwz.googlegroups.com...
>>I can't use objIEA.Navigate "http://your_domain/your_page/htm" to get
>> to the page I need to get to because it is a deep link that can only be
>> accessed once an appropriate log-in has occurred. So, I got to the 1st
>> page --> enter the login information, do some navigation, and I get to
>> the page with the checboxes. If I try to copy the address of the final
>> page with the checkboxes and paste it into a browser it says that I
>> have been automatically logged off. So, it appears there is some type
>> of security mechanism that prevents deep linking. So, I need a way to
>> navigate to the page that is already open. Is there a way to do this?
>>
>

Sorry, forgot to mention the script does go on to the next
page and does some stuff there as well. The Sleep for 5
seconds is to wait till it gets there, my connection is a bit
slow.

TDM