tweakster2010 Posted February 4, 2015 Share Posted February 4, 2015 Hey all, Another weird one. I use the scrip to auto login into certain websites to cut down on manual entries. In turn Ive noticed certain websites (internal but not all) when I do _IEFormSubmit it locks up the script. Now most of them I got around by doing a sleep followed by send Enter. Case $Website Local $oIE = _IECreate("URL used") Local $oFormP = _IEGetObjById($oIE, "Logon") Local $oFormU = _IEGetObjById($oIE, "USERNAME") _IEFormElementSetValue($oFormU, GuiCtrlRead($Username1)) Local $oFormP = _IEGetObjById ($oIE, "password") _IEFormElementSetValue($oFormP, GuiCtrlRead($Pass1)) ;_IEFormSubmit ($oFormP) Sleep(1000) Send("{ENTER}") I commented out the IEFormSubmit as it literally makes everything else hang and I have to start task manager to end it. I figure its the way the internal website is behaving but was curious if anyone has seen this before and knows a better way around it? This solution works for most but 1, this last 1 I even tried _IELinkClickByText but the link looks like its actually a function later on in the website.(also a button instead of a direct link so I am figuring that is the main issue). Any insight or ideas greatly appreciated while i will continue to hammer away at trying to find a solution I like. Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 (edited) Reading the remarks for _IEFormSubmit, there is a couple things that could be the cause. 1) For many HTML forms it is not sufficient to use _IEFormSubmit() because there is often custom JavaScript tied to an onClick event for its Submit button. In these cases you'll need to simulate a click of the submit button instead of using _IEFormSubmit(). See the example for the "click" action of _IEAction(). 2) As well, some form processing relies on the "value" of the submit button being passed along with the rest of the form data (often when there is more than one submit button in the form and they are designed to trigger different results). This function will not result in a submit button value being passed. The solution is to use the "click" action of _IEAction() as above. You might also need to get the object of the submit button by using Local $submit = _IEGetObjByName($oIE, "button name") ;then trying to click it like so _IEAction($oSubmit, "click") Does that help? Edited February 4, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
tweakster2010 Posted February 4, 2015 Author Share Posted February 4, 2015 (edited) I literally was just trying that as you were posting <div class="fitem"> <button class="primary button radius" onclick="return (submitLogin())">Login</button> </div> Only reference to the button. and I assume button name would be the Button class being "primary button radius"? Never used it for button clicks >.> sorry for the ignorance with it. and Thanks for the super fast response Edited February 4, 2015 by tweakster2010 Link to comment Share on other sites More sharing options...
jdelaney Posted February 4, 2015 Share Posted February 4, 2015 (edited) Get all the buttons Loop through until your .onclick = 'return (submitlogin())' Or, get the div, and then it's child item. You can do either, easily with my signature: Any of these will work (1 get the div, and then it's button...get the button by the onclick...get the button based on it's text) $xpath = "//div[@class='fitem']/button" $xpath = "//button[@onclick='return (submitLogin())']" $xpath = "//button[.='Login']" Edited February 4, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 (edited) It's no problem at all, we are all here to learn in some way. The name of the button is "Login" if I'm not mistaken. Also, if that does not help, you might need to actually fire all 3 events to simulate an actual click of the submit button like so: Local $submit = _IEGetObjByName($oIE, "Login") $submit.fireEvent("onmousedown") $submit.fireEvent("onmouseup") _IEAction($submit, "click") Edited February 4, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
tweakster2010 Posted February 4, 2015 Author Share Posted February 4, 2015 @MikahS did not work unfortunately and I think its with how the website is coded. Internally some code with java and html others they leave it completely open(easiest ones to get setup). I have some that are literally only variables and I was like OK not happening LOL. @jdelaney I will definitely give it a shot if I cannot getting it working through the help file first. Are those in your signature custom scripts where I will need to do an Include? Or is there snippets I can snag out just to check it. Sorry still pretty new to the whole thing and my mentality is sometimes locked in hardware mode(software is still a new animal to me) Link to comment Share on other sites More sharing options...
jdelaney Posted February 4, 2015 Share Posted February 4, 2015 (edited) _IEgetobjbyname grabs by @name (and maybe @id?). You can grab the entire source, and paste it in, or create an au3 file and #include it... Or, skip it, and do your own loops. That's all the script does, is a recursive loop to make things easier for you. Edited February 4, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 I think jdelaney's solution might be the best option for you. Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
tweakster2010 Posted February 4, 2015 Author Share Posted February 4, 2015 (edited) @jdelaney pardon my ignorance, basically i completely learn off of the help file and notations. and I am looking over the IEbyXPATH. But to make sure I understand if i place it in an Include there is some built in _commands I can use to get it set, or do I need to precode the desired location to check? @MikahS Many thanks for the effort I have learned so much from these forums already and love to see the questions and see how I can use the knowledge that is posted! Corrected bolded, accidently said loop >.> Edited February 4, 2015 by tweakster2010 Link to comment Share on other sites More sharing options...
MikahS Posted February 4, 2015 Share Posted February 4, 2015 (edited) The pleasure is all mine. If you place the IEbyXPATH code into its own file and keep it in the script directory, you can easily include it like so: #include 'IEbyXPATH.au3' You would call the functions just like any other in AutoIt just like including IE.au3 and using _IEAction() in your script. Edited February 4, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
tweakster2010 Posted February 4, 2015 Author Share Posted February 4, 2015 hehe thank you, I was testing the file itself first with the URL, but it is unable to BGe_IEGetDomObjByXpathWithAttributes. Maybe due to it not having a forums? from what im seeing. expandcollapse popupStart Function=[BGe_IEGetDOMObjByXPathWithAttributes] with $sXPath=[//div[@id='top-menu']/ul[contains(@class,'WONT BE FOUND') or @id='menu-mainmenu']//a[contains(@href,'forum')]]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. Start Function=[BGe_RecursiveGetObjWithAttributes] level=[0]: $sNodeName=[div], $bNodeIsRelative=[True] $bIsConstrainted=[True]. UNable to BGe_IEGetDOMObjByXPathWithAttributes($oIE, //div[@id='top-menu']/ul[contains(@class,'WONT BE FOUND') or @id='menu-mainmenu']//a[contains(@href,'forum')]) 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