>* API declarations (form.init) >declare short GetCursorPos in win32api string @ lpPoint >Declare short SystemParametersInfo In WIN32API ; > integer uiAction, Integer uiParam, Integer @pvParam, Integer fWinIni >Declare SHORT GetAsyncKeyState In WIN32API Integer nVirtKey > >DECLARE INTEGER GetSystemMetrics IN Win32API INTEGER nIndex > >declare short GetVersionEx in win32API string @ lpVersionInfo >Local lpVersionInfo >lpVersionInfo = chr(128+5*4)+replicate(chr(0),128+5*4-1) >GetVersionEx(@lpVersionInfo) > >this.Is2K_or_Later = ASC(substr(lpVersionInfo, 5)) > 4 && 2000/XP or later >If this.Is2K_or_Later > Declare short GetLastInputInfo in win32API string @ plii >EndIf > > >* ActivityDetected >LOCAL lpPoint, llKeypress, llMouseMove, llInput >lpPoint = space(8) >If ( GetCursorPos(@lpPoint)#0 AND lpPoint # this.ptLastPoint ) > this.ptLastPoint = lpPoint && Save new pos > m.llMouseMove = .T. >Else && Check keystate > If thisform.Is2k_or_later > Local plii > plii = Chr(8) + Replicate(Chr(0),7) > If ( GetLastInputInfo(@plii) # 0 and Substr(plii,5) # Substr(this.plii,5) ) > this.plii = plii > m.llInput = .T. > endif > else > For ix=0 To 255 > If GetAsyncKeyState(ix) # 0 && Keypress or mouse button detected > m.llKeypress = .T. > Exit > Endif > EndFor > endif >EndIf >thisform.ActivityReset() >RETURN ( m.llMouseMove or m.llKeypress or m.llInput) > > >* form.ActivityReset >LOCAL lpPoint >lpPoint = space(8) >If ( GetCursorPos(@lpPoint)#0 AND lpPoint # this.ptLastPoint ) > this.ptLastPoint = lpPoint && Save new pos >ENDIF >For ix=0 To 255 > GetAsyncKeyState(ix) >Endfor > > > >************************************ >*Screen saver is also part of checking >************************************ >#Define SPI_GETSCREENSAVETIMEOUT 14 >#Define SPI_SETSCREENSAVETIMEOUT 15 >#Define SPI_GETSCREENSAVEACTIVE 16 >#Define SPI_SETSCREENSAVEACTIVE 17 >#Define SPI_GETSCREENSAVERRUNNING 114 >#Define SPI_SETSCREENSAVERRUNNING 97 >#Define SPI_SCREENSAVERRUNNING SPI_SETSCREENSAVERRUNNING > >LOCAL bActive, iTimeout >Store 0 To bActive, bRunning, iTimeout >SystemParametersInfo(SPI_GETSCREENSAVETIMEOUT, 0,@iTimeout, 0) >SystemParametersInfo(SPI_GETSCREENSAVEACTIVE, 0,@bActive, 0)>