【问题标题】:How to display a message when the mouse and keyboard not used for two minutes?如何在鼠标和键盘两分钟未使用时显示消息?
【发布时间】:2020-07-08 03:50:56
【问题描述】:

我希望我的 Windows 窗体应用程序在我的鼠标和键盘不活动 2 分钟时向我显示消息,有人可以帮助我吗?

我有用 C# 编写的 WinForms 应用程序。现在是医生应用程序的时间,我希望我的应用程序在两分钟未使用鼠标和键盘时向我显示消息。

SqlConnection conn = new SqlConnection(@"Data Source=DESKTOP-CVVIN92;Initial Catalog=PizzaShop;Integrated Security=True");
for(int i=0; i < dataGridsorder.Rows.Count; i++)
{              
    SqlCommand cmd=new SqlCommand(@"INSERT into Orders(Customer,Mobile,Date,MainType,SubType,OrderType,Discount,Net_Total) VALUES('"+dataGridsorder.Rows[i].Cells[0].Value+ "','" + dataGridsorder.Rows[i].Cells[1].Value + "','" + dataGridsorder.Rows[i].Cells[2].Value + "','" + dataGridsorder.Rows[i].Cells[3].Value + "','" + dataGridsorder.Rows[i].Cells[4].Value + "','" + dataGridsorder.Rows[i].Cells[5].Value + "','" + dataGridsorder.Rows[i].Cells[6].Value + "','" + dataGridsorder.Rows[i].Cells[7].Value + "')",conn);
    conn.Open();
    cmd.ExecuteNonQuery();
    conn.Close();

    MessageBox.Show("Your order is successfully completed...", "Information Messsage", MessageBoxButtons.OK, MessageBoxIcon.Information);
}

像这个 MessageBox 一样,我想显示鼠标是否没有移动。

【问题讨论】:

标签: c#


【解决方案1】:

您可以使用每 X 秒触发一次的timer。然后,您可以使用来自@JQSOFT 的链接来检查两分钟是否已经过去since the last input。如果有,请显示messagebox

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-11-15
    • 2012-10-08
    • 2016-09-22
    • 2010-12-29
    • 2022-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多