I have written a vb.net
application to start an external application (notepad.exe) and then open the txt file located in at "D:\test.txt".
I have used keyboard events to achive this.
Step1: Open the notepad
Process.Start("notepad.exe")
Step 2: Raised the keyboard event Ctrl + O to open the Open dialog box
keybd_event(VK_CONTROL, &H45, 0, 0)
keybd_event(VK_O, 0, 0, 0)
keybd_event(VK_CONTROL, &H45, KEYEVENTF_KEYUP, 0)
Step 3: Wait for 2 seconds.
Thread.Sleep(2000)
Step 4: Raised the keyboard event to type the File path "D:\Test.txt" in the File Name textbox.
Issue: Occassionally the Open dialog box operation takes more time (exceeds 2000 ms) to open, as a result the file path typing event started before opening the open dialog box. I have increased the sleep time, but the issue not fixed completely.
Is there any way to check whether the Open dialog box is opened using the notepad process id?
I have tried using EnumChildWindows, but i didn't get the result.