Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

How to copy to clip board

  Asked By: Conrad    Date: Jun 10    Category: Java    Views: 610
  

I want to copy some text to the clipboard when the user presses a
specific sequence on the keyboard and then populate the document the
user is working on with a pre-defined paragraph.

for example -
if the user presses [ =tst ] in a notepad it should automatically type

This is a test for a great program which is going to reduce typing!

And also this should work with any program not only notepad but could
be Word or any other program that has a text area to type anything in.

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Cadencia Bernard     Answered On: Jun 10

As far as the prep of the clipboard  goes here is some sample code:

import java.awt.datatransfer.* ;
import java.awt.Toolkit ;

// prep the selected signature for the clipboard
StringSelection content = new StringSelection ("test") ;
Clipboard test  = Toolkit.getDefaultToolkit().getSystemClipboard() ;

// copy  the selected signature into the systems clipboard
test.setContents(content,null);

As far as the other staff goes someone else has to help you. But it sounds as if
the keys
that you type need to be scanned by the java program  first and then inserted
into the
program (notepad, word, or whatever). Sounds like a while loop to me... But I
would think
it decreases performance a bit...

 
Answer #2    Answered By: Patty Freeman     Answered On: Jun 10

Ur saying like macros but application independent Iam i right?

 
Didn't find what you were looking for? Find more on How to copy to clip board Or get search suggestion and latest updates.




Tagged: