Jump to content

Entering data in editbox on website


texan
 Share

Recommended Posts

Never mind, I had my head my my a**. There is a form element on the website. The spy tool I was using did not display some information correctly and that confused me. Once I properly used the _IEFormElementSetValue everything worked just fine.

Its amazing how you can waste an hour researching the simplest thing in the world. Of course, 2 minutes after posting on here you figure it out on your own.

Link to comment
Share on other sites

The following program helps me locate the forms and elements in a web page

I made it loop so that I can enter manually info in the textboxes and then I see where my text went

#include <IE.au3>
$sUrl = "http://www.autoitscript.com/forum/index.php?app=core&module=global&section=login"
_AnalyzeWebPage($sUrl)
Exit

Func _AnalyzeWebPage($sUrl, $visible = 1)
Local $txt, $i, $j, $oIE, $oForms, $iNumForms, $oForm, $oElements, $iNumElements
_IEErrorHandlerRegister ()    ;else calling $oElement.name sends error if element has no name
$oIE = _IECreate($sUrl, 0, $visible)
$oForms = _IEFormGetCollection($oIE)
$iNumForms = @extended
Do
$txt = $txt & "There are " & $iNumForms & " forms on this page" & @CRLF
For $i = 0 To $iNumForms - 1
    $oForm = _IEFormGetCollection($oIE, $i)
    $txt = $txt & "Form-" & $i & "=" & $oForm.name & @CRLF
    $oElements = _IEFormElementGetCollection($oForm)
    $iNumElements = @extended
    $txt = $txt & "There are " & $iNumElements & " elements on this form" & @CRLF & _
      "  Element-Idx:Name=Value" & @CRLF
    For $j = 0 To $iNumElements - 1
        $oElement = _IEFormElementGetCollection($oForm, $j)
        $txt = $txt & "  Element-" & $j & ":" & $oElement.name & "=" & _IEFormElementGetValue($oElement) & @CRLF
    Next
Next
_PutTextInNotepad ($txt, 1)
;ConsoleWrite ($txt)
Until InputBox ("Analyze Page", "Exit (y/n)?") = "y"
_IEQuit($oIE)
_IEErrorHandlerDeRegister()
Return
EndFunc   ;==>

Func _PutTextInNotepad($txt, $Overwrite = 0)
    Local $Title = "LogFile", $oldtxt = ""
    If Not WinExists($Title) Then
        Local $iPid = Run("notepad.exe")
        Local $hWnd = _ProcessGetHWnd($iPid)
        WinSetTitle($hWnd, "", $Title)
    EndIf
    If $Overwrite = 0 Then $oldtxt = ControlGetText($Title, "", "Edit1")
    ControlSetText($Title, "", "Edit1", $txt & $oldtxt)
EndFunc   ;==>_PutTextInNotepad

;===============================================================================
Func _ProcessGetHWnd($iPid, $iOption = 1, $STitle = "", $iTimeout = 2000)
    Local $aReturn[1][1] = [[0]], $aWin, $hTimer = TimerInit()
    While 1
        ; Get list of windows
        $aWin = WinList($STitle)
        ; Searches thru all windows
        For $i = 1 To $aWin[0][0]
            ; Found a window owned by the given PID
            If $iPid = WinGetProcess($aWin[$i][1]) Then
                ; Option 0 or 1 used
                If $iOption = 1 Or ($iOption = 0 And $aWin[$i][0] <> "") Then
                    Return $aWin[$i][1]
                    ; Option 2 is used
                ElseIf $iOption = 2 Then
                    ReDim $aReturn[UBound($aReturn) + 1][2]
                    $aReturn[0][0] += 1
                    $aReturn[$aReturn[0][0]][0] = $aWin[$i][0]
                    $aReturn[$aReturn[0][0]][1] = $aWin[$i][1]
                EndIf
            EndIf
        Next
        ; If option 2 is used and there was matches then the list is returned
        If $iOption = 2 And $aReturn[0][0] > 0 Then Return $aReturn
        ; If timed out then give up
        If TimerDiff($hTimer) > $iTimeout Then ExitLoop
        ; Waits before new attempt
        Sleep(Opt("WinWaitDelay"))
    WEnd
    ; No matches
    SetError(1)
    Return 0
EndFunc   ;==>_ProcessGetHWnd
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...