Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A Global Timer since last User's Input
Message
De
07/12/2004 18:03:35
 
 
À
24/04/2004 06:07:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00897805
Message ID:
00967637
Vues:
15
Cetin,

After having found some guy Brian_123 writing the GetLastInputInfo() solution for vfp on ExpertsExchange, I hit on your code here.

Three questions:
1) Why do you first and for all test for GetCursorPos(), whether it's W2K+ or not?
2) Why do you also check the screensaver?
3) Is the code for the screensaver check complete?

Thanks in advance.

>>Looking for a way to determine how long since the User has moved the mouse or used the keyboard globally regardless of whether he is in vfp's main _screen, or in specific forms, menues....
>>
>>I need this information to timeout the user's last login, and Force a new Login. Any user activity needs to reset time timer.
>>
>>I can't see how a single timer on one form can do this in a global fashion. Maybe asking for a new command such as SECONDS_SINCE_INPUT() (in vfp10 ?) would be appropriate.
>
>Just yesterday I sent some code about it on another forum. Check :
>
>http://oldlook.experts-exchange.com:8080/Databases/FoxPro/Q_20963825.html
>
>It checks activity not only from within VFP but globally anywhere (in another task, screen saver active/kicked in etc). Couldn't send complete code but core is there.
>
>Update: That link is not trustable it migh tbe deleted anytime. So I paste here as is :
>
>The full code of checking is rather long - here is the core codes that I use to check inactivity (works w/o a need to AttachThreadInput but you might incorparate it as well) :
>
>* 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)
>
>Cetin
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform