#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private WebView1 As WebView
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
WebView1.LoadURL("https://www.b4x.com:51041/guessmynumber/index.html")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
RunJavaScript($"document.getElementById("txtNumber").value="123";"$)
End Sub
Private Sub Button2_Click
RunJavaScript($"document.getElementById("btnGuess").click();"$)
End Sub
Private Sub Button3_Click
Wait For (RunJavaScript($"document.getElementById("txtNumber").value;"$)) Complete(Html As String)
xui.MsgboxAsync(Html, "Get Field")
End Sub
Public Sub RunJavaScript (JS As String) As ResumableSub
#if B4A
WebViewExtras1.executeJavascript(WebView1, $"B4A.CallSub('Process_HTML', true, ${js})"$)
Wait For Process_Html(html As String)
Return html
#Else If B4J
Return WebView1.As(JavaObject).RunMethodJO("getEngine", Null).RunMethod("executeScript", Array(JS))
#Else If B4i
Dim sf As Object = WebView1.EvaluateJavaScript(js)
Wait For (sf) WebView1_JSComplete (Success As Boolean, Result As String)
Return Result
#end if
End Sub