Pain Posted January 2, 2008 Share Posted January 2, 2008 Hello everyone, I need some help with my script to find and press on a sertain button.I am Admin on my friends server and need to automate some functions on the Admin panel.I've tried with _IEFormGetObjByName but the thing is that there is several buttons with same form name.Same with rest of the _IEGet functions.There is also several buttons with same name so I can't make it to read the name on the button.The buttons has no alt tag.It doesn't work with navigate to the page that the button goes to.this is how it looks like, I wanna press on "Set to 0" on user 1 (first)If I can't get this to work I will tell the webmaster (the other admins) to change it when he got time but what would be best to change too then? Link to comment Share on other sites More sharing options...
DW1 Posted January 2, 2008 Share Posted January 2, 2008 Can't you tell it which instance in-case of multiple results? AutoIt3 Online Help Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 2, 2008 Share Posted January 2, 2008 (edited) You can enumerate objects (like buttons) as a collection and walk the collection to find an attribute, like the text on the button or the img src. If you know which instance it is, you can just specify that (i.e. 0 = first, 4 = fifth instance). Look at _IEFormElementGetCollection() in the help file. Edited January 2, 2008 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Pain Posted January 3, 2008 Author Share Posted January 3, 2008 (edited) I see what you mean but I can't get it to work. This is the part that doesn't work. It only change the name of the button "Move Free" to "Set 0" or press wrong button but as you said 0 = first I assume it should be 2 .... $oForm = _IEFormGetCollection ($oIE, 0) $oQuery = _IEFormElementGetCollection ($oForm, 2) _IEFormElementSetValue ($oQuery, "Set 0") _IEFormSubmit ($oForm) _IELinkClickByText ($oIE, "Yes") Edited January 3, 2008 by Pain Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 3, 2008 Share Posted January 3, 2008 I see what you mean but I can't get it to work. This is the part that doesn't work. It only change the name of the button "Move Free" to "Set 0" or press wrong button but as you said 0 = first I assume it should be 2 .... $oForm = _IEFormGetCollection ($oIE, 0) $oQuery = _IEFormElementGetCollection ($oForm, 2) _IEFormElementSetValue ($oQuery, "Set 0") _IEFormSubmit ($oForm) _IELinkClickByText ($oIE, "Yes") You didn't say exactly what you meant to do. You want to click a certain button? Then, assuming your index numbers are right, it's just: ; ... $oForm = _IEFormGetCollection ($oIE, 0) ; First form $oElem = _IEFormElementGetCollection ($oForm, 2) ; Third element on form _IEAction($oElem, "click") If that's not what you meant to do, please detail the actions you wanted to perform. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Pain Posted January 3, 2008 Author Share Posted January 3, 2008 It's working now, had wrong form $oForm = _IEFormGetCollection ($oIE, 2) $oElem = _IEFormElementGetCollection ($oForm, 1) _IEAction($oElem, "click") Thanks for the help Link to comment Share on other sites More sharing options...
Pain Posted January 3, 2008 Author Share Posted January 3, 2008 (edited) How do I disable "AutoIt Error Line: -1 Error: The requested action with this object has failed."I get this every time I close my script before it's finished but my script is never ending and I want it to be so.I have looked in the help file and searched around the forum for 30min without any good result.I was thinking about If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIfafter every possible function but it failed, still "AutoIt Error Line: -1"I even copyied it from the help files.Here is my script:Global $Link = "http://blablabla.com"$oIE = _IECreate ($Link & "search", 0, 1,2000,0)While 1$sHTML = _IEDocReadHTML ($oIE)$o_form = _IEFormGetObjByName ($oIE, "regform") $o_search = _IEFormElementGetObjByName ($o_form, "search")$file = FileOpen("search.txt", 0)If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") ExitEndIf$line = FileReadLine($file, 1)......I pressed X when it was still loading IE but IE doesn't have any -1 error if you look in the help file and therefore I believe it's the FileOpen. Edited January 3, 2008 by Pain Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 3, 2008 Share Posted January 3, 2008 Look in the help file at _IEErrorHandlerRegister() if it's IE generating the error, or look up the OBJ/COM reference section and add a custom COM error handler if it's something else. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Pain Posted January 3, 2008 Author Share Posted January 3, 2008 (edited) I was looking at it but it made no sence (I'm still new on AutoIt ) think I will let this error stay but once again thanks for the help Edited January 3, 2008 by Pain Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 4, 2008 Share Posted January 4, 2008 I was looking at it but it made no sence (I'm still new on AutoIt )Don't be intimidated by it! Just put _IEErrorHandlerRegister(), with no parameters, in somewhere before you do your first _IE* command. Run your script from SciTE and you'll get lots of info about the error in the console. That should do it if it's an IE error in the first place. The technical details of using your own custom error handler are not required, because Dale's default handler is quite good already.think I will let this error stayBad user! No soup for you! but once again thanks for the help You're welcome. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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