Aniket Inge
Aniket Inge

Reputation: 25705

Disable running a program in Linux and Windows

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?

  1. Disable Keyboard completely using SetWindowsHookEx() function with a global LOWLEVEL KEYBOARD HOOK PROC. Equivalents in Linux?

Apologies if this question has been answered before --

Upvotes: 3

Views: 536

Answers (4)

Aniket Inge
Aniket Inge

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

Deanna
Deanna

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

Paul Rubel
Paul Rubel

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

alpera
alpera

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

Related Questions