示例#1
0
        /// <summary>
        ///     Get text from the window
        /// </summary>
        /// <param name="interopWindow">InteropWindow</param>
        /// <param name="forceUpdate">set to true to make sure the value is updated</param>
        /// <returns>string with the text</returns>
        public static string GetText(this IInteropWindow interopWindow, bool forceUpdate = false)
        {
            if (interopWindow.Text != null && !forceUpdate)
            {
                return(interopWindow.Text);
            }
            var text = User32Api.GetTextFromWindow(interopWindow.Handle);

            interopWindow.Text = text;
            return(text);
        }
示例#2
0
        private void Test_GetTextFromWindow()
        {
            const string title  = "1234567890";
            var          window = new Window
            {
                Title = title
            };

            window.Show();
            var handle = window.GetHandle();
            var text   = User32Api.GetTextFromWindow(handle);

            window.Close();
            Assert.Equal(title, text);
        }