반응형

 

콤보박스의 기본은 index값이 수정이 가능하다.

 

그걸 막기위해서 속성에서 DropDownStyle을 수정한다.

 

 

기본 설정이 DropDown에서 DropDownList로 설정을 변경해주면 된다.

 

 

위 F2 콤보박스는 DropDown 설정 값 상태

F3 콤보박스는 DropDownList 설정 값 상태

 

 

반응형
반응형

 

 

특정 위치 마우스 자동 클릭

 

 

프로그램 이해하는데에는 크게 문제없을 겁니다.

시작 위에 나와있는 좌표 보고 자동클릭할 좌표를 텍스트 박스에 적어주시고

반복할 횟수 값 넣어주시면 됩니다.

 

 

<실행 화면>

 

 

 

<실행 파일>

 

 

XY_Click.exe

 

 

 

<소스코드>

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Muse_con
{
    public partial class Form1 : Form
    {
        [DllImport("User32.dll")]
        private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);

        private static int Cur_x, Cur_y; // text박스에서 가져올 X축, Y축
        private static int Loop_cun; // 반복횟수

        private const uint L_down = 0x0002;//왼쪽 마우스 버튼 누름
        private const uint L_up = 0x0004; // 왼쪽 마우스 버튼 땜

        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            timer1_Tick(sender, e);
            timer1.Interval = 300; //스케쥴 간격을 0.3초로 준 것이다.
            timer1.Start(); //타이머를 발동시킨다.
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            Cur_label.Text = "X : " + Cursor.Position.X.ToString() + "   Y : " + Cursor.Position.Y.ToString();
        }
        private void start_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(text_x.Text)&& !String.IsNullOrEmpty(text_y.Text))
            {
                Cur_x = Convert.ToInt32(text_x.Text);
                Cur_y = Convert.ToInt32(text_y.Text);
                Cursor.Position = new Point(Cur_x, Cur_y); // XY축으로 마우스 이동
            }
            Loop_cun = Convert.ToInt32(text_cun.Text);

            
            for (int i = 0; i <Loop_cun; i++)
            {
                mouse_event(L_down, 0, 0, 0, 0);
                mouse_event(L_up, 0, 0, 0, 0);
            }
        }
        private void exit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

    }
}

 

<참고자료>

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-mouse_event

문제점이나 개선사항은 댓글 부탁드립니다.

반응형
반응형

 mouse_event를 사용하여 마우스제어.

 

자세한 부분 이나 추가적인 부분 참고

https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-mouse_event

 

Click_button()함수 호출할때 마다 한번 클릭이 작동합니다.

 

C#소스

 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace test_1
{
    public partial class Form1 : Form
    {
        [DllImport("User32.dll")]
        private static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint dwData, int dwExtraInfo);

        private const uint L_down = 0x0002 //왼쪽 마우스 버튼 누름
        private const uint L_up = 0x0004 // 왼쪽 마우스 버튼 땜


        public Form1()
        {
            InitializeComponent();
        }

        private void Click_button()
        {
            mouse_event(L_down, 0, 0, 0, 0);
            mouse_event(L_up, 0, 0, 0, 0);
        }

    }
}

 

 

0x0008 오른쪽 버튼 누름

0x0010 오른쪽 버튼 땜

 

 

 

반응형
반응형

형 변환이란 데이터 타입을 변환 하는 것이다.

 

 

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 12345;
            float b = 12.345f;
            double c = 54.321;
            string d = "54321";
            
            Console.WriteLine("string d - > int = {0}", int.Parse(d));
            Console.WriteLine("int a - > string = {0}", a.ToString());

            Console.WriteLine("float b - > int = {0}", (int)c);
            Console.WriteLine("double c - > int = {0}", (int)b);

        }
    }
}

 

 

숫자를 문자로 바꿀 때는 변수.ToString()

 

문자를 숫자로 바꿀때는 정수계열타입.parse(문자변수)

 

 

 

 

 

 

double 이나 float 에서 int 형식으로 바꾸면 데이터 손실이 일어나므로 소수점 부분은 버림으로 처리한다.

double 에서 float 으로 바꾸면 반올림 처리된다.

 

 

 

 

반응형
반응형

마우스 좌표는 Cursor.Position 으로 가져올수 있습니다.


소스

1
2
3
Cursor.Position
Cursor.Position.X // X축 좌표
Cursor.Position.Y // Y축 좌표
cs



결과


? = 숫자.


{X=???,Y=???}

X=???

Y=???





첨부파일



마우스 좌표.exe


Form 항상 위


this.TopMost = true;


OR


폼 속성칸에 TopMost 있습니다.





반응형

+ Recent posts