Jump to content
dangkhoa9xset

Auto Fill Problem

Recommended Posts

dangkhoa9xset

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="">

 

Share this post


Link to post
Share on other sites
Danp2

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

 

  • Like 1

Share this post


Link to post
Share on other sites
dangkhoa9xset

It works perfectly! thanks, sir. One two things:

1. How I choose another field because of the same class?

2. What I have to do to select a combo box?

I'm a newbie, please help me. Thanks a lot. :)

Share this post


Link to post
Share on other sites
dangkhoa9xset
$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

Share this post


Link to post
Share on other sites
Danp2

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")

 

  • Like 1

Share this post


Link to post
Share on other sites
dangkhoa9xset

anyone help me send "." to these fields? please :(

 

Edited by dangkhoa9xset

Share this post


Link to post
Share on other sites
Danp2

The issue is that the charCode <> keyCode for certain characters such as comma and period, so the posted solution doesn't work as-is.

I have an idea for an alternate solution, but haven't worked out all of the details of implementation.

  • Like 1

Share this post


Link to post
Share on other sites
Danp2

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

 

  • Like 1

Share this post


Link to post
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

×