DelStone Posted July 24, 2011 Share Posted July 24, 2011 Hi, I'm having problems clicking two elements on the following html page. I've tried linkclicks and formsubmit and read the posts saying use _IEAction - I can't seem to get any of them to work. I'm having to resort to using send with tabs and enter which breaks quite easily and is really inappropriate for the task at hand... Can anyone spot what I'm doing wrong? <form method="post" action="/addfriend.php?id=1592841959&hf=friend_other" onsubmit="return Event.__inlineSubmit(this,event)"> <input type="hidden" autocomplete="off" id="post_form_id" name="post_form_id" value="82f51aa55cbff4b198d4b5ec4ed4ad43" /> <div id="addMsg"><p> <a href="#" onclick="show('addMsgBox'); hide('addMsg'); return false; ">[ Add a message ]</a> </p></div> <div id="addMsgBox" style="display:none; margin-left: 10px;"> <div class="add_personal_message" style="margin-bottom: 4px;"> Add a message: <a href="#" onclick="hide('addMsgBox'); show('addMsg'); return false;">Cancel</a> </div> <textarea onkeyup="textLimit('message',255,'message_msg');" id="message" name="message" class="textarea" cols="30" rows="3" style="width: 250px;" onfocus="" onblur=""></textarea> <br/><span id="message_msg" style="display: none;"><small>Keep it under 255 characters.</small></span></div> </div> <div class="buttonbox"> <input type="submit" class="inputsubmit" onclick="var w = add_to_friend_list_widget.dict["1592841959"];var d = w.get_form_data();for(k in d) { var i = document.createElement('input');i.type="hidden";i.name=k;i.value=d[k];this.form.appendChild(i);};return true;" id="add" name="add" value="Add Friend" /> <input type="button" class="inputbutton inputaux" onclick="history.go(-1);return true" id="cancel" name="cancel" value="Cancel" /> </div> </form> My current Autoit code which is not working: $add_btn = _IEGetObjById($ie, 'add') _IEAction($add_btn, "click") ;does not work $colTags = _IETagNameGetCollection($ie, "input") For $oTag In $colTags If StringInStr($oTag.value,"Add Friend") Then $hwnd = _IEPropertyGet($ie, "hwnd") _IEAction($oTag, "focus") ControlSend($hwnd, "", "[CLASS:Internet Explorer_Server;INSTANCE:1]", "{Enter}") ;does not work _IEAction($oTag, "click") ;does not work ExitLoop EndIf Next $id = _IEGetObjByName($ie, 'message') _IEFormElementSetValue($id, $message) ;works Link to comment Share on other sites More sharing options...
chrshea Posted July 24, 2011 Share Posted July 24, 2011 You might want to try _IEFormGetCollection and _IEFormElementGetCollection and then address the button as a member of the collection. Link to comment Share on other sites More sharing options...
DelStone Posted July 24, 2011 Author Share Posted July 24, 2011 Hi Chris I had tried that as well - the result was the same - the elements are not selected or clicked... There is something untoward - as I have never had any problems with other onclick statements before... the _IEAction has always worked - whether it was through using a collection of tags or collection of forms/elements... I'm not sure why there is a problem this time. Link to comment Share on other sites More sharing options...
Juvigy Posted July 25, 2011 Share Posted July 25, 2011 It has Java function in it ,so most likely you need to fire the onclick event - $element.FireEvent("onclick") or try executing the Java directly - "history.go(-1);return true" for example Link to comment Share on other sites More sharing options...
Exit Posted July 25, 2011 Share Posted July 25, 2011 If you are using IE9, might be the explanation. Use my _SetIE8() function in that post and try it again. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
DelStone Posted July 25, 2011 Author Share Posted July 25, 2011 Hi Thanks for the suggestions. Using $element.FireEvent("onclick") does nothing like the alternatives I've tried above. I can't execute the java directly (or can I) given it comprises: <input type="submit" class="inputsubmit" onclick="var w = add_to_friend_list_widget.dict["1592841959"];var d = w.get_form_data();for(k in d) { var i = document.createElement('input');i.type="hidden";i.name=k;i.value=d[k];this.form.appendChild(i);};return true;" id="add" name="add" value="Add Friend" /> Link to comment Share on other sites More sharing options...
DelStone Posted July 25, 2011 Author Share Posted July 25, 2011 If you are using IE9, might be the explanation. Use my _SetIE8() function in that post and try it again. That worked - thank you very very much!!!I have been on this one problem for 3 days - and I can't believe it's such a simple fix! Once again thank you v much. 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