728x90
728x170
▶ Program.cs
using System;
using System.Runtime.InteropServices;
namespace TestProject
{
/// <summary>
/// 프로그램
/// </summary>
class Program
{
//////////////////////////////////////////////////////////////////////////////////////////////////// Import
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 커서 위치 구하기 - GetCursorPos(point)
/// <summary>
/// 커서 위치 구하기
/// </summary>
/// <param name="point">포인트</param>
/// <returns>처리 결과</returns>
[DllImport("user32")]
private static extern bool GetCursorPos(out POINT point);
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Field
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region Field
/// <summary>
/// X
/// </summary>
private static int _x;
/// <summary>
/// Y
/// </summary>
private static int _y;
#endregion
//////////////////////////////////////////////////////////////////////////////////////////////////// Method
////////////////////////////////////////////////////////////////////////////////////////// Static
//////////////////////////////////////////////////////////////////////////////// Private
#region 마우스 위치 출력하기 - PrintMousePosition()
/// <summary>
/// 마우스 위치 출력하기
/// </summary>
private static void PrintMousePosition()
{
POINT point;
if(GetCursorPos(out point) && point.X != _x && point.Y != _y)
{
Console.Clear();
Console.WriteLine($"({point.X},{point.Y})");
_x = point.X;
_y = point.Y;
}
}
#endregion
#region 프로그램 시작하기 - Main()
/// <summary>
/// 프로그램 시작하기
/// </summary>
private static void Main()
{
Console.CursorVisible = false;
while(!Console.KeyAvailable)
{
PrintMousePosition();
}
Console.CursorVisible = true;
}
#endregion
}
}
728x90
그리드형(광고전용)
'C# > Common' 카테고리의 다른 글
[C#/COMMON] GetKeyboardLayoutName API 함수를 사용해 키보드 레이아웃 ID 구하기 (0) | 2021.10.05 |
---|---|
[C#/COMMON] List<T> 클래스 : 임의 리스트 구하기 (0) | 2021.09.12 |
[C#/COMMON] BitArray 클래스 : SetAll 메소드를 사용해 모든 비트 설정하기 (0) | 2021.09.12 |
[C#/COMMON] MSI 파일 속성 정보 구하기 (0) | 2021.09.05 |
[C#/COMMON] 누겟 설치 : NATS.Client (0) | 2021.09.05 |
[C#/COMMON] Console 클래스 : WindowWidth/WindowHeight 정적 속성 사용하기 (0) | 2021.08.28 |
[C#/COMMON] Console 클래스 : CursorVisible/CursorSize 정적 속성 사용하기 (0) | 2021.08.28 |
[C#/COMMON] DeviceIoControl API 함수를 사용해 디스크 공간에서 파일 압축 설정하기/취소하기 (0) | 2021.08.28 |
[C#/COMMON] keybd_event API 함수를 사용해 SCROLL LOCK/NUM LOCK/CAPS LOCK 키 토글하기 (0) | 2021.08.28 |
[C#/COMMON] Path 클래스 : GetTempPath/GetRandomFileName 정적 메소드를 사용해 임시 파일 경로 구하기 (0) | 2021.08.28 |