public override void Selection(IShipmentAutomationControl control, string text) { if (Selection(control) == text) { return; } if (control.IsCharInputRequired) { Win32ApiHelper.SendMessage(control.NativeHwnd, 335, 1, null); Win32ApiHelper.SendMessage(control.NativeHwnd, Win32ApiHelper.CB_SELECTSTRING, Win32ApiHelper.SEARCH_ALL, text); Win32ApiHelper.SendChars(control.NativeHwnd, text, 10); Win32ApiHelper.SendMessage(control.NativeHwnd, 335, 0, null); return; } var contents = GetListBoxContents(control.NativeHwnd); var item = contents.FirstOrDefault(c => string.Equals(c, text, StringComparison.CurrentCultureIgnoreCase)); var index = contents.IndexOf(item); if (item != null && index > -1) { Win32ApiHelper.SendMessage(control.NativeHwnd, Win32ApiHelper.CB_SETCURSEL, index, null); } else { Text(control, text); } }
public override void Text(IShipmentAutomationControl control, string text) { if (control.IsTypedInputRequired) { TypeTextWithFocus(control, text); Keyboard.Type(Key.Enter); return; } if (control.IsCharInputRequired) { control.AutomationElement.SetFocus(); Thread.Sleep(1000); Keyboard.Type(Key.Back); Win32ApiHelper.SendChars(control.NativeHwnd, text, 70); Keyboard.Type(Key.Enter); return; } Win32ApiHelper.SendMessage(control.NativeHwnd, Win32ApiHelper.WM_SETTEXT, 0, text); if (control.IsFocusedInputRequired) { control.AutomationElement.SetFocus(); Keyboard.Type(Key.Enter); } }