diff --git a/ElegantRecorder.Designer.cs b/ElegantRecorder.Designer.cs index fddf23b..505ec50 100644 --- a/ElegantRecorder.Designer.cs +++ b/ElegantRecorder.Designer.cs @@ -151,6 +151,7 @@ private void InitializeComponent() this.Controls.Add(this.labelStatus); this.Name = "ElegantRecorder"; this.Text = "Elegant Recorder"; + this.TopMost = true; this.ResumeLayout(false); this.PerformLayout(); diff --git a/ElegantRecorder.cs b/ElegantRecorder.cs index 4cc624a..f78b8ef 100644 --- a/ElegantRecorder.cs +++ b/ElegantRecorder.cs @@ -633,26 +633,28 @@ private void buttonReplay_Click(object sender, EventArgs e) return; } + Rect windowRect = (Rect)topLevelWindow.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty); + + var x = (int)windowRect.X + action.OffsetX; + var y = (int)windowRect.Y + action.OffsetY; + AutomationElement targetElement = FindElementInWindow(action.ControlName, action.AutomationId, action.ControlType, topLevelWindow, action.Level, action.ChildIndex); if (targetElement == null) { labelStatus.Text = "Failed to find element: " + action.ControlName; - return; } - - Rect windowRect = (Rect)topLevelWindow.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty); - Rect elementRect = (Rect)targetElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty); - - var x = (int)windowRect.X + action.OffsetX; - var y = (int)windowRect.Y + action.OffsetY; - - if (elementRect.X > x || x > elementRect.X + elementRect.Width || - elementRect.Y > y || y > elementRect.Y + elementRect.Height) + else { - var point = targetElement.GetClickablePoint(); - x = (int)point.X; - y = (int)point.Y; + Rect elementRect = (Rect)targetElement.GetCurrentPropertyValue(AutomationElement.BoundingRectangleProperty); + + if (elementRect.X > x || x > elementRect.X + elementRect.Width || + elementRect.Y > y || y > elementRect.Y + elementRect.Height) + { + var point = targetElement.GetClickablePoint(); + x = (int)point.X; + y = (int)point.Y; + } } int dx = (int)x * 65535 / screenBounds.Width + 1; diff --git a/readme.md b/readme.md index 2e87151..d134f8d 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # Elegant Recorder -![image](https://user-images.githubusercontent.com/981184/191825392-c3e051b0-e24a-4bc9-a23d-a2b984517861.png) +![image](https://user-images.githubusercontent.com/981184/191975186-e6527de6-3ff1-4c46-b0a1-ed4cde394ca0.png) Experimental tool that allows you to record and replay your actions inside Windows applications.