Reputation: 2036
I am working on a program that will make me to be able to post message in a chatbox on a website without doing the posting manually. I have this code to put the text into the textbox
:
message = txtMessage.Text;
foreach(Node txt in wb.Document.GetElementsByTagName("textarea"))
{
if(((Element)txt).GetAttribute("Class") == "chat_input")
{
((Element)txt).Focus();
((Element)txt).TextContent = message;
}
}
Website code is:
<textarea class="chat_input">
Enter text for chat here
</textarea>
All it has a textbox, and not a post button. It posts the message when you press enter. What I need now, is some code for invoking an enter keypress.
Does anyone know how to do that? And is it even possible?
Upvotes: 0
Views: 215
Reputation: 2917
Try this
SendKeys.Send("{ENTER}");
More info at: http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx
All the best!
Upvotes: 1