Jump to content

Auto Fill Problem


Recommended Posts

Hello, I'm trying to fill objects like in the page below in code but it has written in PHP language and WordPess source. It doesn't work right, it just fills above the textbox and when I click on other objects the text has gone away. Help me fill it and choose the item in the combo box, please!

Here is my AutoIt code

#include <FF V0.6.0.1b-15.au3>
$sURL = "https://www.grammarly.com/signup?breadcrumbs=true&install=true"

_FFConnect()
If _FFIsConnected() Then
    _FFOpenURL($sURL)
    $sInput = _FFObjGet("_60f178-field", "class") ; returns a string - no object!
    _FFObj($sInput, "value", "autoit")

    ;_FFSetValue("mmmmmm", "txtName", "id")

Else
    MsgBox(0,"Error:", "Can't connnect to FireFox")
EndIf

Here is PHP code

<input type="name" data-qa="txtName" maxlength="100" class="_60f178-field" value="">

 

Link to comment
Share on other sites

The React library wraps the input element to encapsulate it and it appears to monitor for the keypress event. I played around with this over the last day or so and finally came up with what I believe is a working solution --

#include <FF V0.6.0.1b-15.au3>
$sURL = "https://www.grammarly.com/signup?breadcrumbs=true&install=true"

_FFConnect()

If _FFIsConnected() Then
    _FFOpenURL($sURL)

    $sInput = _FFObjGet("_60f178-field", "class") ; returns a string - no object!

    If @error = $_FF_ERROR_Success Then
        _FFSendReact($sInput, "autoit")
    EndIf
Else
    MsgBox(0,"Error:", "Can't connnect to FireFox")
EndIf

Func _FFSendReact($sElement, $sValue = "")
    If StringLeft($sElement, 7) = "OBJECT|" Then $sElement = StringMid($sElement, 8)
    If StringLeft($sElement, 1) = "." Then $sElement = "window.content.document" & $sElement

    _FFCmd('FFau3.sendReact=function sendReact(a,b){try{var c=FFau3.WCD.createEvent("KeyboardEvent");for (var i = 0, len = b.length; i < len; i++) {c.initKeyEvent("keypress",true,true,null,false,false,false,false,b.charCodeAt(i),b.charCodeAt(i));a.dispatchEvent(c);};return 1}catch(e){return-1}return 0};')

    _FFCmd("FFau3.sendReact(" & $sElement & ",'" & $sValue & "');")
EndFunc

 

Link to comment
Share on other sites

$sInput0 = _FFObjGet("_60f178-field","class",0) ; returns a string - no object!
    $sInput1 = _FFObjGet("_60f178-field","class",1)
    $sInput2 = _FFObjGet("_60f178-field","class",2)
    If @error = $_FF_ERROR_Success Then
        _FFSendReact($sInput0, "autoit")
        _FFSendReact($sInput1, "autoit@gmail.com")
        _FFSendReact($sInput2, "autoit")
    EndIf

I have done the first requirement but I can't send "." character. :(

Edited by dangkhoa9xset
Link to comment
Share on other sites

Please keep the discussion on the open forum so that everyone can potentially help / benefit.

Quote

Please help me Danp2, I can't send "." character and help me select the combo box, I'm a newbie :(

$sInput0 = _FFObjGet("_60f178-field","class",0) ; returns a string - no object!
    $sInput1 = _FFObjGet("_60f178-field","class",1)
    $sInput2 = _FFObjGet("_60f178-field","class",2)
    If @error = $_FF_ERROR_Success Then
        _FFSendReact($sInput0, "autoit")
        _FFSendReact($sInput1, "autoit@gmail.com")
        _FFSendReact($sInput2, "autoit")

 

Link to comment
Share on other sites

It's a hack, but you can try this revised version --

Func _FFSendReact($sElement, $sValue = "")
    If StringLeft($sElement, 7) = "OBJECT|" Then $sElement = StringMid($sElement, 8)

    If StringLeft($sElement, 1) = "." Then $sElement = "window.content.document" & $sElement

    _FFCmd('FFau3.sendReact=function sendReact(a,b){try{var c=FFau3.WCD.createEvent("KeyboardEvent");c.initKeyEvent("keypress",true,true,null,false,false,false,false,008,008);a.value=b.concat(".");a.dispatchEvent(c);return 1}catch(e){return-1}return 0};')

    _FFCmd("FFau3.sendReact(" & $sElement & ",'" & $sValue & "');")
EndFunc

 

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...