I have a program which uses WebDriver for going through web pages and doing some things. I faced with problem: when I need to choose file in file selection window. I know that there is an AutoIt which can do it. But there are two points:
- AutoIt need to be installed on the computer where you run a program
- Installation file doing smth wrong and you need to go to regedit and add some info in order to "complete the installation correctly" :)
And if the first point is fine (because the installer of AutoIt is common and understandable), the second point causes difficulties because users of my program won't open regedit and dig into it (even if steps to fix above-mentioned problem are simple).
So, I want to do the same, but without using another program. I only know that I can use
[DllImport("user32.dll")]
//here's should be name of the function to import
but how? Can anyone please help me to figure out how to do this task:
- to take control of the file selection window
- insert there file location
- press "Ok" button or just press enter
That's all I need.
Here's the example of code in which I used AutoIt:
using AutoItX3Lib;
AutoItX3 autoIt = new AutoItX3();
autoIt.WinActivate("File Upload");
Thread.Sleep(1000);
autoIt.Send(@"file's location");
Thread.Sleep(1000);
autoIt.Send("{ENTER}");