|
Can set a timer, interval = 100
Check if the title of the currently focused form is this program
'Get the current form handle
Public Declare Function GetActiveWindow Lib "user32" Alias "GetActiveWindow" () As Long
'Get title
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
'Flash form
Public Declare Function FlashWindow Lib "user32" Alias "FlashWindow" (ByVal hwnd As Long, ByVal bInvert As Long) As Long
'Activate the form
Public Declare Function SetActiveWindow Lib "user32" Alias "SetActiveWindow" (ByVal hwnd As Long) As Long
If you want to restrict the user to use a certain key combination or some mouse operations when this window is not activated, it is more complicated
But mainly use api function hook to monitor, use sendmessage, postmessage and other functions to block certain messages of the system, it is very complicated. . .
If it is active, keyboard events, use the form's keydown event (the form's keypreview property must be true) can be monitored and blocked, the mouse has to use the hook function |
|