I am trying to control an instance of a Notepad program which has some data in it - I want to save the data into a file.
I am trying this code:
Dim AllProcess() As Process = GetProcessesByName("notepad")
Dim MyProcess As Process = AllProcess(0) ' use the first one found
MyProcess.WaitForInputIdle(1000)
If MyProcess.Responding Then
System.Windows.Forms.SendKeys.SendWait("^s) ' Ctrl-S; File/Save
System.Windows.Forms.SendKeys.SendWait("C:\Test\T1.csv") ' enter filename
System.Windows.Forms.SendKeys.SendWait(vbCr) ' hit the Save button
End If
But it seems these commands are not getting to the Notepad form unless the focus is on that form when the SendKeys is being executed.
1. How can I set the focus to the Notepad?
2. Is there a better way to control the Notepad
I am trying this code:
Dim AllProcess() As Process = GetProcessesByName("notepad")
Dim MyProcess As Process = AllProcess(0) ' use the first one found
MyProcess.WaitForInputIdle(1000)
If MyProcess.Responding Then
System.Windows.Forms.SendKeys.SendWait("^s) ' Ctrl-S; File/Save
System.Windows.Forms.SendKeys.SendWait("C:\Test\T1.csv") ' enter filename
System.Windows.Forms.SendKeys.SendWait(vbCr) ' hit the Save button
End If
But it seems these commands are not getting to the Notepad form unless the focus is on that form when the SendKeys is being executed.
1. How can I set the focus to the Notepad?
2. Is there a better way to control the Notepad