Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 979
  • Last Modified:

VB.NET SendKeys ... File Open window

I have a VB.NET application that I am writing.  I need to capture a file by the user and feed that filename into the "file open" of another application.  I am simulating it in this example with notepad.  

The code works until it comes to populating the "open" window in notepad.  

I have tried SendKeys.Send and SendKeys.SendWait

NOTE:  The application (i.e. NOTEPAD) will already be open.

- - - - sample code excerpt - - - -
            openFD.ShowDialog()
            AppActivate("untitled - notepad")
            SendKeys.SendWait("%FO")
           
            ' All is well until this next line.  This line does not work
            SendKeys.SendWait("{quote}" & openFD.FileName & "{quote}{enter}")
0
javajws
Asked:
javajws
  • 3
1 Solution
 
darbid73Commented:
Whenever I see send keys I always think - is this really the only way to do it.  It is arguable that sendkeys is not realiable.

If I understand you correctly the user is going to use the windows dialog to open a file.  You would like to intercept or listen to this process and get the file that is being opened and use that information somewhere else?
0
 
javajwsAuthor Commented:
My program will ask the user for the filename with the Windows dialog to open a file.  That filename (and path) will not be opened, it will be used to copy the file from the network folder to a local folder and open the local file in another program (for now, Notepad).  

I have the first part working.  It asks for a file, copies the file from the network path to the local path.  I am then able to locate the application (in this case Notepad) using "AppActive".  

Now I want to simulate "File...Open" and feed the path/filename, to open the user requested file.
0
 
darbid73Commented:
Ok so you have the full path name to the file which is now saved locally.

Your example (which I know is an example) is with notpad.

I would use something like this
System.Diagnostics.Process.Start("notepad.exe", "mydocument.txt")

Open in new window


Why do you need to imitate how a user opens it?

What is the program you really want to open the file in?
0
 
darbid73Commented:
The questioner wants to open a file with, in this example notepad.

His example has been answered and one could assume satisfactorily, as he has not questioned it or asked for more assistance for more than a month.
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now