Jump to content

CheckBox through iexplorer


Recommended Posts

I'm not here for freebies, i really want to learn what i am doing wrong. After 4 hours of exhaustive forum search i cannot find anything (or) i am not doing it correctly. 

The following is the form data from the source code in the page, i'm posting bits and pieces of what I've seen is important to know: 

<form name=att enctype="multipart/form-data" action=/ecn/attachment_proc.php method=post>

<INPUT type=checkbox value=Y name=nounzip>

full code:
 

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0><FORM encType=multipart/form-data method=post name=att action=/ecn/attachment_proc.php><INPUT type=hidden value=ba9fe1b6-0409-11e5-8005-cdf8735656af name=ecid> 
<TBODY>
<TR class=smallfont>
<TD colSpan=3 align=center><INPUT type=file name=userfile></TD></TR>
<TR class=smallfont>
<TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip> Do not unzip files.</TD></TR>
<TR align=center>
<TD class=smallfont colSpan=3><INPUT type=submit value=update>&nbsp;<A style="FONT-SIZE: 10pt" href="/ecn/attachments_add.php?ecid=ba9fe1b6-0409-11e5-8005-cdf8735656af&amp;showattuser=Y">show user</A> </TD></TR>
<TR class=smallfont>
<TD>&nbsp;<B>File</B></TD>
<TD><B>Zip</B></TD>
<TD><B>Del</B></TD></TR>
<TR onmouseover="this.bgColor='gold';" onmouseout="this.bgColor='#ffffff';" id=L0 class=smallfont bgColor=#ffffff vAlign=top>
<TD><A href="/ecn/attachment_download.php?attid=f3bae344-040d-11e5-8005-cdf8735656af" target=ec_atts>&nbsp;fixture for 250a.zip</A>&nbsp;&nbsp;&nbsp;26-May-2015</TD>
<TD><INPUT type=checkbox value=f3bae344-040d-11e5-8005-cdf8735656af name=glist[]></TD>
<TD><INPUT onclick=SetColor(0); type=checkbox value=f3bae344-040d-11e5-8005-cdf8735656af name=dlist[]></TD></TR></FORM></TBODY></TABLE>

JavaScript function, yes i even went that far:
 

<SCRIPT language=javascript>
//
// Set Row Color
//
function SetColor(IDX)
{
    L="L" + IDX;

    if ( document.att.elements['dlist[]'][IDX] ) {
    if ( document.att.elements['dlist[]'][IDX].checked ) {
        document.getElementById(L).style.background="#ff6666";
    }
    else {
        document.getElementById(L).style.background="";
    }
    }
    else if ( document.att.elements['dlist[]'].checked ) {
    document.getElementById(L).style.background="#ff6666";
    }
    else {
    document.getElementById(L).style.background="";
    }
}
</SCRIPT>

and one more:

 

<table width=100% cellpadding=0 cellspacing=0 border=0>
<form name=att enctype="multipart/form-data" action=/ecn/attachment_proc.php method=post>
<input type=hidden name=ecid value='ba9fe1b6-0409-11e5-8005-cdf8735656af'>
<tr class=smallfont><td colspan=3 align=center><input name="userfile" type="file"></td></tr>
<tr class=smallfont><td colspan=3 align=center><input type=checkbox name=nounzip value=Y> Do not unzip files.</td></tr>
<tr align=center><td colspan=3 class=smallfont><input type=submit value="update">&nbsp;<a style='font-size:10pt;' href='/ecn/attachments_add.php?ecid=ba9fe1b6-0409-11e5-8005-cdf8735656af&showattuser=Y'>show user</a>
</td></tr>

the form i am targeting is att, and the name is nounzip. The value of the check box is Y. 

here is the following of what i tried and failed at miserably:

#include <IE.au3>

$sUrl = "http://www2.eng.york.york.com/ecn/ec_summary.php"

$oIE = _IEAttach($sUrl, "url")
If not isObj($oIE) Then
    $oIE = _IECreate()
    _IENavigate($oIE, $sUrl)
EndIf

While 1
;$o_form = _IEFormGetObjByName($oBrowser, "EC Summary")
$o_form = _IEFormGetObjByName($oIE, "EC Summary")

$o_SubmitButton = _IEFormElementGetObjByName($o_form, "att")

$o_SubmitButton.click
WEnd
#include <IE.au3>
While 1

$url = "http://www2.eng.york.york.com/ecn/ec_summary.php"
$oIE = _IECreate($url,1)

$oCheckBox = _IEGetObjByName($oIE, "nounzip")

If Not $oCheckBox.checked Then
    $oCheckBox.checked = True
    _IEAction($oCheckBox,"click")
EndIf
WEnd
#include <IE.au3>
While 1
$oIE = _IEAttach("http://www2.eng.york.york.com/ecn/ec_summary.php")
$oForm = _IEFormGetObjByName($oIE, 'att')
_IEFormElementCheckBoxSelect($oForm, 0, 'nounzip', 1, 'byIndex')
WEnd
#include <IE.au3>
While 1
Local $oSelect = _IEFormElementGetObjByName($oForm, "att")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Y")
WEnd
#include <IE.au3>
While 1
$url = "http://www2.eng.york.york.com/ecn/ec_summary.php"
$oIE = _IECreate($url,1)
$oForm = _IEFormGetObjByName($oIE, "att")
_IEFormElementCheckBoxSelect($oForm, "on")
WEnd
#include <IE.au3>
While 1

$url = "http://www2.eng.york.york.com/ecn/ec_summary.php"
$oIE = _IECreate($url,1)

$oCheckBox = _IEGetObjByName($oIE, "att")

If Not $oCheckBox.checked Then
    $oCheckBox.checked = True
    _IEAction($oCheckBox,"click")
EndIf
WEnd

 

Link to comment
Share on other sites

i know all the code needs is: 

was: <TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip>

new: <TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip checked>

but our IT group is sitting on its ass not doing anything. If there is an easier way so it stays default please let me know. a lot of users forget to click on it and it causes major downtime on projects. 

Link to comment
Share on other sites

  • Developers

Slow down please and be polite to wait for somebody to stop by and voluntarily donate some time to your question.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This may be as close as i will ever get:

 

#include <IE.au3>
While 1
                _WindowMonitor() ; Call the Function to monitor window.
WEnd

Func _WindowMonitor()
                If WinActivate("EC Summary - Internet Explorer") Then

$url = "http://www2.eng.york.york.com/ecn/attachments_add.htm"
;$oIE = _IECreate($url,1)

$oCheckBox = _IEFormGetObjByName($url, "att")

If Not $oCheckBox.checked Then
    $oCheckBox.checked = True
    _IEAction($oCheckBox,"click")
EndIf
EndIf
EndFunc   ;==>_WindowMonitor

Func _Exit()
                Exit
EndFunc

just in case somebody actually looks at this and gets an idea of what i want to do. the winactive command im not sure if it will recognize the tab name though. 

Link to comment
Share on other sites

It's still not clear to me what you are attempting to accomplish (well, beyond toggling a checkbox). Please don't just post code and then say it doesn't work without providing further details. Why didn't it work? Were there errors? Post the results from the Scite output window.

Have you tried running the sample code from the help file entry for _IEFormElementCheckBoxSelect? If so, did you then examine the html and get an understanding of how this code is working?

Link to comment
Share on other sites

yeh, i tried many a different methods. i know im vague. 


all the pages are different see how the url structure is:
http://www2.eng.york.york.com/ecn/ec_summary.php?ecid=ba9fe1b6-0409-11e5-8005-cdf8735656af

i was thinking about just using this for it to be a general link:
http://www2.eng.york.york.com/ecn/ec_summary.php

now great thing is i noticed this in the source code:
 

<script name='javascript'>
window.name='ec_main';
// Set search window as top window.
window.focus();
</script>
<html>
<head>
and so goes on the code
dot
dot
dot

maybe i could use the window.name as something the code looks for before activating.
I want the script to run in the background. as soon as the page opens it looks for the form in html this:

<TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip>

magic happens and it checks the checkbox. 

when i modified the actual html file locally it would work when i modified it like this:
<TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip checked>

all i added was "checked", i dont have access to change any templates. I can only hope to build a autoit script for this. 

 

Link to comment
Share on other sites

okay so i got it to see active window, but is still get 
Error: Variable must be of type "Object"

 

#include <ie.au3>

While 1
                _WindowMonitor() ; Call the Function to monitor window.
WEnd

Func _WindowMonitor()

$sText = WinGetTitle(WinwaitActive("EC Summary"))

If WinActivate($sText) Then

_IELinkClickByText($sText,"nounzip")

$oCheckBox = _IEGetObjByName($sText, "nounzip")

If Not $oCheckBox.checked Then
$oCheckBox.checked = True
$oCheckBox.fireEvent ("onClick")

EndIf
EndIf
EndFunc   ;==>_WindowMonitor

Func _Exit()
                Exit
EndFunc

i love the active window code, so using for other projects. 

Edited by DeerSpotter
Link to comment
Share on other sites

Question on this:

You didn't indicate which line is giving you the error now. I suspect the issue is that you are trying to use the _IE functions without having a valid reference to the IE object. Try using _IEAttach and then use the resulting object instead of $sText.

​this is all i have to go off of:

<TD colSpan=3 align=center><INPUT type=checkbox value=Y name=nounzip>



How do i even guess what the object is? 

javascript has something like a similar object look alike:

 

<SCRIPT language=javascript>
//
// Set Row Color
//
function SetColor(IDX)
{
    L="L" + IDX;

    if ( document.att.elements['dlist[]'][IDX] ) {
    if ( document.att.elements['dlist[]'][IDX].checked ) {
        document.getElementById(L).style.background="#ff6666";
    }
    else {
        document.getElementById(L).style.background="";
    }
    }
    else if ( document.att.elements['dlist[]'].checked ) {
    document.getElementById(L).style.background="#ff6666";
    }
    else {
    document.getElementById(L).style.background="";
    }
}
</SCRIPT>

i'm not sure if that can be used as a object. 

Link to comment
Share on other sites

Sorry, but I'm still not clear why you need to monitor your browser and automatically click a checkbox whenever a specific page is present. You've told us that the script doesn't work, but you haven't provided the necessary details for us to further assist you. I suggest that you go back and reread my earlier responses, review the sample code in the help file, and then come back with any questions that you may have.

Link to comment
Share on other sites

Any of the _IE... functions rely on having a valid InternetExplorer object.  _IEAttach will create that object so the other _IE functions will work properly.  Your _IEClickbyText isn't going to work until you use _IEAttach to "grab" your browser window.

 

 

Edited by MuffinMan
poor spelling
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...