Disable Keybord Buttons
is it possible to disable the print screen button when my program is in use?
is it possible to disable the print screen button when my program is in use?
actually, this is interesting, because i know I've played some games before online where printscreen did not work, and i had to go to a menu and click on a button everytime i wanted a snap shot. so it might be possible, and funny thing is, i think it was a game written in java.
I dont have enough knowledge to instruct on how to do it, but if you have the app running, and you click printscreen, you could have your keyboard listener ignore it? dont know if that would work, and then if they try going around it by being on the desktop and printing the screen you could make it so the app minimizes when it's not selected?
anyways good luck...
> actually, this is interesting, because i know I've
> played some games before online where printscreen did
> not work, and i had to go to a menu and click on a
> button everytime i wanted a snap shot. so it might
> be possible, and funny thing is, i think it was a
> game written in java.
>
> I dont have enough knowledge to instruct on how to do
> it, but if you have the app running, and you click
> printscreen, you could have your keyboard listener
> ignore it? dont know if that would work, and then if
> they try going around it by being on the desktop and
> printing the screen you could make it so the app
> minimizes when it's not selected?
>
> anyways good luck...
I think ill try that.
Better yet, tell the people giving you the idiotic requirement that it's an idiotic requirement.
1) It can still be circumvented thru what's been mentioned already
2) Don't mess with the user's wishes. If they want to print the screen, don't make it harder for them to do it (and they still will be able to in one way or another). It's not hurting anything to let them print it. They're "printing" it in their minds when they see it on the screen. A paper copy of that mental image isn't hurting anything.
> Better yet, tell the people giving you the idiotic
> requirement that it's an idiotic requirement.
> 1) It can still be circumvented thru what's been
> mentioned already
> 2) Don't mess with the user's wishes. If they want to
> print the screen, don't make it harder for them to do
> it (and they still will be able to in one way or
> another). It's not hurting anything to let them print
> it. They're "printing" it in their minds when they
> see it on the screen. A paper copy of that mental
> image isn't hurting anything.
honestly.. wtf. What if its for security reasons so that images of what is going on in the app don't get out?
and plus, the user seems to be asking for it to be disabled...
>
>
> honestly.. wtf. What if its for security reasons
That makes it worse. If it's really a "security" issue then the problem should be addressed in a more suitable fashion.
> Better yet, tell the people giving you the idiotic
> requirement that it's an idiotic requirement.
> 1) It can still be circumvented thru what's been
> mentioned already
> 2) Don't mess with the user's wishes. If they want to
> print the screen, don't make it harder for them to do
> it (and they still will be able to in one way or
> another). It's not hurting anything to let them print
> it. They're "printing" it in their minds when they
> see it on the screen. A paper copy of that mental
> image isn't hurting anything.
It is my clients request that it be disabled, i would rather not tell hi its stupid. I can how ever tell him its not possible.
you'll probably find the OS handles the printscreen key before it gets to the jvm.
perhaps if you reset the clipboard (after the prinscreen key gets to the jvm).
something like this
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.datatransfer.*;
import java.io.*;
class Testing
{
public void buildGUI()
{
JFrame f = new JFrame();
f.getContentPane().add(new JScrollPane(new JTextArea(10,20)));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(new KeyEventDispatcher(){
public boolean dispatchKeyEvent(KeyEvent ke){
if(ke.getID() == KeyEvent.KEY_RELEASED)
{
if(((KeyEvent) ke).getKeyCode() == KeyEvent.VK_PRINTSCREEN)
{
System.out.println("print screen");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new DummyImage(new ImageIcon("test.gif").getImage()), null);
}
}
return false;
}
});
}
class DummyImage implements Transferable
{
private Image image;
public DummyImage(Image img){image = img;}
public DataFlavor[] getTransferDataFlavors(){return new DataFlavor[]{DataFlavor.imageFlavor};}
public boolean isDataFlavorSupported(DataFlavor flavor){return DataFlavor.imageFlavor.equals(flavor);}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException
{
if (!DataFlavor.imageFlavor.equals(flavor)){throw new UnsupportedFlavorException(flavor);}
return image;
}
}
public static void main(String[] args){new Testing().buildGUI();}
}
that wont work. no java solution will.
what if i made the program half the screen and then gave focus to another program on the other half. if i hit printscreen it wouldnt register
with the java program but id still get the image. : P
> you'll probably find the OS handles the printscreen
> key before it gets to the jvm.
> perhaps if you reset the clipboard (after the
> prinscreen key gets to the jvm).
>
> something like this
>
> > import java.awt.*;
> import java.awt.event.*;
> import javax.swing.*;
> import java.awt.datatransfer.*;
> import java.io.*;
> class Testing
> {
>
>public void buildGUI()
> {
>JFrame f = new JFrame();
> f.getContentPane().add(new JScrollPane(new
> JTextArea(10,20)));
>
> .setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
>f.pack();
> f.setLocationRelativeTo(null);
>f.setVisible(true);
>
> eyboardFocusManager.getCurrentKeyboardFocusManager()
> .addKeyEventDispatcher(new
> KeyEventDispatcher(){
>public boolean dispatchKeyEvent(KeyEvent ke){
>if(ke.getID() == KeyEvent.KEY_RELEASED)
>{
> if(((KeyEvent) ke).getKeyCode() ==
> KeyEvent.VK_PRINTSCREEN)
>{
>System.out.println("print screen");
>
> oolkit.getDefaultToolkit().getSystemClipboard().setCon
> tents(new DummyImage(new
> ImageIcon("test.gif").getImage()), null);
> }
>
>return false;
>
>});
>
>class DummyImage implements Transferable
> {
>private Image image;
> public DummyImage(Image img){image = img;}
> public DataFlavor[]
> getTransferDataFlavors(){return new
> DataFlavor[]{DataFlavor.imageFlavor};}
> public boolean isDataFlavorSupported(DataFlavor
> flavor){return
> DataFlavor.imageFlavor.equals(flavor);}
> public Object getTransferData(DataFlavor flavor)
> throws UnsupportedFlavorException, IOException
>{
> if (!DataFlavor.imageFlavor.equals(flavor)){throw
> new UnsupportedFlavorException(flavor);}
>return image;
>
>}
> public static void main(String[] args){new
> Testing().buildGUI();}
> }
>
I will try that
Why dont you people use some assembly executables and embed it into your code? Is it possible in Java to embed something like SYSTEM (disable.exe)?
Oops my bad!
Not yet ready to dive into JNI. (whatever the hell it is). But as you suggested, it is possible.
Thanks.
> Oops my bad!
>
> Not yet ready to dive into JNI. (whatever the hell it
> is). But as you suggested, it is possible.
>
And as already pointed out, it won'd matter one iota whether you do it or not.
People are resourceful, and will find a way around it.
In the meantime they'll be mightily annoyed and blacklist you for any future business.
> > yes it sure is. using JNI.
>
> I'm glad it only took about 20 posts for this to come up.
I was hoping it wouldn't come up at all. *Shudder*
> I was hoping it wouldn't come up at all. *Shudder*
yea like i said: "(you could try) and you would be foolish to."
Actually this reminds me of a time in college when a friend of mine
was bragging that his band was streaming their music on Real
player so that no one could download it and steal it.
While he carried on and on I recorded the sound card's "what you hear"
channel and in 3 minutes i had his stupid song emailed to him.
Moral: you're never as clever as you think. let people do what they will.