Android Question Click Form Button

MODERN TALKING

Active Member
Licensed User
Longtime User
Hi guys,

Is there any way to click a Form or Login Button through Code?

What if we load the URL in Webview - then possible?

There is a reward if someone can offer a solution

Thank you,

"Goldmeister" Goldman
 

Douglas Farias

Expert
Licensed User
Longtime User
You can use WebViewExtras + Javascript

B4X:
Sub Process_Globals
End Sub

Sub Globals
    Private ww As WebViewExtras
    Private webCaptcha As WebView
    Private btConsultar as Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    ww.addJavascriptInterface(webCaptcha, "B4A")
    webCaptcha.LoadUrl("http://xxxxxxxxxxxxxxx")
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub



Sub webCaptcha_PageFinished (Url As String)
    Sleep(2500)
    Dim Javascript As String
    Javascript="B4A.CallSub('Process_HTML', false, document.documentElement.outerHTML)"
    ww.executeJavascript(webCaptcha, Javascript)
End Sub



Sub Process_Html(Html As String) 'IGNORE
    CallSubDelayed2(Me, "Process_HtmlImpl", Html)
End Sub

Sub Process_HtmlImpl(Html As String) 'HERE YOU HAVE THE HTML CODE OF WEBVIEW

    if Html.ToLowerCase.Contains("cpf") then
         btConsultar.Visible = true
    end if

End Sub






Sub btConsultar_Click

    'HERE FILL IN THE FORM'S CPF FIELD (YOU CAN CHANGE CPF for another FIELD)
    ww.executeJavascript(webCaptcha,"document.getElementById('cpf').value='"&edCpf.Text&"';")

    'HERE IS HOW TO CLICK ON WEBVIEW FORM BUTTON, CHANGE btnConsultaAvancar TO YOUR BUTTON
    ProgressDialogShow2("Carregando...",False)
    ww.executeJavascript(webCaptcha,"document.getElementById('btnConsultaAvancar').click();")


End Sub
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Thank you Douglas :)

This really works?

I try tomorrow but I send you a "donation" tonight first

And another one tomorrow - if it works ;)

Thank you so much for being kind to help me so fast

What's your email for Paypal?
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
works, i use this on some governamental websites, witouth api xD

dont need send me donation, thank you
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
You are a good man

Obrigado

Maybe you can do some PAID work for me - then it's not a donation

We both benefit

I tell you tomorrow minha amiga

Again, thank you and boa noite :)
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Douglas, you da man

WORKS PERFECTLY :)

Thank you so much

What's your email?

Tell you the job on Monday and if you can do it, then we talk payment ;)
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Douglas, the Website I wanna fill in the login form doesn't display the ID for the "Login" Button

How to assign it in code?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What is the website url?
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Hi Manfred,

Thank you for helping

I'm trying another way - gimme a day to check if this works

It's a Government Website - so it's sensitive :rolleyes:

ACHTUNG TANZEN!
 
Upvote 0

MODERN TALKING

Active Member
Licensed User
Longtime User
Manfred,

Can you help me one other matter - USD 10 donation

B4J JAR File not appearing on different computer, after compiling, and when it does appear - clicking on it to launch brings up "which program to open" dialog

But on another computer - fine

WEIRD
 
Upvote 0
Top