How to Open a Process and Send Keys to that Process ( e.g. MS Word )

Following works fine opens document, ctrl + g = go to in word, book mark “StockControl”

Dim process1 As New Process
process1.StartInfo.FileName = String.Concat(My.Settings.DocumentationDirectory, My.Settings.HelpWordFile)
process1.Start()
process1.WaitForInputIdle()
'Dim hwnd = process.MainWindowHandle
Threading.Thread.Sleep(1000)
SendKeys.Send("^g")
SendKeys.Send("+{TAB}")
SendKeys.Send("b")
SendKeys.Send("{TAB}")
SendKeys.Send("StockControl")
SendKeys.Send("{ENTER}")
SendKeys.Send("{ESC}")

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: