One way would be:the form's KeyPreview property needs to be set to true.VB Code:
Private Sub Form_KeyPress(KeyAscii As Integer) Timer1.Enabled = False: Timer1.Enabled = True End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Timer1.Enabled = False: Timer1.Enabled = True End Sub Private Sub Timer1_Timer() Unload Me End Sub
That will only work well if you have a lot of the form exposed (i.e. not covered with controls so the MouseMove event doesn't fire).
Alternatively you could use GetCursorPos API on a timer to check the mouse position.




Reply With Quote