0

私はwebviewを追加したアプリを作成し、Gmailのログインページにリダイレクトしました。WindowsのGmail 10のユーザー名とパスワードラズベリーパイのiot 11

GmailWebView.Navigate("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1&osid=1#identifier") 

ここで、ユーザーIDとパスワードを追加してログインをクリックしますが、できません。 System.Windows.Forms.WebBrowserを追加することができないため、使用できます。私たちはこれを完了するためにwin10に何かを持っていますか?あなたのURLに移動し、ナビゲートがNavigationCompletedがあなたのWebViewをcontrollできraised.and完了後

+0

Googleを使用して第三者認証を受けたり、文字通りGmailにログインしようとしていますか? – gilliduck

+0

私はwebviewでGmailにログインしようとしています。ここでは、ユーザーIDとパスワードをコードで渡し、最初のメールを選択して開くことができます。 – Farhan

+0

私たちがwin10 iotでウェブサイト上のテキストボックスにデータを入力するために使用できる方法はありますか?送信またはログイン時にリダイレクトされます。 – Farhan

答えて

1

まず

<WebView x:Name="webView" NavigationCompleted="webView_NavigationCompleted"></WebView> 

以下のようなあなたのWebViewでNavigationCompletedに加入します。

await webView.InvokeScriptAsync("eval", new[] { 
     "var usernameText=document.getElementById(\"UserName\");"+ 
     "var passwordText=document.getElementById(\"Password\");"+ 
     "var button=document.getElementById(\"SubmitButton\");"+ 
     "button.attachEvent('onclick', MyButtonClicked);"+ 
     "function MyButtonClicked(){" + 
      " //click Function"+ 
     "}" 
    }); 
+0

エラーの下 'System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(タスクのタスク) でSystem.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(タスクのタスク) でSystem.Runtime.CompilerServices.TaskAwaiter''1.GetResultで取得() at AllinOnePi.MainPage。 d__36.MoveNext() ' – Farhan

+0

親愛なる@Farhan InvokeScriptAsyncメソッドを使用してWebViewコンテンツにスクリプトを呼び出したり、スクリプトを挿入したりして、WebViewのコンテンツとやりとりすることができます。ScriptNotifyイベントWebViewコンテンツから情報を取得します。 WebViewコンテンツ内でJavaScriptを呼び出すには、InvokeScriptAsyncメソッドを使用します。呼び出されたスクリプトは文字列値のみを返すことができます。 詳細はこちら[link](https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.controls.webview) –

+0

私は以下のコードを使用しようとしましたが、上記の例外を除いて 初期化時にuriが定義されているuri = new Uri( "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=XMc7Wo2RE9KnvwSD2LeQDQ&gws_rd=ssl"); 'private非同期void webview_NavigationCompleted(WebView送信者、WebViewNavigationCompletedEventArgs引数) {try {string functionString =" document.getElementById( 'lst-ib')。value = 'abc'; " await webview.InvokeScriptAsync( "eval"、新しい文字列[] {functionString}); } catch(例外ex) {LogTextbox.Text = ex.Message; }} ' – Farhan

関連する問題