phamtua Posted June 16, 2018 Share Posted June 16, 2018 expandcollapse popup#include <ButtonConstants.au3> #include <IE.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 442, 192, 124) Local $oIE = _IECreateEmbedded() GUICtrlCreateObj ($oIE, 0, 0, 609, 401) _IENavigate ($oIE, "https://bit.ly/2y1VYBz") ; After visit this link, please choose 6 Digits and Press Button1 $Button1 = GUICtrlCreateButton("Button1", 248, 416, 75, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $oQuery = _IEGetObjById($oIE, "field1") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field2") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field3") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field4") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field5") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field6") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field7") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field8") _IEFormElementSetValue ($oQuery, "123456") $oQuery = _IEGetObjById($oIE, "field9") _IEFormElementSetValue ($oQuery, "123456") EndSwitch WEnd Hi all, I'm trying to set text to 9 fields and click Submit Problem: After set text to 9 fields, I can't click Submit because it's disabled P/s: Please choose 6 Digits then Press Button1 Link to comment Share on other sites More sharing options...
Danp2 Posted June 16, 2018 Share Posted June 16, 2018 @phamtua Please explain why you need to automate the Windows activation process. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Danyfirex Posted June 16, 2018 Share Posted June 16, 2018 (edited) This works for me: expandcollapse popup#include <IE.au3> Local $oIE = _IECreate("https://bit.ly/2y1VYBz") _IELoadWait($oIE) Local $oBtn6 = 0 ;wait 20 seconds max for button exists (my internet conection is bad so I need to handle page load this way) Local $hTimer = TimerInit() Local $iDiff = 0 While Sleep(300) $oBtn6 = _IEGetObjByClass($oIE, "jma-click-to-continue-button ui-btn ui-btn-icon-right ui-icon-carat-r") $iDiff = TimerDiff($hTimer) If $iDiff > 20000 Or IsObj($oBtn6) Then ExitLoop EndIf WEnd If IsObj($oBtn6) Then ConsoleWrite(IsObj($oBtn6) & @CRLF) _IEAction($oBtn6, "click") ;wait input exists $hTimer = TimerInit() $iDiff = 0 Local $oQuery = 0 While Sleep(300) $oQuery = _IEGetObjById($oIE, "field1") $iDiff = TimerDiff($hTimer) If $iDiff > 20000 Or IsObj($oQuery) Then ExitLoop EndIf WEnd Sleep(1000) If IsObj($oQuery) Then $oQuery = _IEGetObjById($oIE, "field1") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field2") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field3") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field4") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field5") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field6") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field7") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field8") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field $oQuery = _IEGetObjById($oIE, "field9") _IEFormElementSetValue($oQuery, "123456") _IEAction($oQuery, "focus") Send("A") ;send a dummy value to activate next field Sleep(500) Local $oSubmit = _IEGetObjById($oIE, "custom-msft-submit") If IsObj($oSubmit) Then ConsoleWrite(IsObj($oSubmit) & @CRLF) _IEAction($oSubmit, "click") EndIf EndIf EndIf 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 It could be improved just think think haha. Saludos Edited June 16, 2018 by Danyfirex 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...
phamtua Posted June 16, 2018 Author Share Posted June 16, 2018 Thank you! 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