如何封鎖鍵盤及滑鼠
Win98/Me/2000/XP 適用
有網友問怎樣封鎖(lock)鍵盤及滑鼠(中止回應),答案是用api "BlockInput"。
傳入true以封鎖,false以解鎖。
e.g
Private Declare Function BlockInput Lib "USER32.DLL" (ByVal fBlockIt As Long) As Long
Private Sub Command1_Click()
  BlockInput True '封鎖
  Delay 3 '等候3秒
  BlockInput False '解鎖
  End Sub
Private Sub Delay(DelayTime As Single)
  Dim ST As Single
  ST = Timer
  Do Until Timer - ST > DelayTime
  DoEvents
  Loop
  End Sub
註︰按crtl+alt+del 能解除封鎖。
必要時可用do..doevents..loops+showintaskbar=false去封鎖︰
e.g
Private Declare Function BlockInput Lib "USER32.DLL" (ByVal fBlockIt As Long) As Long
Private Sub Command1_Click()
  Do
  DoEvents
  BlockInput True
  Loop
  End Sub