WPF 定时器DispatcherTimer+GetCursorPos 的使用,动态查看屏幕上任一点坐标
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.IO;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Windows.Threading;
namespace AiGame
{
public partial class MainWindow : Window
{
public struct POINT
{
public int X;
public int Y;
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]//导入Dll
public static extern bool GetCursorPos(ref POINT pt);//定义相对应的函数,需使用ref传入结构,这里是传入结构的引用
public MainWindow()
{
InitializeComponent();
DispatcherTimer dTimer = new System.Windows.Threading.DispatcherTimer();
dTimer.Tick += new EventHandler(dTimer_Tick);
dTimer.Interval = new TimeSpan(0, 0, 0, 0, 100);
dTimer.Start();
}
void dTimer_Tick(object sender, EventArgs e)
{
POINT p = new POINT();
GetCursorPos(ref p);//这里传入结构实例
this.Title= p.X.ToString() + " " + p.Y.ToString();//鼠标的实时坐标在标题上体现出来
}
}
}
- WPF 定时器DispatcherTimer+GetCursorPos 的使用,动态查看屏幕上任一点坐标
- C#中使用GetCursorPos获取屏幕坐标
- C#中使用GetCursorPos获取屏幕坐标
- C#中使用GetCursorPos获取屏幕坐标
- MFC中InvalidateRect 、GetCursorPos、静态或全局变量使用、 error RC1121 四个问题
- 易语言-API 取窗口或者组件句柄的 屏幕坐标并限制区域 GetWindowRect ClipCursor getwindowrect GetClientRect WindowFromPoint
- c#四种定时器,wpf DispatcherTimer
- MFC的坐标转换GetClientRect/GetWindowRect/ClientToScreen/GetCursorPos/ScreenToClient
- GetClinetRect GetWindowRect ScreenToClient ClientToScreen GetCursorPos几个函数的正确使用
- 使用getLocationInWindow或getLocationOnScreen获得View在屏幕中的坐标
- MFC的坐标转换GetClientRect/GetWindowRect/ClientToScreen/GetCursorPos/ScreenToClient
- C# .NET中如何使用GetCursorPos函数
- WPF的System.Windows.Threading.DispatcherTimer的使用(每隔一定的时间重复做某事)
- GetCursorPos获取鼠标坐标
- java中使用线程实现Timer(定时器)原理和源码
- Silverlight2.0中的计时器类DispatcherTimer——不再使用Storyboard计时器
- java中使用线程实现Timer(定时器)原理和源码
- WinAPI: GetCursorPos - 获取鼠标指针的当前位置
- java中使用线程实现Timer(定时器)原理和源码
- GetCursorPos/WindowFromPoint/SendMessage (用API函数向Edit框发送字符)