public void FindWindows_FilterByProcessID() { var windowHandle1 = new IntPtr(100); var windowHandle2 = new IntPtr(200); var windowHandle3 = new IntPtr(300); var windowHandle4 = new IntPtr(400); NativeMethodsStub.Stub(stub => stub.EnumWindows(Arg <EnumWindowsProc> .Is.NotNull, Arg <WindowFinderEnumWindowsProcContext> .Is.NotNull)) .WhenCalled( mi => { Assert.That(InvokeEnumWindowsProc(mi, windowHandle1), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle2), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle3), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle4), Is.True); }) .Return(true); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle1, 101, "Class1", "Window1"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle2, CurrentProcessID, "Class2", "Window2"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle3, 101, "Class3", "Window3"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle4, 401, "Class4", "Window4"); var windows = WindowFinder.FindWindows(new WindowFilterCriteria { ProcessID = 101 }); Assert.That(windows.Length, Is.EqualTo(2)); AssertWindowInformation(windows[0], windowHandle1, 101, "Class1", "Window1"); AssertWindowInformation(windows[1], windowHandle3, 101, "Class3", "Window3"); }
/* User clicks "clone character" button */ private void CloneCharacterButton_Click(object sender, RoutedEventArgs e) { if (CharacterID.Text.Length == 0 || !CharacterID.Text.ToLower().Equals(CharacterID.Text) || !CharacterID.Text.Replace(" ", "").Equals(CharacterID.Text)) { MessageBox.Show("Your character ID must contain no spaces, no capitals or match an existing character ID"); return; } if (CharacterName.Text.Length > 50) { MessageBox.Show("Your character name should be less than 50 characters in length"); return; } /* Logic to clone the character */ Character clonedCharacter = CharacterBeingCloned; clonedCharacter.description = clonedCharacter.description.Replace(clonedCharacter.name, CharacterName.Text); clonedCharacter.classinfo.name = ActiveProject.Project.prefix + CharacterID.Text; ActiveProject.Project.characters.Add(clonedCharacter); MainWindow mainWindow = WindowFinder.FindOpenWindowByType <MainWindow>(); mainWindow.ProjectDataTree.Items.Refresh(); mainWindow.ProjectDataTree.UpdateLayout(); this.Close(); }
public void FindWindows_SkipsWindowsWhereGetClassNameReturnsZero() { var windowHandle1 = new IntPtr(100); var windowHandle2 = new IntPtr(200); var windowHandle3 = new IntPtr(300); NativeMethodsStub.Stub(stub => stub.EnumWindows(Arg <EnumWindowsProc> .Is.NotNull, Arg <WindowFinderEnumWindowsProcContext> .Is.NotNull)) .WhenCalled( mi => { Assert.That(InvokeEnumWindowsProc(mi, windowHandle1), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle2), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle3), Is.True); }) .Return(true); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle1, 101, "Class1", "Window1"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle2, 201, "", "Window2"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle3, 301, "Class3", "Window3"); var windows = WindowFinder.FindWindows(new WindowFilterCriteria()); Assert.That(windows.Length, Is.EqualTo(2)); AssertWindowInformation(windows[0], windowHandle1, 101, "Class1", "Window1"); AssertWindowInformation(windows[1], windowHandle3, 301, "Class3", "Window3"); }
public void Launch_CalledWith100and100_PositionatesTheWuindow() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); mainWindow.CloseButton.Unsafe.Click(); }
public void FindWindows_IncludesChildWindowsWhereGetWindowTextReturnsZero() { var windowHandle1 = new IntPtr(100); var subWindowHandle11 = new IntPtr(1001); var subWindowHandle12 = new IntPtr(1002); NativeMethodsStub.Stub(stub => stub.EnumWindows(Arg <EnumWindowsProc> .Is.NotNull, Arg <WindowFinderEnumWindowsProcContext> .Is.NotNull)) .WhenCalled(mi => Assert.That(InvokeEnumWindowsProc(mi, windowHandle1), Is.True)) .Return(true); NativeMethodsStub.Stub( stub => stub.EnumChildWindows( Arg.Is(windowHandle1), Arg <EnumChildWindowsProc> .Is.NotNull, Arg <WindowFinderEnumChildWindowsProcContext> .Is.NotNull)) .WhenCalled( mi => { Assert.That(InvokeEnumChildWindowsProc(mi, subWindowHandle11), Is.True); Assert.That(InvokeEnumChildWindowsProc(mi, subWindowHandle12), Is.True); }); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle1, 101, "Class1", "Window1"); StubNativeMethodsForWindowInformation(NativeMethodsStub, subWindowHandle11, 101, "Class1.1", ""); StubNativeMethodsForWindowInformation(NativeMethodsStub, subWindowHandle12, 101, "Class1.2", "Window1.2"); var windows = WindowFinder.FindWindows(new WindowFilterCriteria { IncludeChildWindows = true }); Assert.That(windows.Length, Is.EqualTo(3)); AssertWindowInformation(windows[0], windowHandle1, 101, "Class1", "Window1"); AssertChildWindowInformation(windows[1], subWindowHandle11, 101, "Class1.1", "", windowHandle1); AssertChildWindowInformation(windows[2], subWindowHandle12, 101, "Class1.2", "Window1.2", windowHandle1); }
public void Search_ByTitle_ReturnsTheWindow() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var window = WindowFinder.Search <BasicWindow>(Use.Title("mainwindow")); window.CloseButton.Unsafe.Click(); }
public async Task MouseClickRepeatClickTests() { /* Arrange */ var handle = WindowFinder.FindWindow(null, "Genymotion for personal use - Google Galaxy Nexus - 4.2.2 - API 17 - 720x1280 v2.6 (720x1280, 320dpi) - 192.168.56.101"); /* Atc */ await MouseSimulator.ClickAsync(handle, MouseButton.Left, 50, 500, 1, 10); }
private List <WindowHandle> GetWindowsOnScreen(Screen screen) { WindowFinder finder = new WindowFinder(); var windows = finder.Windows.Where(x => x.GetScreen().Equals(screen)).ToList(); return(windows); }
public void Search_ByAutomationId_ReturnsTheWindow() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var window = WindowFinder.Search <BasicWindow>(Use.AutomationId("CUI_TestApplication_MainWindow")); window.CloseButton.Unsafe.Click(); }
public void FindWindows_HandlesEnumWindowsReturnedFalse() { NativeMethodsStub.Stub(stub => stub.EnumWindows(null, null)) .IgnoreArguments() .WhenCalled(mi => NativeMethodsStub.Stub(stub => stub.GetLastWin32Error()).Return(-1).Repeat.Once()) .Return(false); WindowFinder.FindWindows(new WindowFilterCriteria()); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_WindowFocusTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
private uint GetProcId(string windowName, out int handle) { uint procId; WindowFinder windowFinder = new WindowFinder(); IntPtr hwnd = windowFinder.FindWindowAsynch(windowName, 10000, out procId); handle = hwnd.ToInt32(); return(procId); }
public void State_CalledWithMaximized_MaximizesTheWindow() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); WindowSetup.Prepare(mainWindow).State(WindowState.Maximized); Assert.AreEqual(WindowState.Maximized, mainWindow.WindowState); mainWindow.CloseButton.Unsafe.Click(); }
public static void TreeAddSources() { MainWindow mainWindow = WindowFinder.FindOpenWindowByType <MainWindow>(); mainWindow.ProjectCharacters.ItemsSource = ActiveProject.Project.characters; /* Show the Tree Views */ mainWindow.ProjectDataTree.Visibility = Visibility.Visible; mainWindow.ImportedDataTree.Visibility = Visibility.Visible; }
/// <summary> /// Gets the name of the by. /// </summary> /// <param name="name">The name.</param> /// <returns></returns> public static FileDialog GetByName(string name) { IntPtr handle = new WindowFinder().FindFirstDialog(name).Handle; if (handle == IntPtr.Zero) { return(null); } return(new FileDialog(handle)); }
public static void Maximize() { #if UNITY_EDITOR || !UNITY_STANDALONE_WIN return; #endif Task.Run(() => { var wf = new WindowFinder(); wf.FindWindows(0, null, new Regex(APP_NAME), new Regex(APP_NAME), new WindowFinder.FoundWindowCallback(MaximizeWindow)); }); }
public void Size_CalledWith100and100_PositionatesTheWuindow() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); WindowSetup.Prepare(mainWindow).Size(500, 400); Assert.AreEqual(500, mainWindow.Properties.BoundingRectangle.Width); Assert.AreEqual(400, mainWindow.Properties.BoundingRectangle.Height); mainWindow.CloseButton.Unsafe.Click(); }
public static void Setup(TestContext context) { Do.Launch(TestData.ApplicationPath).And.Wait(1000); _mainWindow = WindowFinder.Search(Use.AutomationId(TestData.MainWindowAutomationId)); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
// [RuntimeInitializeOnLoadMethod] // No need to run it on this project // private static void MaximizeWindowOnStart() // { // if (Application.isEditor) { return; } // WindowFinder wf = new WindowFinder(); // // Maxime all windows that contains "APP_NAME" in their title. // wf.FindWindows(0, null, new Regex("The Colour of Music"), new Regex("The Colour of Music"), new WindowFinder.FoundWindowCallback(MaximizeWindow)); // } public static void MaximizeWindow() { if (Application.isEditor) { return; } WindowFinder wf = new WindowFinder(); // Maxime all windows that contains "APP_NAME" in their title. wf.FindWindows(0, null, new Regex("The Colour of Music"), new Regex("The Colour of Music"), new WindowFinder.FoundWindowCallback(MaximizeWindow)); }
public void InvokePattern_ReadFromButton_CanInvoked() { var button = UI.GetChild(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(_mainWindow)); var pattern = Patterns.GetInvokePattern(button.AutomationElement); pattern.Invoke(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); }
private static IntPtr GetTextWindowHandle() { var finder = new WindowFinder("AutoCAD LT テキスト ウィンドウ - ", "AutoCAD LT Text Window - "); //EnumChildWindowsは指定したウィンドウ配下のコントロール全てを、順にコールバック関数に渡す var result = WindowController2.EnumChildWindows(new IntPtr(0), finder.FindChildWindow, 0); if (result == 1) { throw new ApplicationException("AutoCADのTextWindowが見つかりませんでした。"); } return(finder.FoundWindowHandle); }
public void Search_ForAMessageBox_FindsAndClosesIt() { Do.Launch(TestData.ApplicationPath).And.Wait(1000); var window = WindowFinder.Search <BasicWindow>(Use.AutomationId("CUI_TestApplication_MainWindow")); var button = UI.GetChild <BasicButton>(By.AutomationId("CUI_ShowMessageBox_Button"), From.Element(window)); button.Unsafe.Click(); DynamicSleep.Wait(1000); var messageBox = WindowFinder.Search <BasicMessageBox>(Use.Title("MessageBoxTitle")); messageBox.OKButton.Unsafe.Click(); window.CloseButton.Unsafe.Click(); }
public void TypeKey_AltF4OnTheWindow_ClosesTheWindow() { KeyboardEx.TypeKey(_testWindow, Key.F4, ModifierKeys.Alt).And.Wait(2000); var testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert().And.Timeout(2000)); Assert.IsNull(testWindow); var currentButton = UI.GetChild <BasicButton>(By.AutomationId("CUI_KeyboardExTests_Button"), From.Element(_mainWindow)); currentButton.Unsafe.Click(); DynamicSleep.Wait(1000); _testWindow = WindowFinder.Search(Use.AutomationId("CUI_KeyboardExTestsWindow"), And.NoAssert()); _textBox = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(_testWindow)); }
/// <summary>AutoCADのコマンドウィンドウのハンドルを取得する</summary> public static IntPtr GetCommandWindowHandle() { var textWindowHandle = WindowController2.GetTextWindowHandle(); var finder = new WindowFinder("Marin"); //EnumChildWindowsは指定したウィンドウ配下のコントロール全てを、順にコールバック関数に渡す var result = WindowController2.EnumChildWindows(textWindowHandle, finder.FindChildWindow, 0); if (result == 1) { throw new ApplicationException("AutoCADのCommandWindowが見つかりませんでした。"); } return(finder.FoundWindowHandle); }
public override void OnLoad() { thisProcess = Process.GetCurrentProcess(); thisWindowHandle = thisProcess.MainWindowHandle; timer = new Timer(500); timer.Elapsed += TimerElapsed; timer.Start(); CheckCanSave(); if (textBoxApplication.Text != null || textBoxWindowTitle.Text != null) { WindowFinder.Find(ActionInfo, hwnd => { CurrentlySelectedWindow = hwnd; }); } }
public override void Perform() { int num = WindowFinder.Find(ActionInfo, hwnd => { foreach (IWindowAction action in ActionInfo.WindowActions) { action.Perform(hwnd); Thread.Sleep(50); } } ); // If we can't find the window, then num appears to be non-zero. if (num != 0) { ErrorLog.AddError(ErrorType.Failure, string.Format("The Window '{0}' is not avaliable", ActionInfo.WindowInfo.Title)); } }
public void BringOnTop_TypesTextToDifferentWindows_TheWindowsGetsTheTextAccordingly() { var window1 = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow_1")); var window2 = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow_2")); var textBox1 = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(window1)); var textBox2 = UI.GetChild <BasicEdit>(By.AutomationId("CUI_InputTextBox"), From.Element(window2)); WindowFocus.BringOnTop(window1); MouseEx.Click(window1); KeyboardEx.TypeText("First Window Text").And.Wait(1000); WindowFocus.BringOnTop(window2); MouseEx.Click(window2); KeyboardEx.TypeText("Second Window Text").And.Wait(1000); Assert.AreEqual("First Window Text", textBox1.Text); Assert.AreEqual("Second Window Text", textBox2.Text); }
public void FindWindows_IncludeChildWindows_MatchesParentAndChild() { var windowHandle1 = new IntPtr(100); var windowHandle2 = new IntPtr(200); var subWindowHandle11 = new IntPtr(1001); var subWindowHandle12 = new IntPtr(1002); var subWindowHandle21 = new IntPtr(2001); NativeMethodsStub.Stub(stub => stub.EnumWindows(Arg <EnumWindowsProc> .Is.NotNull, Arg <WindowFinderEnumWindowsProcContext> .Is.NotNull)) .WhenCalled( mi => { Assert.That(InvokeEnumWindowsProc(mi, windowHandle1), Is.True); Assert.That(InvokeEnumWindowsProc(mi, windowHandle2), Is.True); }) .Return(true); NativeMethodsStub.Stub( stub => stub.EnumChildWindows( Arg.Is(windowHandle1), Arg <EnumChildWindowsProc> .Is.NotNull, Arg <WindowFinderEnumChildWindowsProcContext> .Is.NotNull)) .WhenCalled( mi => { Assert.That(InvokeEnumChildWindowsProc(mi, subWindowHandle11), Is.True); Assert.That(InvokeEnumChildWindowsProc(mi, subWindowHandle12), Is.True); Assert.That(InvokeEnumChildWindowsProc(mi, subWindowHandle21), Is.True); }); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle1, 101, "Class1", "Window1"); StubNativeMethodsForWindowInformation(NativeMethodsStub, windowHandle2, 201, "Class2", "Window2"); StubNativeMethodsForWindowInformation(NativeMethodsStub, subWindowHandle11, 101, "Class1.1", "Window1.1"); StubNativeMethodsForWindowInformation(NativeMethodsStub, subWindowHandle12, 101, "Class1.2", "Window1.2"); StubNativeMethodsForWindowInformation(NativeMethodsStub, subWindowHandle21, 201, "Class2.1", "Window2.1"); var windows = WindowFinder.FindWindows(new WindowFilterCriteria { IncludeChildWindows = true, ClassName = new Regex("Class1") }); Assert.That(windows.Length, Is.EqualTo(3)); AssertWindowInformation(windows[0], windowHandle1, 101, "Class1", "Window1"); AssertChildWindowInformation(windows[1], subWindowHandle11, 101, "Class1.1", "Window1.1", windowHandle1); AssertChildWindowInformation(windows[2], subWindowHandle12, 101, "Class1.2", "Window1.2", windowHandle1); }
public static void Cleanup() { var basicWindow = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow", CompareKind.StartsWith), And.NoAssert().And.Timeout(100)); if (basicWindow != null) { basicWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); } basicWindow = WindowFinder.Search(Use.AutomationId("CUI_WindowFocusTestsWindow", CompareKind.StartsWith), And.NoAssert().And.Timeout(100)); if (basicWindow != null) { basicWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); } _mainWindow.CloseButton.Unsafe.Click(); DynamicSleep.Wait(1000); }
public TrackerSelector() { InitializeComponent(); this.trackingSettings = new TrackingSettings() { Type = TrackingType.Full, }; this.windowFinder = new WindowFinder(); // Item events this.tsmiWindow.Click += new EventHandler(tsmiWindow_Click); this.tsmiWindow.MouseDown += new MouseEventHandler(tsmiWindow_MouseDown); // Subscrible to move event of items in order to update window finder when user moves cursor over them... foreach (ToolStripItem item in this.cmsCaptureRegion.Items) { item.MouseMove += new MouseEventHandler(cmsCaptureRegion_ItemMouseMove); } // Load target cursor from .ico file in resources System.IO.MemoryStream targetCursorMs = new System.IO.MemoryStream(); iconTarget.Save(targetCursorMs); targetCursorMs.Position = 0; this.targetCursor = new Cursor(targetCursorMs); }
public frmOptions() { InitializeComponent(); this.presenter = new OptionsPresenter(this); this.windowFinder = new WindowFinder(); }