Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with sendkeys and openprocess

Status
Not open for further replies.

jaloes

MIS
Mar 22, 2004
6
ES
I'm trying to start a database application with a call to shell. When a dialog box is opened for a password, I try to suply it through Sendkeys.
The following code opens correcly the database, BUT the computer blocks until the Start key is pressed (a way to do it, only).

routeAcc = SysCmd(acSysCmdAccessDir) & "msaccess.exe "
Cmd = Chr(34) & rutaAcc & Chr(34) & " /NoStartup /User Admin /Pwd " & Chr(34) & "" & Chr(34) & " /wrkgrp " & Chr(34) & DBEngine.SystemDB & Chr(34) & Chr(34) & Routedb & Chr(34)
dwProcessID = Shell(Cmd, WindowStyle)
If dwProcessID = 0 Then
Error ERROR_IN_PROCESS
End If
SendKeys myPwd & "{ENTER}", True
hProcess = OpenProcess(SYNCHRONIZE, False, dwProcessID)
If hProcess = 0 Then
Exit Function
Else
CloseHandle hProcess
End If


Please, can you tell me how solve it.

Thanks in advance.


 
Are you sure that the application is active and has the focus when you fire the SendKeys? There may be a way to wait (perhaps search for shell and wait in this forum). Alternatively, you could try putting a delay into your code before the SendKeys.
 
I'm sure that is the problem, but I don't know how to solve it, I'm trying in many ways but it doesn't work and my system is locked until start key is pressed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top