DeerSpotter Posted June 2, 2015 Share Posted June 2, 2015 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> <A style="FONT-SIZE: 10pt" href="/ecn/attachments_add.php?ecid=ba9fe1b6-0409-11e5-8005-cdf8735656af&showattuser=Y">show user</A> </TD></TR> <TR class=smallfont> <TD> <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> fixture for 250a.zip</A> 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"> <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 More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 please help. Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 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 More sharing options...
Developers Jos Posted June 2, 2015 Developers Share Posted June 2, 2015 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 More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 Slow down please and be polite to wait for somebody to stop by and voluntarily donate some time to your question.Josi'm sorry, its really frustrating me; this project. I promise to behave. Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 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 EndFuncjust 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 More sharing options...
Danp2 Posted June 2, 2015 Share Posted June 2, 2015 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? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 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-cdf8735656afi was thinking about just using this for it to be a general link:http://www2.eng.york.york.com/ecn/ec_summary.phpnow 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 dotmaybe 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 More sharing options...
DeerSpotter Posted June 2, 2015 Author Share Posted June 2, 2015 (edited) 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 EndFunci love the active window code, so using for other projects. Edited June 2, 2015 by DeerSpotter Link to comment Share on other sites More sharing options...
Danp2 Posted June 3, 2015 Share Posted June 3, 2015 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 4, 2015 Author Share Posted June 4, 2015 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 More sharing options...
Danp2 Posted June 4, 2015 Share Posted June 4, 2015 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. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
MuffinMan Posted June 4, 2015 Share Posted June 4, 2015 (edited) 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 June 4, 2015 by MuffinMan poor spelling Link to comment Share on other sites More sharing options...
232showtime Posted June 4, 2015 Share Posted June 4, 2015 can you post your whole code? ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 4, 2015 Author Share Posted June 4, 2015 just found out its a iframe. will try something different. Link to comment Share on other sites More sharing options...
Danp2 Posted June 4, 2015 Share Posted June 4, 2015 just found out its a iframe. will try something different.That's an important detail. Take a look at _IEFrameGetCollection and _IEFrameGetObjByName. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
DeerSpotter Posted June 8, 2015 Author Share Posted June 8, 2015 That's an important detail. Take a look at _IEFrameGetCollection and _IEFrameGetObjByName.didn't have time to work on this method. Does anybody have any example scripts that worked for through a iframe? Link to comment Share on other sites More sharing options...
Danp2 Posted June 8, 2015 Share Posted June 8, 2015 https://www.autoitscript.com/autoit3/docs/libfunctions/_IEFrameGetCollection.htmhttps://www.autoitscript.com/autoit3/docs/libfunctions/_IEFrameGetObjByName.htm Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now