|
发表于 2020-1-18 16:27:02
|
显示全部楼层
可以设个timer,interval=100
检测当前获得焦点的窗体标题是否是本程序
'获得当前窗体句柄
Public Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
'获得标题
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'闪窗体
Public Declare Function FlashWindow Lib "user32" Alias "FlashWindow" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
'激活窗体
Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long) As Long
如果想当本窗全不是激活状态的话,限制用户使用某种键组合或者鼠标的一些操作比较复杂
但主要是使用api函数hook来进行监视,使用sendmessage、postmessage等函数来阻止系统的某些消息,很复杂咯。。。
如果是处于激活状态,键盘事件,使用窗体的keydown事件就行(窗体的keypreview属性要为true)就可以监视并阻止了,鼠标还得用hook函数 |
|