|
I am writing an application that runs as a Windows Service to measure user inactivity - for the purpose of timing out applications. How best to do it?
None
|
|
|
|
|
Oops: My bad. I just noticed a similar thread below.
But coming to think of it, I am not particularly interesting in using Mouse/Keyboard hooks since they may affect over-all computer response. Is there a way to tell MS Windows to wake up a certain CALLBACK if the user doesn't input for a certain period of time?
None
|
|
|
|
|
look CWinApp::OnIdle (MFC)
Russell
|
|
|
|
|
Wrong. Did you read the docs to find out what OnIdle() does?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
brahmma wrote: Wrong
brahmma wrote: Did you read the docs to find out what OnIdle() does?
Did you?
Russell
|
|
|
|
|
I don't care you voting me 1 for that, but at least try to realize that you are providing wrong guidance to a person seeking help. That is plainly unacceptable.
Russell` wrote: Did you?
Of course I do read the docs and I've provided him the correct solution.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
Sorry,...I haven't seen that him was talking to windows-inactivity and not his app-inactivity.
Next time I'll read the question better.
Thank you
...and sorry to the OP
Russell
|
|
|
|
|
concoran wrote: I am not particularly interesting in using Mouse/Keyboard hooks since they may affect over-all computer response. Is there a way to tell MS Windows to wake up a certain CALLBACK if the user doesn't input for a certain period of time?
If you run Windows 2000 or above, you can use GetLastInputInfo() API.
See here[^].
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->ßRÅhmmÃ<-·´¯`·.
|
|
|
|
|
I am looking for some help on terminating an application after a certain period of inactivity.
I need to terminate the application if the user does not perform any actviity for certain amount of time.
Any help or direction will be appreciated.
Thanks
Sri Rama
|
|
|
|
|
1) For mouse/keyboard messages pretranslate might do or setup message hooks, whatever works. If other devices are used to interact with the program you have to account for them as well.
2) Upon any of those messages you cancel the previous duration timer and set a new one.
3) If the timer ever expires you exit the application.
|
|
|
|
|
Can you use a timer in your application class - likes of the of fashioned watch dog timer? Than all you have to do is reset it on any user activity or let it timeout and exit the app.
|
|
|
|
|
Sriramak wrote: Any help or direction will be appreciated.
See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Nice but ... does it defeat the windows very basics?
Would you have to put this API in some kinda of wait loop?
Just wondering.
Vaclav
|
|
|
|
|
Vaclav_Sal wrote: does it defeat the windows very basics?
Not sure what you mean by this.
Vaclav_Sal wrote: Would you have to put this API in some kinda of wait loop?
Most likely using WM_TIMER .
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I tought you would have to have this GetLastInputInfo()API in a loop to monitor the inactivity.
IMHO that defeats the very essence of an event driven OS unless you "plug it in" into windows message loop of course.
Is't the timer (CTimer) already in this OS loop since it is a "windows" resource ?
|
|
|
|
|
Vaclav_Sal wrote: I tought you would have to have this GetLastInputInfo()API in a loop to monitor the inactivity.
You can call SetTimer(1000) , and then respond to the WM_TIMER message.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
My app shows the dialog box in a modal (topmost) window.
The purpose of the app is to give feedback to the user about the button pressed on the keyboard, however, whenever I press the ESC or Space keys, the IDCANCEL or IDOK buttons are "pressed".
Is it possible to prevent this behavior ?
(I want those buttons only to be used by the user via mouse click to exit the app. The "Default Button" property for the buttons is set to False)
thankyou !
|
|
|
|
|
you need to add a PreTranslateMsg handler and eat the Escape & Space keys.
|
|
|
|
|
I am studying this now. Found a good example here http://www.codeguru.com/forum/archive/index.php/t-203713.html
thanks !!
|
|
|
|
|
abiemann wrote: Is it possible to prevent this behavior ?
Yes. See here.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I've added BN_CLICKED handlers:
S2000_CP_DLG::OnExitOK()
S2000_CP_DLG::OnExitCANCEL()
and for good measure I've stubbed-out the base functions: (probably unnecessary)
S2000_CP_DLG::OnOK()
S2000_CP_DLG::OnCancel()
so what happens now is that when I press [Esc] the OnExitCANCEL() is called.
When I press [Enter] or [Space] the OnExitOK() is called.
but since the app has to run through some code when OK and CANCEL are clicked I can't just leave the handlers empty.
Hence, within the handlers I think I need to detect if the keyboard was used to click the button. If no, then proceed with processing and close the dialog. If yes, then exit the handler.
I just don't know how to detect if the keyboard was used to enter OnExitOK and OnExitCANCEL.
|
|
|
|
|
I got it fixed:
I went back to the Dialog Editor, deleted the BN_CLICKED handlers from the IDOK and IDCANCEL buttons. Then I made the default OK and CANCEL buttons invisible and changed their captions to "ignore".
Subsequently I added 2 new buttons: "OK" and "CANCEL" and added the BN_CLICKED handlers to handle the closing of the Dialog.
Now the user can press [Enter], [Esc], and [Space] without any problem what-so-ever and when the user wants exit - the OK and CANCEL buttons will do just that
|
|
|
|
|
This one has been bugging me all day. I'm trying to fill a consoles screen with null characters using FillConsoleOutputCharacter() passing '\0' as the character. This works flawlessly in a non-unicode build, but after switching to unicode it just doesn't work.
After reading the buffer it becomes apparant that the screen was filled with spaces 0x0020. Thinking it was a problem with the null character I then tried '0x0A' and '0x000A' both of which fill the buffer with '0x25D9'.
Do I need to do anything special before trying to fill with a unicode null character, or does the function just not work in a unicode build?
|
|
|
|
|
The unicode implementation is FillConsoleOutputCharacterW().
|
|
|
|
|
And the ANSI implementation is FillConsoleOutputCharacterA(), both of which are mapped accordingly depending if UNICODE is defined. So how does this relate to my question?
|
|
|
|