a2z Posted November 21, 2006 Share Posted November 21, 2006 Hi, i'm tring to make a little script to rate pictures in www.rate.ee But i have some problems. Source: expandcollapse popup#NoTrayIcon #include <GUIConstants.au3> #include <IE.au3> _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GUICreate("Rate", 640, 580, _ (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _ $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360) $GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30) $GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30) $GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30) $GUI_Button_Stop = GUICtrlCreateButton("Rate 5", 340, 420, 100, 30) $GUI_Create_Group = GUICtrlCreateGroup("Rate", 10, 455, 500, 50) GUISetState() ;Show GUI _IENavigate ($oIE, "http://www.rate.ee/show.php") ; Waiting for user to close the window While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $GUI_Button_Home _IENavigate ($oIE, "http://www.rate.ee/show.php") Case $msg = $GUI_Button_Back _IEAction ($oIE, "back") Case $msg = $GUI_Button_Forward _IEAction ($oIE, "forward") Case $msg = $GUI_Button_Stop _IEFormElementRadioSelect ($oIE,"rating", "5") EndSelect WEnd GUIDelete() Exit So when the "Rate 5" button is pressed, picture should be rated with 5 points. But what's the problem? It doesn't works. In HTML source radio button is marked as <input type=radio name=rating value=5 onclick="destroy_ten_div();if(pressed.value==0){pressed.value=1;this.form.submit()}"> Please help. Link to comment Share on other sites More sharing options...
mikehunt114 Posted November 21, 2006 Share Posted November 21, 2006 I could be wrong because I just had a quick look, but shouldn't it be: _IEFormElementRadioSelect($oIE, "5", "rating") IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
chie Posted November 21, 2006 Share Posted November 21, 2006 (edited) this is what im using, so it selects perfectly radio 5, but for some odd reason it wont klick it. $oIE = _IECreate ("http://www.rate.ee/show.php",1,1) _IELoadWait ($oIE) $oForm = _IEFormGetCollection($oIE,0) ; find the form $getforminputname = _IEFormGetObjByName($oForm,"rating") ; input name $oForm2 = _IEFormElementRadioSelect ($oForm, "5", "rating", 1, "byValue") ; form,value,name,selected,byValue _IEAction ($oForm, "click") Edited November 21, 2006 by chie Link to comment Share on other sites More sharing options...
mikehunt114 Posted November 21, 2006 Share Posted November 21, 2006 (edited) Here you go. $oIE = _IECreate ("http://www.rate.ee/show.php", 1) $oForm = _IEFormGetCollection($oIE, 1) _IEFormElementRadioSelect ($oForm, "5", "rating") _IEFormSubmit($oForm) Edited November 21, 2006 by mikehunt114 IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
chie Posted November 21, 2006 Share Posted November 21, 2006 (edited) Here you go.Nop its not working that way, take a look:(it will log you in autmatically) What you see, is that if you use $oForm = _IEFormGetCollection($oIE, 1), it wont select the radio button & will simply submit radio button labeled 10(there is an error message in the bottom) #include <IE.au3> $oIE = _IECreate("http://www.rate.ee/show.php",1) $oForm = _IEFormGetCollection($oIE,0) $Username = _IEFormElementGetObjByName($oForm,"username") $Password = _IEFormElementGetObjByName($oForm,"password") _IEFormElementSetValue($Username,"testuser2") _IEFormElementSetValue($Password,"123456") _IEFormSubmit($oForm) _IENavigate($oIE,"http://www.rate.ee/show.php") _IELoadWait ($oIE) ;~ $oForm = _IEFormGetCollection($oIE,0) ; find the form ;~ $getforminputname = _IEFormGetObjByName($oForm,"rating") ; input name ;~ $oForm2 = _IEFormElementRadioSelect ($oForm, "5", "rating", 1, "byValue") ; form,value,name,selected,byValue ;~ _IEAction ($oForm, "click") $oForm = _IEFormGetCollection($oIE, 1) _IEFormElementRadioSelect ($oForm, "5", "rating") _IEFormSubmit($oForm) @ prof28 I see you made a GUi for rating, well hire is an idea, why not to try to make it this way: script starts ...opens invisible window in the background & start rating Edited November 21, 2006 by chie Link to comment Share on other sites More sharing options...
mikehunt114 Posted November 21, 2006 Share Posted November 21, 2006 (edited) Nop its not working that way, take a look:(it will log you in autmatically)What you see, is that if you use $oForm = _IEFormGetCollection($oIE, 1), it wont select the radio button & will simply submit radio button labeled 10(there is an error message in the bottom)Works perfectly for me, selects the correct radio and submits. Edited November 21, 2006 by mikehunt114 IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
chie Posted November 21, 2006 Share Posted November 21, 2006 Works perfectly for me, selects the correct radio and submits.I swear it was not working when i tried, well maybe it was just too fast. Still, let me explane why it is not working(I used messageboxes to stop the script)yes It will select the radio box but then it will submit radiobox 10[& this is wrong radio box]) if you submit (radioBox), then on the next page you will see the picture, you just rated: if you dont see that picture, this means, that radiobox was not submitted. Example: http://www.image2host.com/t.php?img=a8be12b81b.jpg Link to comment Share on other sites More sharing options...
DaleHohm Posted November 22, 2006 Share Posted November 22, 2006 You can submit forms, you cannot submit radioboxes. 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...
chie Posted November 22, 2006 Share Posted November 22, 2006 You can submit forms, you cannot submit radioboxes.Dalewell if you left click on the radio box, it will automatically submit klikked box(then there wont be any need to submit the form), in this case, do you know why the _IEAction ($oForm, "click") is not working? Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted November 22, 2006 Share Posted November 22, 2006 (edited) $oForm = _IEFormGetCollection($oIE,0) $oRate = _IEFormElementGetCollection($oForm,10) _IEAction($oRate,"click") to the rescue again @Extended helps with collection stuff Edited November 22, 2006 by thatsgreat2345 Link to comment Share on other sites More sharing options...
chie Posted November 22, 2006 Share Posted November 22, 2006 (edited) EDIT CHECK my next post for working example! to the rescue again @Extended helps with collection stuff Yay it works, thank you thatsgreat2345 I think I understand now why. & for lazy people: PS: it took me 5h to make:(Reason ( Alot of experimenting.... ) as far as I understand if sleep is not used, then its simply too fast & ...I dont know why but it simply stops.) This code can rate 24/7 now in your background ( but if your PC laggs alot, then it will probably stop. ) #include <IE.au3> HotKeySet("{esc}", "_Exit") while 1 $oIE = _IECreate("http://www.rate.ee/show.php",0,0,1) $oBOdy = _IEBodyReadText($oIE) sleep(500) if StringInStr($oBody, "keerinud") Then _IENavigate ($oIE, "http://www.rate.ee/show.php");if found wordpeace User has blokked you "keerinud" _IELoadWait ($oIE) $oForm = _IEFormGetCollection($oIE,0) sleep(1000) $oRate = _IEFormElementGetCollection($oForm,10) sleep(1000) _IEAction($oRate, "click") sleep(1000) _IEQuit ($oIE) ;EDIT CLOSE OPENED WINDOW WEnd Func _Exit() Exit EndFunc ;==>_Exit Edited November 23, 2006 by chie Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted November 22, 2006 Share Posted November 22, 2006 ur continually creatinga new IE window... and thats going to lag ur PC like crap change your usernam/pass to what u want and it will auto log in for you #include <IE.au3> HotKeySet("{esc}", "_Exit") $oIE = _IECreate("http://www.rate.ee/",0,0) $oForm = _IEFormGetCollection($oIE,0) $Username = _IEFormElementGetObjByName($oForm,"username") $Password = _IEFormElementGetObjByName($oForm,"password") _IEFormElementSetValue($Username,"testuser2") _IEFormElementSetValue($Password,"123456") _IEFormSubmit($oForm) _IENavigate($oIE,"http://www.rate.ee/show.php") _IELoadWait() while 1 $oForm = _IEFormGetCollection($oIE,0) $oRate = _IEFormElementGetCollection($oForm,10) _IEAction($oRate, "click") _IELoadWait($oIE) WEnd Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
chie Posted November 23, 2006 Share Posted November 23, 2006 (edited) It started bothering me whaen I first learned how to use _Iecreate (The problem was the script simply stopped time to time without no error message). i think i finally solved atleast 1 part of the mystery. @thatsgreat2345 your last post is not actyally working 100%, since the script simply stops after rating 1 or 2 pictures. Same goes for most my codes in this post. I added if error..then do something & some loops in thatsgreat2345 code, Lagged my PC pretty bad & Ran the code for about 20 hours. All worked fine. Extra info: some data collected from previoust tests was used, like: 1. IE crashing, due ShockhWave flash object Add-on in IE (Was disabled before last test) 2. Do not show pictures in IE (this was enabled in IE[Tools-->Internet options-->Advanced & Uncheck the box] so the browser wont even bother to DL pictures & there is no need for them anyway) I dont use IE to surf the Internet so it is not a problem. Just to note:(Error log)--> IE.au3 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch --> IE.au3 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType --> IE.au3 Error from function _IEFormElementSetValue, $_IEStatus_InvalidDataType --> IE.au3 Error from function _IEFormSubmit, $_IEStatus_InvalidDataType --> IE.au3 Warning from function _IELoadWait, $_IEStatus_LoadWaitTimeout Edited November 24, 2006 by chie Link to comment Share on other sites More sharing options...
a2z Posted November 25, 2006 Author Share Posted November 25, 2006 (edited) Nop its not working that way, take a look:(it will log you in autmatically) What you see, is that if you use $oForm = _IEFormGetCollection($oIE, 1), it wont select the radio button & will simply submit radio button labeled 10(there is an error message in the bottom) #include <IE.au3> $oIE = _IECreate("http://www.rate.ee/show.php",1) $oForm = _IEFormGetCollection($oIE,0) $Username = _IEFormElementGetObjByName($oForm,"username") $Password = _IEFormElementGetObjByName($oForm,"password") _IEFormElementSetValue($Username,"testuser2") _IEFormElementSetValue($Password,"123456") _IEFormSubmit($oForm) _IENavigate($oIE,"http://www.rate.ee/show.php") _IELoadWait ($oIE) ;~ $oForm = _IEFormGetCollection($oIE,0) ; find the form ;~ $getforminputname = _IEFormGetObjByName($oForm,"rating") ; input name ;~ $oForm2 = _IEFormElementRadioSelect ($oForm, "5", "rating", 1, "byValue") ; form,value,name,selected,byValue ;~ _IEAction ($oForm, "click") $oForm = _IEFormGetCollection($oIE, 1) _IEFormElementRadioSelect ($oForm, "5", "rating") _IEFormSubmit($oForm)oÝ÷ Úèo±ç²¢éuæR'讶x0zYa·¢±©âuæ°)è¶Ú-¯+h©ÛaÌÊÇ+lµªí²^ȧ¾+"nW°whÂ)íæÚrH+¢éÝjjlµªí«bêº^aë"·l¶)৶ڡ»fl¢É®×è¶Øb°2-)ä¶wv¥¦ÚæzÊ&zØbIbëajÐn·ræ×F®¶sbb33c¶õ&FRÒôTf÷&ÔVÆVÖVçDvWD6öÆÆV7Föâb33c¶ôf÷&Òò6VÆV7B&Fö&÷ Edited November 25, 2006 by prof28 Link to comment Share on other sites More sharing options...
a2z Posted November 26, 2006 Author Share Posted November 26, 2006 expandcollapse popup#include <GuiConstants.au3> #include <IE.au3> Opt("TrayMenuMode",1) $exititem = TrayCreateItem("Exit") $showitem = TrayCreateItem("Show") TraySetState() _IEErrorHandlerRegister () $oIE = _IECreateEmbedded () GuiCreate("Rate", 604, 445,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Group_1 = GuiCtrlCreateGroup("Rate", 0, 320, 600, 120) $Button_2 = GuiCtrlCreateButton("Only 1", 10, 340, 80, 20) $Button_3 = GuiCtrlCreateButton("Only 2", 100, 340, 80, 20) $Button_4 = GuiCtrlCreateButton("Only 3", 190, 340, 80, 20) $Button_5 = GuiCtrlCreateButton("Only 4", 280, 340, 80, 20) $Button_6 = GuiCtrlCreateButton("Only 5", 370, 340, 80, 20) $Button_7 = GuiCtrlCreateButton("1-3", 10, 370, 80, 20) $Button_8 = GuiCtrlCreateButton("1-5", 100, 370, 80, 20) $Button_9 = GuiCtrlCreateButton("3-5", 190, 370, 80, 20) $Button_10 = GuiCtrlCreateButton("STOP", 480, 340, 110, 90) $Group_11 = GuiCtrlCreateGroup("Rate.ee", 0, 0, 600, 320) $Combo_12 = GuiCtrlCreateCombo("5", 330, 370, 50, 21) $Label_13 = GuiCtrlCreateLabel("In age", 280, 370, 40, 20) $Label_14 = GuiCtrlCreateLabel("->", 390, 370, 20, 20) $Combo_15 = GuiCtrlCreateCombo("100", 420, 370, 50, 21) $Button_Exit = GuiCtrlCreateButton("Quit", 10, 400, 80, 20) $GUIActiveX = GUICtrlCreateObj($oIE, 2, 15, 594, 303) GUISetState() ;Show GUI _IENavigate ($oIE, "http://www.rate.ee/show.php") while 1 $msg = TrayGetMsg() $msg2 = GUIGetMsg() Select Case $msg = 0 ContinueLoop Case $msg2 = $showitem WinSetState("Rate", "", @SW_SHOW) Case $msg2 = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Select Case $msg2 = $Button_6 _IENavigate($oIE,"http://www.rate.ee/show.php") _IELoadWait($oIE) EndSelect while 1 ; Loop 1 Begins ;Collect info about the page & rate the image with 5 while 1 ; Loop 2 Begins $oForm = _IEFormGetCollection($oIE,0) if @error <> 0 then ExitLoop $oRate = _IEFormElementGetCollection($oForm,10) ; select radiobox 5 sleep(100) if @error <> 0 then ExitLoop _IEAction($oRate, "click") if @error <> 0 then ExitLoop _IELoadWait($oIE) if @error <> 0 then ExitLoop sleep(3000) WEnd ; Loop 2 Ends ;If any kind of error happened in loop 2, refresh the page while 1 ; Loop 3 Begins _IENavigate($oIE,"http://www.rate.ee/show.php") _IELoadWait($oIE) ; if no error happened go to loop 1 beginning & continue rating. If @error = 0 then ExitLoop WEnd ; Loop 3 Ends WEnd ; Loop 1 Ends Func _Exit() _IEQuit($oIE) Exit EndFunc Whatta hell is wrong? It doesn't rate, i can't close it. I have no idea, what is wrong. It shows that there is a Case error, but it's not true. Who can help me please (A)? Link to comment Share on other sites More sharing options...
chie Posted November 27, 2006 Share Posted November 27, 2006 (edited) Whatta hell is wrong? It doesn't rate, i can't close it. I have no idea, what is wrong. It shows that there is a Case error, but it's not true. Who can help me please (A)?because you have many Bugs: Cant close it?: Case $msg2 = $GUI_EVENT_CLOSE Exit Hotkeyset("{esc}", "_Exit") Func _Exit() _IEQuit($oIE) Exit EndFunc oÝ÷ Ø&§¶¶y«¢+Ø ÍÀÌØíµÍôÀÌØíÍ¡½Ý¥Ñ´(í¹½Ð ÍÀÌØíµÍÈôÀÌØíÍ¡½Ý¥Ñ´(ì´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´´)U%MÑMÑÑ¡M]}M!=¤(ÀÌØíá¥Ñ¥Ñ´ôQÉå ÉÑ%Ñ´ ÅÕ½Ðíá¥ÐÅÕ½Ðì¤(ÀÌØíÍ¡½Ý¥Ñ´ôQÉå ÉÑ%Ñ´ ÅÕ½ÐíM¡½ÜÅÕ½Ðì¤)QÉåMÑMÑÑ¡M]}!%¤(íM¡½ÜU$()}%9Ù¥Ñ ÀÌØí½%°ÅÕ½Ðí¡ÑÑÀè¼½ÝÝܹÉѹ½Í¡½Ü¹Á¡ÀÅÕ½Ðì¤()Ý¡¥±Ä(ÀÌØíµÍÈôU%Ñ5Í ¤(ÀÌØíµÍôQÉåÑ5Í ¤(M±Ð(íø ÍÀÌØíµÍôÀ(íø ½¹Ñ¥¹Õ1½½À( ÍÀÌØíµÍôÀÌØíÍ¡½Ý¥Ñ´(]¥¹MÑMÑÑ ÅÕ½ÐíIÑÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì°M]}M!=¤( ÍÀÌØíµÍÈôÀÌØíU%}Y9Q} 1=M½ÈÀÌØíµÍôÀÌØíá¥Ñ¥Ñ´(á¥Ð($(% ÍÀÌØíµÍÈôÀÌØí ÕÑѽ¹|Ø(%}ÍÑÉÑÑÉ¥¹ ¤)¹M±Ð)]¹()Õ¹}ÍÑÉÑÑÉ¥¹ ¤(íIÑ¥¹]¡¥±ÄѸ¸¸¡¥É)¹Õ¹But you may also want to take a look at this code: its basically same as yours only little bit better. take a look at attachment, since the code is 833 lines Edited November 27, 2006 by chie 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