zoukankan      html  css  js  c++  java
  • 获取系统输入闲置时间

    delphi编写指定时间不动鼠标将系统锁定/以及在不动的情况下隐藏鼠标 
    3秒种不动鼠标键盘看看效果。
    GetLastInputInfo:获取闲置时间;
    ShowCursor:设置鼠标状态

    unit Unit1;
    interface
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls;
    type
      TForm1 = class(TForm)
        Timer1: TTimer;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
      function BlockInput(fFreezeInput : boolean):DWord; stdcall; external 'user32.DLL';
    var
      Form1: TForm1;
    implementation
    {$R *.dfm}
    procedure TForm1.Timer1Timer(Sender: TObject);
    var
      vLastInputInfo: TLastInputInfo;
    begin
      vLastInputInfo.cbSize := SizeOf(vLastInputInfo);
      GetLastInputInfo(vLastInputInfo);
      if GetTickCount - vLastInputInfo.dwTime > 3000 then
      begin
        ShowCursor(False)//隐藏鼠标
        timer1.Enabled:= false;
        BlockInput(True);
        showmessage('超过3秒,已锁定!');
      end;
    end;
    end.
     
    View Code
  • 相关阅读:
    第一次冲刺结果演示 一组评审总结
    检查博客情况
    第十次站立会议
    第九次站立会议
    暑期实训day4
    暑期实训day3
    暑期实训day2.1——一发空格引发的血案
    暑期实训day2
    暑期实训day1
    黑板模式
  • 原文地址:https://www.cnblogs.com/key-ok/p/3358972.html
Copyright © 2011-2022 走看看