Facebook评论文本框,按Enter键 [英] Facebook Comment Textbox, Pressing Enter Key

查看:111
本文介绍了Facebook评论文本框,按Enter键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作带浏览器的桌面应用程序,其中发布评论



需要按Enter键才能发表评论



现在我正在使用以下代码



i am making a desktop app with browser, which posts comment

the Enter button is required to be pressed to post the comment

right now i am using folowing code

txt = "how r u";
            string initial = "";
            HtmlDocument Document = (HtmlDocument)e.Argument;
            foreach (HtmlElement hform in Document.GetElementsByTagName("form"))
            {
                if (hform.GetAttribute("action") == "/ajax/ufi/modify.php")
                {
                    foreach (HtmlElement hbtnComment in hform.GetElementsByTagName("input"))
                    {
                        if (hbtnComment.GetAttribute("value") == "Comment")
                        {
                            hbtnComment.InvokeMember("click");
                            System.Threading.Thread.Sleep(1000);
                            Application.DoEvents();
                            break;
                        }
                    }

                    HtmlElement htxtArea = hform.GetElementsByTagName("textarea")[0];
                    initial = htxtArea.InnerText;
                    htxtArea.Focus();
                    System.Threading.Thread.Sleep(200);
                    Application.DoEvents();
                    htxtArea.InnerHtml = txt;// +"<input id=\"abc\" type=\"submit\">";
                    System.Threading.Thread.Sleep(200);
                    Application.DoEvents();
                    SendKeys.SendWait("{ENTER}");
                    System.Threading.Thread.Sleep(200);
                    Application.DoEvents();
}
}





此代码存在的问题是,它使用的是SendKeys函数,需要应用程序保持焦点,如果应用程序被最小化,那么这个代码不起作用



所以任何人都可以帮助我告诉我们如何让文本区域感觉到Enter按键已被按下



the problem with this code is, that it using SendKeys function, which requires the application to remain in focus, if the application is minimized then this code doesnt work

so kindly anyone who can help me in telling how we can make the text area feel that Enter key has been pressed

推荐答案

查看本教程 http://www.vivid-abstractions.net/programming/tutorials/video-tutorial-send-keys-to-an-inactive- window-windows-messages / [ ^ ]

如果没有给你足够的细节,那么google for sendkeys inactive application 并看看其他建议。



此处 [ ^ ]是Windows的列表消息代码和此处 [ ^ ]是官方的模糊,
Have a look at this tutorial http://www.vivid-abstractions.net/programming/tutorials/video-tutorial-send-keys-to-an-inactive-window-windows-messages/[^]
If that doesn''t give you enough detail then google for sendkeys inactive application and have a look at the other suggestions.

Here[^] is a list of the Windows Message codes and here[^] is the official blurb,


这篇关于Facebook评论文本框,按Enter键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆