![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
|
Subclassing \ hooking the OS
Hi
I am trying to determine how to do the following things in VB6: 1) Determine when the keyboard focus has changed (ie. the user has moved the blinking text cursor to another text box or edit class in any application) 2) After having recieved notification of the above, I would like to be able to determine if the textbox that has the focus has character masking enabled on it. In VB6 you would determine this in your application by seeing if PasswordChar contains anything. Of course, the method in which I could check this is going to be different - as I am wanting to monitor ANY application! Any help much appreciated! Matthew
__________________
Kind regards, Matthew Hall ______________________________________ My personal site iD Hosting Services UK - Plans from £2.50! |
|
|
|
|
|
#2 |
|
Programming Guru
![]() ![]() |
Hey,
to find out if a text box has focus you can do sotmhign like this: Private Sub Text1_GotFocus()
'Do what you want.
End Sub1) clicks the text box. 2) Tabs to the text box. As for your second question, for checking for any app, you'd probably have to do it through the Windows API. See the msdn for more info on that.
__________________
Profanity is the one language that all programmers understand. Check out my Blog <---updated Nov 30 2007! |
|
|
|
|
|
#3 |
|
Expert Programmer
|
Well whatever the purpose, be it systematically grabbing the contents of every textbox that could possibly be a password (!), your best bet would be to look out for the WM_FOCUS window message, the lParam of which is the windows handle. You could then do a GetWindowLong(hwnd) Or WS_CHARMASKED or whatever to see if it employs the text masked style (for exact details of the password box class, use Spy++) and grab its contents using GetWindowText(), or the longer SendMessage(WM_GETTEXT ... ) for the "more secure" XP password boxes.
To actually hook the Windows global message stream, you can insert a callback via the CallWindowsHookEx function, though this starts to get into some complex multithreading, as windows sets a timeout on the delegate of 100ms or so. I would post my hilarious program-that-replaces-what-you-type-with-rude-words project that demonstrates windows hooks, but I'm stuck halfway through a Gentoo install with a buggy BIOS. ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|