2017-05-03 1 views
0

나는 자동으로 마우스를 움직이고 백그라운드에서 버튼을 누르면 응용 프로그램을 만들고 싶습니다. 판매 및 재고/HTML 숍 웹 사이트 프로그래밍 및이 컨트롤을 포함하는 응용 프로그램을 만드는 것은 처음입니다. 내 프로그래밍 기술을 밀어주고 싶어서 나를 도와주세요. 이것은 내가하고 싶은 일이고 나의 아이디어입니다. * 내가 이동 현재 커서의 X/Y하지 1.GetC# 마우스 Winforms 이동/클릭

의 반복을 위해 루프 카운터를 넣고라는 변수에 저장한다 (점 A)

을 클릭 2.Right (좌표) 및

3.wait 2초

4.Move 다시 변수를 사용하여 제 위치 (좌표)

5.End 루프 반복 우하 (점 B)를 이동한다.

내 생각과 알고리즘은 내 문제는 마우스를 움직여 멈추게하는 방법이 전혀 없다는 것입니다.

+0

WPA? WPF를 말하는 겁니까? 이 경우 관련 답변이 있습니다. http://stackoverflow.com/questions/8050825/how-to-move-mouse-cursor-using-c/8050847#8050847 – bradbury9

+0

woops 죄송합니다. Windows 애플리케이션 양식 –

+0

https : //을 의미합니다. msdn.microsoft.com/en-us/library/ms753326(v=vs.110).aspx –

답변

0

당신은이 같은 일부 기능이나 코드 작성 마우스를 이동할 수 있습니다

private void MoveCursor() 
{ 
    // Set the Current cursor, move the cursor's Position, 
    // and set its clipping rectangle to the form. 

    this.Cursor = new Cursor(Cursor.Current.Handle); 
    Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50); 
    Cursor.Clip = new Rectangle(this.Location, this.Size); 
} 

How To Move mouse in C#

을 그리고 다음 코드

Point locationOnForm = control.FindForm().PointToClient(
    control.Parent.PointToScreen(control.Location)); 
를 사용할 수있는 양식에 모든 컨트롤의 위치를 ​​찾으려면

How to get controls location in Win Forms

1

윈도우 있음 m 프로젝트를 사용하여 커서를 화면의 특정 지점으로 이동하면이 정적 방법을 사용할 수 있습니다.

System.Windows.Forms.Cursor.Position = new Point (X,Y);

은이 방법을 사용할 수있는 클릭 이벤트를 수행 할 수 있습니다.

[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] 
public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo); 

public void DoMouseClick() 
{ 
    //Call the imported function with the cursor's current position 
    uint X = (uint)System.Windows.Forms.Cursor.Position.X; 
    uint Y = (uint)System.Windows.Forms.Cursor.Position.Y; 
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, 0, 0); 
}