My objective is to get current position on the screen (out side the form), and save X, Y coords by press "C" for example.
I google and found some suggestion to use api hooks, but i wonder are there a way we can do this task purely in C# code (.NET Lib) ?
Please give me quick sample if possible because im new to c#.
Thanks
Just use:
Cursor.Position
or
Control.MousePosition
To get the position. You can then map the KeyPress event of the form:
private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == 'c')
MessageBox.Show(Cursor.Position.ToString());
}
The individual X and Y coordinates are two properties of the Position object.
Documentation: http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With