[RESOLVED] Webbrowser & Key strokes
I have been attempting to automate a process in a webbrowser control. When I attempt to fill out the form and submit, I get a false negative response (meaning all the data in the fields are correct but I am getting an incorrect response back from what I should be getting). I have determined that this problem is due to the fact that when I manually type out the data in the input fields a javascript is being fired. I know that you are able to invoke the javascript, but as I have no real knowledge about javascript and the script is rather complex I am stuck.
A temporary solution for me has been to use SendKeys, but this is no real solution at all. If the window loses focus, the entire process goes out the window. I cannot just use the .SetAttribute or .InnerText methods for the elements in the window.
I'm not sure if any of you are familiar with WatiN but I have used it recently while looking for other means to do what I need to do here. Watin works, but instead of allowing me to use an embedded browser object it shells new browser windows. Anyhow, with WatiN I am able to minimize or hide the browser window and the code will still execute. This leads me to believe that there is a way to simulate keypress events in a browser window while making sure that the specific element is the active element.
I have searched all over the internet for this (but am sure I overlooked a few things in frustration) and have yet to find a solution that works for me. If anyone has any information it would be greatly appreciated. Thanks in advance.
Re: Webbrowser & Key strokes
Re: Webbrowser & Key strokes
nevermind... i found a fanastic solution. if anyone is looking for something similar message me.
Re: [RESOLVED] Webbrowser & Key strokes
hi i JUST joined this site i was having problems like that a while back but i found a pretty easy way to fill out a forum
for anyone who still needs it heres how
Say your web browser is open on the page u want already
and u know how to get that far at least lol
first lets do something like Username Password and submit :D
on most non popular sites and stuff that dont have a bot blocker thing its as simple as just typing in username and password for other sites
lets say Travian
(its a browser based game)
http://speed.travian.us/login.php
we need to FIND the username and password boxes value's so we can type something in there :O heres how
so we look into our page source first
Since our username box says name lets try looking for that
Ctr F in the page source and look for name
We keep pressing next untill we see something
that says the value of name is Class Text and type is text so like this
<th>Name:</th>
<td><input class="text" type="text" name="e1e9c3c"
and where it says name thats the name of the textbox we need :D
now explain the code
WebBrowser1.Document.All("name of the box").SetAttribute("value", text u want changed to)
u do the same thing for the password so u would have 2 lines with whatever the value of name and password are
now last thing u want is to click the Login button :D
thats realy easy to
login button says Login on it simple enough
so Ctr F in the source find login type is an image in this case
so it will look like this
<input type="image" value="login" name="s1"
so our name for it is s1 simple enough
so we put this code
WebBrowser1.Document.All("s1").InvokeMember("click")
this will Click s1
and thats it thats all u have to know to fill in forums those 2 lines of code :3
sure you can make it automaticly do that or a button or whatever or only do it when
ur on a sertain page but for now thats all if u need help and u prolly will cause i suck at explaining TONS pm me :D i will gladly help
Re: [RESOLVED] Webbrowser & Key strokes
i appreciate it but i already got it figured out. the solution was actually pretty simple. there were just a few methods that i was unaware of that helped play a big part in the code for this particular automation. thanks again though.
Re: [RESOLVED] Webbrowser & Key strokes
oh no i posted that for anyone else who is having problems i read u already got it ^^