IGAOMD Posted August 30, 2006 Share Posted August 30, 2006 I am trying to write a script for a forum website that has a game on it involving clicking submit several times and then starting over again. I currently have it running but just moving the mouse to the submit button and telling it to click, but after a little while it tends to stop working for some reason. I was thinking that maybe I could get it to work better using the formsubmit command, but I have not been able to get it to work. I have tried several suggestions from other threads but I always end up with some sort of hWnd error from ie.au3. The website that I start at is http://www.d2xp.com/forum2/monsterarena.php . If you want to see the source of the pages that have the submit button you will have to join the site, make a character for this game, and then click on the challenge link on the right side of the screen. You will then go thru a start page where I need to click on the start battle button and then the actual battle page where I need to hit the submit button. When you join the site feel free to use me (IGAOMD) as a referral... . I am fairly sure the pages are java scripted, and from what I have been reading on these forums that makes a difference. Any help you can give me would be great...thanks in advance Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 30, 2006 Moderators Share Posted August 30, 2006 You will need to provide the html of the page if you want help. We at least need the html between the "<FORM" And "</FORM>" tags. Link to comment Share on other sites More sharing options...
Azu Posted August 30, 2006 Share Posted August 30, 2006 http://www.d2xp.com/forum2/monsterarena.php Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted August 30, 2006 Moderators Share Posted August 30, 2006 http://www.d2xp.com/forum2/monsterarena.phpI know what webpage it is, but I'm not going to register. If he wants help he can provide the infomation I requested. Link to comment Share on other sites More sharing options...
IGAOMD Posted August 30, 2006 Author Share Posted August 30, 2006 I know what webpage it is, but I'm not going to register. If he wants help he can provide the infomation I requested. I have attached the file to this reply. I did this rather than post the code because it is a pretty long file and there are several forms in it. I figured it would be easiest this way so I don't miss something that turns out to be important. Thanks again. monsterbattle.HTML Link to comment Share on other sites More sharing options...
IGAOMD Posted August 30, 2006 Author Share Posted August 30, 2006 I got to thinking about it and it would probably be a good idea to share how the page runs and my ideas for the script. This is for a forum RPG game where you select a monster to fight and you go into battle and you kill it and gain exp, the higher level you are the higher level monster you can fight and gain more exp along with XP which is something that you can trade for d2 items. The webpage I put in my first post is where I start out at and I have no problem with clicking the link that I want to go to, the move mouse and click has not failed me yet on this page so I will just leave it as is. After clicking this link it takes me to a one time page that basically says that I want to start the battle. The attached file I put in my previous reply is pretty much the same and I figure if you can help me out with that page then I can figure this one out fairly easy. After I hit start battle I go to the page which I attached, on this page I hit submit then it reloads with updated stats for the monster and myself, it's a turn based battle setup. I keep hitting submit until the monster is dead at which point I have to hit submit one more time and then it takes me back to the page where I originally clicked challenge above. I want to set up the script so that it clicks challenge, clicks start battle, then set up a function to that will be in a while loop which will hit submit until it sees the work acknowledge on the page at which point it stops the while loop hits submit one more time and then starts the process all over again - using a continuous while loop of course. I also will have a hotkey set so that I can turn it off. I would also be interested to know if there is a way to run this script minimized, but that is secondary to getting this all worked out for now. Thanks again. Link to comment Share on other sites More sharing options...
IGAOMD Posted August 31, 2006 Author Share Posted August 31, 2006 bump Link to comment Share on other sites More sharing options...
DaleHohm Posted August 31, 2006 Share Posted August 31, 2006 bumpI suggest you take a shot at this first and post some code you've tried, no matter how lame it may be. You'll get a much better response.Look at _IECreate (or _IEAttach) and the _IEForm* functions and examples in the helpfile.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
IGAOMD Posted August 31, 2006 Author Share Posted August 31, 2006 I tried out a couple of different things using the _IEAttach command with the ie.au3 included and I kept getting a hwnd error. I may have removed the stuff that I tried from my script but I will look when I get home from work in a few hours and post what all I am using at the moment and what I have not deleted from my test script also. Link to comment Share on other sites More sharing options...
IGAOMD Posted August 31, 2006 Author Share Posted August 31, 2006 This is the code I am currently using. As you can see it is all mouse clicks, which would be fine if it didn't stop working after about 20-30 mins or so. I am hoping that with the help of the people on this board I can get it to see the submit button and click it and set up some sort of error checking so that if something happens and it doesn't see the click that it will try again. CODE HotKeySet("!x", "quit") ; create hotkey alt-x to exit loop While 1 = 1 ;begin continuous loop $i = 0 ;function counter winwaitactive("Monster Arena - D2 eXPerience - Microsoft Internet Explorer") ; wait for web page to load MouseClick("left", 1030, 700, 1, 0) ; click on challenge link for Abizoah ;MouseClick("left", 1030, 715, 1, 0) ;click on challenge link for Haizhe ;MouseClick("left", 1030, 730, 1, 0) ;click on challenge link for Coeurl WinWaitActive("New Monster Battle - D2 eXPerience - Microsoft Internet Explorer") ; wait for web page to load ;MouseClick("left", 630, 670, 5, 0) ; click on start battle button Sleep(3000) ;allow webpage to fully load MouseMove( 630, 670, 0) ;move mouse to start battle button MouseClick( "left") ;click start battle button While $i <= 14 ;this value varies depending on how long it takes to kill the monster Call ("battle") ;call the battle function WEnd WinWaitActive("D2 eXPerience - Microsoft Internet Explorer", "", 5) ; wait for web page to load or timeout if monster killed in fewer attacks than battle function tried to do ;MouseClick("left", 100, 100, 1, 0) ; move mouse to allow time for page to fully load before clicking again WinWaitActive("Ongoing Battle - D2 eXPerience - Microsoft Internet Explorer", "", 5) ; wait for web page to load or timeout if monster killed in fewer attacks than battle function tried to do ;MouseClick("left", 610, 910, 5, 0) ; click submit and acknowledge win or loss Sleep(3000) ;allow webpage to fully load MouseMove( 610, 910, 0) ;move mouse to submit button MouseClick( "left") ;click submit button WEnd ; end loop go back to start Func quit() ; hotkey function Exit ; stop script when hotkey pressed EndFunc ; end function Func battle() WinWaitActive("D2 eXPerience - Microsoft Internet Explorer", "", 5) ; wait for web page to load ;MouseClick("left", 100, 100, 1, 0) ; move mouse to allow time for page to fully load before clicking again WinWaitActive("Ongoing Battle - D2 eXPerience - Microsoft Internet Explorer", "", 5) ; wait for web page to load ;MouseClick("left", 600, 970, 5, 0) ; click submit and attack monster Sleep(3000) ;allow webpage to fully load MouseMove( 600, 970, 0) ;move mouse to submit button MouseClick( "left") ;click submit button $i = $i + 1 EndFunc This is what I am using in my test script. I only have it set up to go into the start battle screen right now as it will error out with a hWnd error #include <IE.au3> winwaitactive("Monster Arena - D2 eXPerience - Microsoft Internet Explorer") MouseClick("left", 1030, 730, 1, 0) WinWaitActive("New Monster Battle - D2 eXPerience - Microsoft Internet Explorer") $oIE = _IEAttach ("New Monster Battle - D2 eXPerience - Microsoft Internet Explorer") $oForm = _IEFormGetObjByName ($oIE, "submit") $oQuery = _IEFormElementGetObjByName ($oForm, "submit") _IEFormSubmit ($oForm) these two lines are what I found to be the submit button in the start battle and during the battle pages as well as the acknowledge battle is over page ;<input type="submit" name="submit" id="submit" class="button" value="Start Battle" - Start Battle ;<input type="submit" name="submit" id="submit" class="button" value="Submit" - Submit and ack Link to comment Share on other sites More sharing options...
IGAOMD Posted September 1, 2006 Author Share Posted September 1, 2006 any ideas yet? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 1, 2006 Moderators Share Posted September 1, 2006 any ideas yet?I have one... Change you nick My wife is always having me help her with word twist, and every time I see your name, I see IAMGOD not IGAOMD.... Or maybe that was a play on text anyway Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
DaleHohm Posted September 1, 2006 Share Posted September 1, 2006 If your form name is really "submit" it may be the source of some pretty strange problems. We had another case reported recently where it was apparent that the DOM was confused and could not perform an _IEFormSubmit. I suggest that you get a reference to the submit button on the form and then use _IEAction($oButton, "click") instead. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
IGAOMD Posted September 2, 2006 Author Share Posted September 2, 2006 (edited) @SmOke_N...yes I did take IAMGOD and rearrange it to get this name... well here is the form that I am working with...I believe it is the 3rd form in the code on the start battle screen. CODE <form action="monsterarena.php" method="post" onsubmit="return disable_form();"> <input type="hidden" name="s" value="" /> <input type="hidden" name="do" value="donewbattle" /> <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="70%" align="center"> <thead> <tr> <td class="thead" colspan="2" align="center">New Monster Battle</td> </tr> <tr> <td class="alt1" colspan="2">Welcome, IGAOMD. In here, we have restrained some of the most powerful beasts in this land, harnessing their power for use in training warriors such as yourself. Will you challenge one of these beasts?</td> </tr> </thead> <tbody> <tr align="center"> <td class="tcat" colspan="2">Enter Info</td> </tr> <tr> <td class="alt1">What do you wish to challenge?<br /><dfn class="smallfont">Pick a beast from the list.</dfn></td> <td class="alt1"><select name="ibotid" id="ibotid"> <option value="1" >Thunder Flan</option><option value="2" >Training Bot</option><option value="3" >Grim Gaze</option><option value="4" selected="selected">Abizoah</option><option value="5" >Haizhe</option><option value="6" >Coeurl</option><option value="32" >Dire Wolf</option><option value="33" >Munmar</option> </select></td> </tr> <tr> <td class="alt1">Where should this Battle take place?<br /><dfn class="smallfont">We have many available arenas, choose the one most fitting to you.</dfn></td> <td class="alt1"><select name="sceneid" id="sceneid"> <option value="1" >Grass and Mountains Day</option><option value="2" >Cloud Tops</option><option value="3" >Cloudy Mountains</option><option value="4" >Dark Forest</option><option value="5" >Floating Ship Night</option><option value="6" >Floating Ship Day</option><option value="7" >Mountain Plains Day</option><option value="8" >Mountain Plains Night</option><option value="9" >Pirate Ship</option><option value="10" >Pirate Ship Stormy</option><option value="11" >Sandy Desert Day</option><option value="12" >Sandy Desert Night</option><option value="13" >Stone Cavern</option><option value="14" >Undead Tomb</option> </select></td> </tr> <tr> <td class="alt2">What background music would you like to hear? <br /><dfn class="smallfont">Choose which type of music you wish to play during the fight to soothe the spirit.</dfn></td> <td class="alt2"><select name="musicid" id="musicid"> <option value="0" selected="selected" disabled="disabled">No Battle Music defined</option> </select></td> </tr> <tr> <td class="alt1" colspan="2">These beasts are not free to fight.<br /><dfn class="smallfont">In order to prevent extinction, the gamekeepers placed a price tag on the beasts. A full price list can be found on the main page.</dfn></td> </tr> <tr align="center"> <td class="alt2" colspan="2"> <script type="text/javascript"> document.write('<input type="submit" name="submit" id="submit" class="button" value="Start Battle" disabled="disabled" accesskey="s" />'); </script> <noscript> You will be unable to perform an action until you either enable Javascript in your browser, or get a modern browser. </noscript> </td> </tr> </tbody> </table> </form> and these are my latest attempts at hitting the start battle submit button. #include <IE.au3> $oIE = _IEAttach ("New Monster Battle - D2 eXPerience - Microsoft Internet Explorer") $oSubmit = _IEFormElementGetObjByName ($oIE, "Submit") _IEAction ($oSubmit, "click") this one returns an error of line 2799 (referring to ie.au3) return HWnd($o_object.HWND()) return ^error error: the requested action with this object has failed. #include <IE.au3> $oIE = _IEAttach ("New Monster Battle - D2 eXPerience - Microsoft Internet Explorer") $oForm = _IEFormGetObjByName ($oIE, "2") $oButton = _IEFormElementGetObjByName ($oForm, "2") _IEAction ($oButton, "click") this returns the same error as above. I have tried a few other variations, but I just can't seem to figure it out. can someone point out my errors please? thx Edited September 2, 2006 by IGAOMD Link to comment Share on other sites More sharing options...
DaleHohm Posted September 2, 2006 Share Posted September 2, 2006 Regarding the HWND error... do you happen to be using the Firefox IE Tab extension? It has recently been found to cause this error (not necessarilyt taht you are trying to attach to one, but just when you have one running I believe). This is because it showes up in the Shell Window collection and does its best to look like an IE window, but it isn't... I will figure out a way around this, but I have not done so yet. Workaround for now is not to run it when you are trying to use _IEAttach Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
IGAOMD Posted September 3, 2006 Author Share Posted September 3, 2006 I don't have firefox I have Maxthon, so I tried the script without having maxthon open and it did not error out. Unfortunately it did not do anything at all. Link to comment Share on other sites More sharing options...
IGAOMD Posted September 3, 2006 Author Share Posted September 3, 2006 WOOHOO I finally got it to work...thanks for the help dale...greatly appreciated. Did I mention this is my first script? once you told me about the probs with other browsers being open while ie was open I just used one and it stopped erroring and after a few hours of trying some commands and figuring out what the forms were on the page and the input ref I got it all working. I have one thing that I would like to do to make it fully automated tho, right now I am running a loop to do a submit button that comes up several times, but I would like a way to stop the loop when the battle ends and I need to hit submit to acknowledge the end of the fight. I am pretty sure that if there is a way to find the word acknowledge on the page and when that happens end the loop it would work perfectly. Right now I am using a loop that ends after $i goes from 0 to 14, any help on how to get this last bit automated either by finding a word or by some other means? Link to comment Share on other sites More sharing options...
IGAOMD Posted September 3, 2006 Author Share Posted September 3, 2006 also for some reason _ieattach was giving me an error $_iestatus_nomatch in scite...was I using it wrong in my previous code? I have switched to _iecreate now and have no troubles with that, but I just wanna know, if I need _ieattach sometime in the future, what I am doing wrong with it. Link to comment Share on other sites More sharing options...
DaleHohm Posted September 3, 2006 Share Posted September 3, 2006 also for some reason _ieattach was giving me an error $_iestatus_nomatch in scite...was I using it wrong in my previous code? I have switched to _iecreate now and have no troubles with that, but I just wanna know, if I need _ieattach sometime in the future, what I am doing wrong with it.OK, so Maxathon hos the same issue... good to know. That will help with the fix.Regarding _IEAttach and nomatch... the default match for it is by Title and it does a sub-string match on the title string, so I see that you were very detailed in your title specification, perhaps there is a strange spacing or a strange character in the title string so you could probably get away with a less specific match string.Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
IGAOMD Posted September 3, 2006 Author Share Posted September 3, 2006 (edited) Regarding _IEAttach and nomatch... the default match for it is by Title and it does a sub-string match on the title string, so I see that you were very detailed in your title specification, perhaps there is a strange spacing or a strange character in the title string so you could probably get away with a less specific match string.Good to know, I will try to keep that in mind next time. I finally figured out how to set it up to know when to hit the final submit via pixel searching, so I think I have this script fully functional now, unless the page kicks back with some sort of error...thanks again for the help... Edit: Is it possible to have this post deleted or something? Edited September 3, 2006 by IGAOMD 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