Answer the question
In order to leave comments, you need to log in
How to find windows by title or executable file?
You need to programmatically press the Enter button on certain running windows.
those. you need to find a window by title or by executable file, emulate pressing the Enter button, and so on with each window. How to do it? =)
Answer the question
In order to leave comments, you need to log in
There is no built-in sharp, but there is a Win32 api
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
1 - find window, get handle (duplicate of colleague's answer, though)
[DllImport("USER32.DLL", CharSet = CharSet.Auto)]
internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
"Save Table".hWndByTitle().setTitle(csvDlg).waitForIdle().sendString(
new string[] {
"DUIViewWndClassName",
"DirectUIHWND",
"FloatNotifySink",
"ComboBox",
"Edit" },
csv);
internal static IntPtr sendString(this IntPtr hWnd, string[] classNames, string msg, bool verb = false)
{
var hCtrl = hWnd;
if (classNames != null && classNames.Count() > 0)
{
Thread.Sleep(to[toFileStdDlg]);
foreach (var c in classNames)
{
Thread.Sleep(to[toFileStdDlg]);
hCtrl = user32.FindWindowEx(hCtrl, IntPtr.Zero, c, null);
if (hCtrl.Equals(IntPtr.Zero))
{
$"\tERROR :: sendString not found class {c}".log();
return hWnd;
}
else
hCtrl.waitForIdle();
}
}
for (int i = 0; i < msg.Length; i++)
user32.PostMessage(hCtrl, WM_CHAR, msg[i], 0);
Thread.Sleep(to[toFileStdDlg]);
user32.PostMessage(hWnd, WM_KEYDOWN, user32.VkKeyScan('\r'), 0);
user32.PostMessage(hWnd, WM_KEYUP, user32.VkKeyScan('\r'), 0);
return hWnd;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question