tigexo Posted May 31, 2008 Share Posted May 31, 2008 Hi i try to make a script cliking on images Here is the HTML code <a href="details.php?id=953" onclick="return confirm..."><img src="images/deatils.gif" border="0" /></a> Here is the autoit script #include <IE.au3> ; Create a browser window and navigate to hotmail $oIE = _IECreate() _IENavigate($oIE, "http://www.whatever.com") ; get pointers to the login form and username and password fields $o_login = _IEGetObjByName($oIE, "login") $o_password = _IEGetObjByName($oIE, "passwd") ; Set field values and submit the form _IEFormElementSetValue($o_login, "mylogin") _IEFormElementSetValue($o_password, "mypasswd") Sleep(2000) $oInputs = _IETagNameGetCollection ($oIE, "input") For $oInput In $oInputs If $oInput.type = "submit" Then $oInput.click ExitLoop EndIf Next Sleep(5000) _IENavigate($oIE, "http://www.whatever.com/list.php") sleep(5000) $oImgs = _IEImgGetCollection ($oIE) For $oImg In $oImgs If $oImg.src = "images/details.gif" and $oImg.border = "0" Then $oImg.click endif Next Exit Well my problem is that it doesn't click on the image, i guess using _IEImgClick but as it's my first autoit script i ve got not so much experience. Also as u can see, there is a "onclick="return confirm ....". Could we use in the autoscript a sendkey {enter} to click ok in the msgbox If anyone has got an idea, please help Thx Link to comment Share on other sites More sharing options...
tigexo Posted May 31, 2008 Author Share Posted May 31, 2008 (edited) Ok i found a part of the answer in the forums, i was asking how to click "ok" in a popup Func clickonthatpopup() ;MsgBox(0, "info", "all I want is to click the popup") If ControlFocus("Microsoft Internet Explorer","OK",1) Then ControlClick("Microsoft Internet Explorer", "", "Button1") EndIf EndFunc But the script still doesn't click on the image-link, that's really annoying Do i have to try a mouseclick on it, but in this case is it possible to retrieve the position(coordinates) of these images with a function ?? Sorry if my questions are maybe sometimes a little bit easy, but i m a noob in autoit scripting. I read actively the forum to find a solution Thx for helping Edited May 31, 2008 by tigexo Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 31, 2008 Share Posted May 31, 2008 Hi i try to make a script cliking on images Here is the HTML code <a href="details.php?id=953" onclick="return confirm..."><img src="images/deatils.gif" border="0" /></a> Here is the autoit script #include <IE.au3> ; Create a browser window and navigate to hotmail $oIE = _IECreate() _IENavigate($oIE, "http://www.whatever.com") ; get pointers to the login form and username and password fields $o_login = _IEGetObjByName($oIE, "login") $o_password = _IEGetObjByName($oIE, "passwd") ; Set field values and submit the form _IEFormElementSetValue($o_login, "mylogin") _IEFormElementSetValue($o_password, "mypasswd") Sleep(2000) $oInputs = _IETagNameGetCollection ($oIE, "input") For $oInput In $oInputs If $oInput.type = "submit" Then $oInput.click ExitLoop EndIf Next Sleep(5000) _IENavigate($oIE, "http://www.whatever.com/list.php") sleep(5000) $oImgs = _IEImgGetCollection ($oIE) For $oImg In $oImgs If $oImg.src = "images/details.gif" and $oImg.border = "0" Then $oImg.click endif Next Exit Well my problem is that it doesn't click on the image, i guess using _IEImgClick but as it's my first autoit script i ve got not so much experience. Also as u can see, there is a "onclick="return confirm ....". Could we use in the autoscript a sendkey {enter} to click ok in the msgbox If anyone has got an idea, please help Thx So where, exactly does the script you posted fail? Does it find the username and password inputs, and fill them as you expected? Does your "submit" work? On the last part with the image click, did you try just using _IEImgClick()? 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...
tigexo Posted June 1, 2008 Author Share Posted June 1, 2008 So where, exactly does the script you posted fail? Does it find the username and password inputs, and fill them as you expected? Does your "submit" work? On the last part with the image click, did you try just using _IEImgClick()? The script logs in perfectly, navigates perfectly to http://www.whatever.com/list.php but exits without clicking on the images i wanna click. Yes i tried _IEImgClick ($oIE) $oImgs = _IEImgGetCollection ($oIE) _IEImgClick($oImgs, "images/details.gif", src) I don't really understand where is the problem, maybe because there is this image several times on the webpage. But my aim is to click them all It's really driving me crazy Link to comment Share on other sites More sharing options...
tigexo Posted June 1, 2008 Author Share Posted June 1, 2008 The script logs in perfectly, navigates perfectly to http://www.whatever.com/list.php but exits without clicking on the images i wanna click. Yes i tried _IEImgClick ($oIE) $oImgs = _IEImgGetCollection ($oIE) _IEImgClick($oImgs, "images/details.gif", src) I don't really understand where is the problem, maybe because there is this image several times on the webpage. But my aim is to click them all It's really driving me crazy In fact my only question is : "is there a mistake in this code ??" If yes were ?? THX Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 2, 2008 Share Posted June 2, 2008 In fact my only question is : "is there a mistake in this code ??" If yes were ?? THXLook at the examples in the help file under _IEImgClick(). Note they use the $oIE reference directly to look for the image, not a collection from _IEImgGetCollection().If the image is in a Frame, you might have to get a reference to the frame first, but barring that it should be more straight forward. 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