저는 Teamviewer를 재미있는 소프트웨어로 만들려고합니다. 한 사람이 다른 사람의 화면을보고 클릭하면됩니다. 어쨌든 대부분의 소켓 작업은 끝났지 만 마우스 클릭이 올바르게 작동하는 방법을 모르겠습니다. 여기에 프로그래밍 방식으로 마우스를 이동 온라인으로 볼 수있는 코드 :C#으로 움직이는 마우스 (좌표 단위)
public static class VirtualMouse
{
// import the necessary API function so .NET can
// marshall parameters appropriately
[DllImport("user32.dll")]
static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);
// constants for the mouse_input() API function
private const int MOUSEEVENTF_MOVE = 0x0001;
private const int MOUSEEVENTF_LEFTDOWN = 0x0002;
private const int MOUSEEVENTF_LEFTUP = 0x0004;
private const int MOUSEEVENTF_RIGHTDOWN = 0x0008;
private const int MOUSEEVENTF_RIGHTUP = 0x0010;
private const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;
private const int MOUSEEVENTF_MIDDLEUP = 0x0040;
private const int MOUSEEVENTF_ABSOLUTE = 0x8000;
// simulates movement of the mouse. parameters specify changes
// in relative position. positive values indicate movement
// right or down
public static void Move(int xDelta, int yDelta)
{
mouse_event(MOUSEEVENTF_MOVE, xDelta, yDelta, 0, 0);
}
// simulates movement of the mouse. parameters specify an
// absolute location, with the top left corner being the
// origin
public static void MoveTo(int x, int y)
{
mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, x, y, 0, 0);
}
// simulates a click-and-release action of the left mouse
// button at its current position
public static void LeftClick()
{
mouse_event(MOUSEEVENTF_LEFTDOWN, Control.MousePosition.X, Control.MousePosition.Y, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, Control.MousePosition.X, Control.MousePosition.Y, 0, 0);
}
}
가 지금은 moveTo 메소드를 사용하여 마우스를 이동할는하지만, 움직임이 미친 높은 번호가 필요합니다. 화면상의 위 치로 픽셀 단위로 이동하는 좌표를 일치시킬 수 있습니까? 죄송합니다 이것은 명백한 질문처럼 보이지만 거의 한 시간 동안 봤는데 봤는데 어떤 단위가 마우스 x 및 y 위치에 사용되고 있는지에 대한 논의를 찾을 수 없으므로 어떤 종류의 수식을 사용하여 한 패널의 클릭 수와 사용자의 클릭 수를 비교합니다. Microsoft's documentation 가입일
['Cursor.Position'] (http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx)는 유망 해 보입니다. – chris