Reputation: 25705
I am building a Computer Adaptive Test in Java[Swing] and want to disable running other programs in the background until the test finishes(or the user quits). This is to prevent candidates taking the test from cheating in the test.
My question is, how to go about it? How can I stop creation of new task or prevention of user from interacting with other programs?
My homework before asking this question was: 1. I could use JNI and call SetForegroundWindow(HWND) function on windows. What are its equivalents in Linux?
Apologies if this question has been answered before --
Upvotes: 3
Views: 536
Reputation: 25705
Um I think I found a work around for this: (I should have thought about it in a simpler way).
I can implement WindowFocusListener to my frame and if the person cheats an ALARM will go off and alert the monitors.
Thanks everybody. :-)
Upvotes: 0
Reputation: 24283
On Windows, you can make use of another desktop session (The same thing the Windows Vista and 7 UAC prompt uses by default).
This allows you to run your process with no way (for the user) of interacting with the rest of the desktop but be very careful to make sure you switch back before exiting otherwise they'll be stuck.
Upvotes: 1
Reputation: 27232
While I don't know how to stop someone from changing focus you could track the focus, and detect when your GUI loses focus. You could even take some timing measurements so that, say 5 seconds is OK but 30 is not.
Upvotes: 1
Reputation: 509
How can I stop creation of new task or prevention of user from interacting with other programs
The above statement should not be allowed by the operating system, and i think you should gracefully warn the user not to start new tasks and interract with existing ones.
however, if you insist, you should consider writing some code acting like password protected screen saver, ofcourse not asking for a password.
Upvotes: 1