#
#
#2018-06-03 10:30:33
Automation
#, 2018-06-03 10:30:33

Who knows examples of external automation of standard Windows File Open/File Save dialogs from C#?

subj actually, I ask you to throw examples, if anyone knows.
In general terms, the situation is that a certain program is being automated without source codes (not very fresh anymore), clicks on the "controls" have been worked out, and everything seems to be stable. Each time, by HWnd, we secure the presence of the window in the top of the display, and in the input focus. But with the input of file names for opening / saving (there are no APIs in the target program), something is not simple. On the developer's computer, everything works smartly and stably. And the consumer fails (((
used options

"Save Table".hWndByTitle().setActive().waitForIdle();
Clipboard.SetText(file_path_name);
SendKeys.SendWait("^V{Enter}");
Thread.Sleep(timeOuts[toSendKeys]);

works more stable (but still not stable enough)
"Save Table".hWndByTitle().setActive().waitForIdle();
SendKeys.SendWait(file_path_name);
SendKeys.SendWait("{Enter}");
Thread.Sleep(timeOuts[toSendKeys]);

works fast for everyone, but much more lethargic - at an unpredictable moment, the opening / saving fails, after which the bot logic collapses
Note:
.hWndByTitle().setActive().waitForIdle(); these are extensions based on system functions imported from user32.
Actually, a request - if someone solved a similar problem (or saw a solution) in C # (it is possible with the import of system functions, this does not scare) which uses direct input of text strings of paths + file names into the controls of standard dialogs (and if "OK" by invok and not by click) share plz!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
res2001, 2018-06-03
@mindtester

I once used AutoIt scripts for similar purposes.
Purely theoretically:
You send messages to an active window. Perhaps between SetActive and SendWait the window ceases to be active. In this case, the messages will go to the wrong window.
Try getting the window handle and send messages to the window with the given handle.
"Unpredictable failures" need to be dealt with. What is the cause of the failure, how does it manifest itself ... ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question