我有下面的代码,它确实从一个位置拖放到另一个位置,但它不是正确的位置。如何减慢速度或查看其运行状况?我在CodedUI和Mouse.StartDragging等中使用过Mouse.Move,您可以设置速度并查看它们的作用,并在需要时进行更正。用于将画布上的某些内容拖动到画布上的其他项目,以便与位置相关。
我知道我会在某个时候到达那里,PMeter是一个很好的工具,可以用来在这里为您提供帮助,但是我希望能够看到我有时在做的调试工作。
Actions builder = new Actions(session);
builder.MoveByOffset(100, -85);
builder.ClickAndHold();
builder.MoveByOffset(gridPos2.X - gridPos1.X, gridPos2.Y - gridPos1.Y);
builder.Release();
builder.Perform();
答案 0 :(得分:0)
答案 1 :(得分:0)
我创建了一种方法来显示光标以您选择的颜色闪烁...
/// <summary>
/// This method is useful for seeing what the cursor is doing. **Call it like this...**
/// CommonMethods.HighlightCursor(new System.Drawing.Pen(System.Drawing.Color.Red));
/// </summary>
/// <param name="colour"></param>
public static void HighlightCursor(Pen colour)
{
for (int i = 0; i < 10; i++)
{
Point pt = Cursor.Position; // Get the mouse cursor in screen coordinates
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{
g.DrawEllipse(colour, pt.X - 5, pt.Y - 5, 10+i, 10+i);
}
Thread.Sleep(150);
}
}