PDA

Click to See Complete Forum and Search --> : Forcing keystrokes for password entry


jpeg0499
Feb 28th, 2001, 08:01 AM
Hello Everyone!

I have a PDF file being opened in a OCX control in one of my forms, and it requires a password before it can be opened. However, I do not want the user to enter the password. Right now, I have my program set up to watch for the "Password" window, and then it sets the focus on it, and generates the password entry with simulated keystrokes. However, I would like to know if this is the best method. Part of the problem is that someone can run a key logger and get the password, and another problem is if a key is being held down while my program enters the password. Any ideas around any of these "problems" would be greatly appreciated. Thanks in advance!

Jeremy Lounds

Feb 28th, 2001, 11:32 AM
Try sending the WM_SETTEXT message rather than sending the actual keystrokes.

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_SETTEXT = &HC

Private Sub Command1_Click()

SendMessage hwnd_of_window, WM_SETTEXT, 0, ByVal "MyPassword"

End Sub

jpeg0499
Feb 28th, 2001, 04:29 PM
Hmmm... I must be doing something wrong, because when I tried that, it changed the actual caption of the window, and not the text entry field.

Not something I want, that's for sure! :-)

Jeremy

Feb 28th, 2001, 05:13 PM
Change hwnd_of_window to the handle of the password entry box.