Anyone have any good keystroke saving code?

J. Scott Elblein

Well-known member
Joined
Dec 14, 2006
Messages
166
Location
Chicago
Programming Experience
10+
In the app I am writing for work, I have a webrowser control, that has a login form.

What I 'd like to do is have the program store the login & password automatically for them after they type it in and click the Submit button, which I then add to a drop-down combobox, so they can easily just select them next time (they often have to have multiple logins), and login automatically for them just by switching the logins in the combobox.

I have written some basic code which works well enough with a little post-handling to clean it up, but it's also a bit squirrly. I put it in the WBR_PreviewKeyDown event, the problem is, that event gets called multiple times per key, and sometimes seems to just keep randomly getting called, especially when someone uses Shift+Some-Letter. I was wondering if anyone has some better code, or maybe just an idea no how to tweak this code so it's more stable/solid? (Just for testing you can use any website that requires a login and pass, yahoo email for example):

VB.NET:
In KeyPreviewDown event:

        ' Static var so we can try to only catch a keypress one time instead of multiples.
        Static Dim boolOneTime As Boolean

        If boolOneTime = True Then
            strITLP += e.KeyCode.ToString
            boolOneTime = False
        Else
            boolOneTime = True
        End If

--

(Then I have this at the top of the form so I can use it in other Subs: Dim strITLP As String)

--

And in the DocumentCompleted event, after the next page loads after logging in, I have this:

        MessageBox.Show(strITLP)
        strITLP = String.Empty
Right now during testing, I just use a messagebox to show me, but later would use that as the place to do what I want as far as adding to the combobox. I actually considered looking for some keylogger code and adjusting it to my needs for this app, but that seems a bit overboard and shady, and don't really want to mess with that stuff, lol.
Thanks again for all help guys. :)
 
Hey AB...

I myself wrote a small app which requires logging in. Albeit its contained in the App itself and not a webbrowser control. The app uses a login form and queries a MySQL DB for UserID's and populates the UserID combo.
This may be beyond the requirements of your app, but if you can facilitate a MySQL DB, I'll be happy to post the code I've implemented.


Regards
NssB
 
Hi NssB,

Thanks for helping. I'm thinking that may not actually help me much in what I am trying to accomplish however, but I do appreciate it. :)

Anyone have any idears?
 
Back
Top