WPF 长时间无键鼠操作后自动执行某些操作
因需要在页面长时间无操作后自动返回首页,在这里记录一下。
利用Windows的API:GetLastInputInfo
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace WpfApplication1
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
private DispatcherTimer mouseOrKeyboardOpTimer;
private readonly static int defaultCheckCount = <

这篇博客介绍了如何在WPF应用程序中实现当用户长时间未进行任何键鼠操作后,自动触发返回首页的功能。通过调用Windows API GetLastInputInfo来检测用户的活跃状态。
最低0.47元/天 解锁文章
803

被折叠的 条评论
为什么被折叠?



