faustf Posted October 1, 2018 Share Posted October 1, 2018 hi guys , i try to automate , a shipment , in this site , with this code #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <File.au3> #include <IE.au3> #include <Array.au3> #include <INet.au3> Global $iCont_truck = 0, $iGTimeToCeckTruck = 1000, $iGTimeOutTruck = 1000 If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running. ProcessClose("iexplore.exe") EndIf Global $oIE = _IECreate("https://www.truckpooling.it/", 0, 1, 1, 1) ; <--- 0011 invisible explorer <--- 0111 visible explorer _IELoadWait($oIE, $iGTimeToCeckTruck, $iGTimeOutTruck) Local $oBtns = $oIE.document.GetElementsByTagName("span") For $oBtn In $oBtns $id = String($oBtn.classname()) ConsoleWrite($id & @CRLF) If $id = "select2-selection__rendered" Then _IEAction($oBtn, "click") _IEFormElementSetValue($oBtn, "fucecchio") _IEAction($oBtn, "click") EndIf Next a combobox for insert city not work someone could help me ?? thankz Link to comment Share on other sites More sharing options...
Danp2 Posted October 1, 2018 Share Posted October 1, 2018 That is a complex task due to the fact that it doesn't involve a standard select element and instead uses multiple elements and jQuery events. If I were trying to do this, I would use @Chimp's jQuerify routine to gain access to the jQuery object. With that, you should be able to trigger the events to mimic a user clicking the the element, entering text, selecting an item from the list, etc. Another option would be to use IUIAutomation. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
faustf Posted October 2, 2018 Author Share Posted October 2, 2018 o thankz for replay , but you have some example ?? thankz Link to comment Share on other sites More sharing options...
Danyfirex Posted October 2, 2018 Share Posted October 2, 2018 Here is an example without Danp2's suggestion. expandcollapse popup#include <IE.au3> Local $oIE = _IECreate("https://www.truckpooling.it/", 0, 0) Local $oObject1 = _IEGetObjByClass($oIE, "select2-selection select2-selection--single") ConsoleWrite(IsObj($oObject1) & @CRLF) _IEAction($oObject1, "focus") ControlSend(_IEPropertyGet($oIE, "hwnd"), "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") Local $oObject2 = _IEGetObjByClass($oIE, "select2-search__field") ConsoleWrite(IsObj($oObject2) & @CRLF) _IEAction($oObject2, "focus") ControlSend(_IEPropertyGet($oIE, "hwnd"), "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "00010") Sleep(2000) ;wait load ControlSend(_IEPropertyGet($oIE, "hwnd"), "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", "{ENTER}") WinSetState(_IEPropertyGet($oIE, "hwnd"), "", @SW_SHOW) MsgBox(0, "", "00010 should be selected") Func _IEGetObjByClass(ByRef $o_object, $s_Class, $i_index = 0) If Not IsObj($o_object) Then __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidDataType") SetError($_IEStatus_InvalidDataType, 1) Return 0 EndIf ; If Not __IEIsObjType($o_object, "browserdom") Then __IEConsoleWriteError("Error", "_IEGetObjByClass", "$_IEStatus_InvalidObjectType") SetError($_IEStatus_InvalidObjectType, 1) Return 0 EndIf ; Local $i_found = 0 ; $o_tags = _IETagNameAllGetCollection($o_object) For $o_tag In $o_tags If String($o_tag.className) = $s_Class Then If ($i_found = $i_index) Then SetError($_IEStatus_Success) Return $o_tag Else $i_found += 1 EndIf EndIf Next ; __IEConsoleWriteError("Warning", "_IEGetObjByClass", "$_IEStatus_NoMatch", $s_Class) SetError($_IEStatus_NoMatch, 2) Return 0 EndFunc ;==>_IEGetObjByClass Saludos faustf 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
faustf Posted October 2, 2018 Author Share Posted October 2, 2018 o thankz nice work Link to comment Share on other sites More sharing options...
faustf Posted October 2, 2018 Author Share Posted October 2, 2018 but now the problem is , in the page i have 2 combo box identical , and if i want set a second combo , how is possible to do that ? Link to comment Share on other sites More sharing options...
Danyfirex Posted October 2, 2018 Share Posted October 2, 2018 Change the instance Index local $objectSecondInstace=_IEGetObjByClass($oIE, "select2-selection select2-selection--single",1) Saludos faustf 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
faustf Posted October 2, 2018 Author Share Posted October 2, 2018 thankz so much , 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