【发布时间】:2015-07-06 09:41:20
【问题描述】:
基本上我想移动鼠标直到角度匹配。 这是我到目前为止得到的(不起作用):
for (eyeangle != angleVert)
{
if (eyeangle < angleVert)
{
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 10);
}
if (eyeangle > angleVert)
{
this.Cursor = new Cursor(Cursor.Current.Handle);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 10);
}
}
这样做的正确方法是什么?
【问题讨论】:
-
你必须有某种数组或集合来迭代
-
好的,我会这样做:
for(int i = 0; angleVert != eyeangle; i++) { if (eyeangle < angleVert) { this.Cursor = new Cursor(Cursor.Current.Handle); Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - i); } -
我想你可能想要一个
while循环,但要小心:如果你的逻辑不好,你最终会出现一个无限循环。您需要确保条件最终肯定为真,或者您有办法打破循环 -
@jmc 这不是 java 而是 c#
-
@BinkanSalaryman 真的吗?好吧,你能用这种语法给我看一个 for 循环吗?
for (eyeangle != angleVert)
标签: c# cursor-position