Skip to content

Instantly share code, notes, and snippets.

@wyvernzora
Created February 24, 2014 06:02
Show Gist options
  • Save wyvernzora/9182683 to your computer and use it in GitHub Desktop.
Save wyvernzora/9182683 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
using System.Windows;
namespace Launcher
{
public static class Utilities
{
#region Win32 Calls
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool GetCursorPos(ref Win32Point pt);
[StructLayout(LayoutKind.Sequential)]
private struct Win32Point
{
public Int32 X;
public Int32 Y;
}
#endregion
/// <summary>
/// Gets the on screen position of the cursor.
/// </summary>
/// <returns></returns>
public static Point GetCursorPosition()
{
Win32Point point = new Win32Point();
GetCursorPos(ref point);
return new Point(point.X, point.Y);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment