HugoNatalis Posted February 22, 2019 Share Posted February 22, 2019 Hello all, Im currently trying to write a script able to click on a button/image, but this one isn't having any link/name/id linked to. The only thing it has is a class name (which seems variable) and a data-num. Operations wanted would be like : -Open IE with specific URL -Get Source -Search the string of the image (which is : " data-num="30">30</div> " ) -And finally click on the image corresponding to this string Hope some of you will understand my request and know how i can write my script , I'm also able to provide more informations/pictures if needed ! thx Link to comment Share on other sites More sharing options...
Developers Jos Posted February 23, 2019 Developers Share Posted February 23, 2019 Moved to the appropriate forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 23, 2019 Share Posted February 23, 2019 Hi @HugoNatalis, and welcome to the AutoIt forums You can start to take a look at _IE* functions in the Help file. All the things you want to do are easily achievable through those functions Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 23, 2019 Author Share Posted February 23, 2019 Sure @FrancescoDiMuro, i checked it ! But there is a lot of functions and i don't which one to use, as beginner as I am... Link to comment Share on other sites More sharing options...
Nine Posted February 23, 2019 Share Posted February 23, 2019 @HugoNatalis Look at the _IEImgGetCollection and the example that comes with it. If you still need help post your code here along with the DOM of the associated image you want to get at. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 23, 2019 Author Share Posted February 23, 2019 Didn't work with the _IEImgGetCollection, and i dont even know what script to write... Seems very hard to do Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 23, 2019 Share Posted February 23, 2019 (edited) @HugoNatalis It's not that hard as it seems If you "split" the work (as you already did), you can see that you can use: _IECreate() to open IE with the URL you want; _IEDocReadHTML() to get the source of the document; Loop through the return value of the above function to get what you are looking for; Once you get it, use _IEAction() or any _IE* function to click the item you were looking for. Edited February 23, 2019 by FrancescoDiMuro Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Nine Posted February 23, 2019 Share Posted February 23, 2019 32 minutes ago, HugoNatalis said: Seems very hard to do Open Example 2 of _IEImgGetCollection, change the url to yours. Save as the script in your personal folder. Press F5. Printscreen the result, paste (Ctrl-V) here. Voilà ! “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 23, 2019 Author Share Posted February 23, 2019 Does not even work too, the webpage does not recognize buttons as images... site has been coded with feets i bet. Link to comment Share on other sites More sharing options...
Nine Posted February 23, 2019 Share Posted February 23, 2019 1 hour ago, HugoNatalis said: the webpage does not recognize buttons as images What is the url ? is it public ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 23, 2019 Author Share Posted February 23, 2019 Site is private, i can pm you my infos to log in it if you want. Link to comment Share on other sites More sharing options...
Nine Posted February 23, 2019 Share Posted February 23, 2019 ya, sure, pm me, and tell me the page that is causing you trouble... “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 24, 2019 Author Share Posted February 24, 2019 On 23/02/2019 at 5:47 PM, Nine said: ya, sure, pm me, and tell me the page that is causing you trouble... PM sent ! Link to comment Share on other sites More sharing options...
Gianni Posted February 25, 2019 Share Posted February 25, 2019 ... it's worth have also a try with this ... Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 25, 2019 Author Share Posted February 25, 2019 So, after a few talks with @Nine (which i thank btw), my code to catch and click the objet I want is not working. Here is my code, The website to access is private, if some of you feel able to help me to code this i will give you the access to the website. expandcollapse popup#include <IE.au3> HotKeySet("{esc}", "_Exit") func _Exit() Exit EndFunc Global $oIE = _IECreate("http://www.lycee-champblanc.net/resa.php") WinSetState(_IEPropertyGet($oIE,"hwnd"),"",@SW_MAXIMIZE) _IELoadWait($oIE) Sleep(2500) SignIn() Func SignIn() Do Local $user = _IEGetObjByName($oIE,"username") Local $pwd = _IEGetObjByName($oIE,"password") Local $button = _IEGetObjById($oIE,"but_login") _IEFormElementSetValue($user,"My-Username") _IEFormElementSetValue($pwd,"My-Password") _IEAction($button,"click") _IELoadWait($oIE) _IELoadWait($oIE) Sleep(2500) $sujet1 = _IEDocReadHTML ($oIE) $refreshornot = "L'identifiant ou le mot de passe saisi est incorrect" $resultat1 = StringRegExp($sujet1, $refreshornot, $STR_REGEXPMATCH) Until $resultat1 = 0 _IELoadWait($oIE) Sleep(2500) Local $oInputs = _IETagNameGetCollection($oIE, "div") Local $sTxt = "" For $oInput In $oInputs $sTxt &= $oInput.className & @CRLF Next MsgBox($MB_SYSTEMMODAL, "Form DIV Type", "Form: " & $oInput.form.name & @CRLF & @CRLF & " Types :" & @CRLF & $sTxt) _IEQuit($oIE) EndFunc Link to comment Share on other sites More sharing options...
Nine Posted February 25, 2019 Share Posted February 25, 2019 Try this : expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <IE.au3> Opt ("MustDeclareVars", 1) HotKeySet("{esc}", "_Exit") func _Exit() Exit EndFunc Global $oIE = _IECreate("http://www.lycee-champblanc.net/resa.php") WinSetState(_IEPropertyGet($oIE,"hwnd"),"",@SW_MAXIMIZE) _IELoadWait($oIE) Sleep(2500) SignIn() Func SignIn() Do Local $user = _IEGetObjByName($oIE,"username") Local $pwd = _IEGetObjByName($oIE,"password") Local $button = _IEGetObjById($oIE,"but_login") _IEFormElementSetValue($user,"xxxxxx") _IEFormElementSetValue($pwd,"xxxxxxxx") _IEAction($button,"click") _IELoadWait($oIE) _IELoadWait($oIE) Sleep(2500) Local $sujet1 = _IEDocReadHTML ($oIE) Local $refreshornot = "L'identifiant ou le mot de passe saisi est incorrect" Local $resultat1 = StringRegExp($sujet1, $refreshornot, $STR_REGEXPMATCH) Until $resultat1 = 0 _IELoadWait($oIE) Local $oInputs = _IETagNameGetCollection($oIE, "div") Local $sTxt = "" For $oInput In $oInputs If $oInput.className = "vide" or $oInput.className = "" then ContinueLoop If StringLeft ($oInput.className,5) = "table" then $sTxt &= $oInput.className & " " & $oInput.innerText & @CRLF endif Next MsgBox (0,"",$sTxt) _IEQuit($oIE) EndFunc Works for me “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted February 25, 2019 Share Posted February 25, 2019 39 minutes ago, HugoNatalis said: my code to catch and click the objet I want is not working. Add some error checking/handling. Almost every _IE* function (and not) sets a code called @error to a non-zero value if an error occurs. You can check that value after calling a specific function, something like: _IECreate("URL") If @error Then ; Handle the error Else ; Go ahead with the script EndIf Doing this helps you a lot since you can see where your script is failing, and so, making your script works Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 25, 2019 Author Share Posted February 25, 2019 32 minutes ago, FrancescoDiMuro said: Doing this helps you a lot since you can see where your script is failing, and so, making your script works Very useful to check errors ! Thanks for the hint ! Also @Nine this code is working ! But now how to click on the correct string ? ControlClick ? Link to comment Share on other sites More sharing options...
Nine Posted February 25, 2019 Share Posted February 25, 2019 3 minutes ago, HugoNatalis said: But now how to click on the correct string ? ControlClick ? What would be the correct string ? “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
HugoNatalis Posted February 25, 2019 Author Share Posted February 25, 2019 Just now, Nine said: What would be the correct string ? The needed table (previously set in a GUI for example) , Example : <div class="table-jaune available" data-num="20">20</div> 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