Question about generate key press event to system. help plz.

I am wondering if it is possible to write a java program to generate key press event(not receiving)to the local system so all the other program in the system receive those key press event also. Thanks.

Hi,
:. I don't know what exactly you intend to accomplish. But, I have used the following code in order to simulate keys pressing inside a Java application.
      /* - - - Simulates TAB (java.awt.Event)
      EventQueue evtq = Toolkit.getDefaultToolkit().getSystemEventQueue();
      evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_PRESSED,
                      0, 0, KeyEvent.VK_TAB, KeyEvent.CHAR_UNDEFINED) );
      evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_RELEASED,
                      0, 0, KeyEvent.VK_TAB, KeyEvent.CHAR_UNDEFINED) );
      /* - - - Simulates Shift+TAB (java.awt.Event)
      evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_PRESSED, 0,
                      InputEvent.SHIFT_DOWN_MASK, KeyEvent.VK_TAB,
                      KeyEvent.CHAR_UNDEFINED) );
      evtq.postEvent( new KeyEvent(this, KeyEvent.KEY_RELEASED, 0,
                      InputEvent.SHIFT_DOWN_MASK, KeyEvent.VK_TAB,
                      KeyEvent.CHAR_UNDEFINED) );:. However, as far as I know to send keys to the whole OS you have to create a 'Hook' as described inside Win32API documentation. That's for Microsoft Windows naturaly.
Cheers.
Roque

Similar Messages

  • How to detect space key pressed event

    I am working on a japplet where it is needed to pause the applet on the occurrence of a space bar key pressed event can anybody help
    thanks in advance

    Have a look at the tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
    http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html
    -Puce

  • Raise Key pressed event

    Hello, any know how can I raise a key press event throw code. For example I want to simulate that the user has press the A Key. How can I do that throw code?
    Thanks a lot !!

    Hi there,
    Your question has been discussed previously in the forums. Sounds like you want to programmatically click a button in WPF.
    Please check out this post
    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1329603&SiteID=1
    Thanks,
    Jennifer

  • Unable to receive Tab key press event

    Hello,
    I have written a component which extends JComponent.
    For that , when Tab key is pressed I need to process something.
    I have overridden the function processKeyBinding in my class.
    But I am not getting any event for tab key press. For all the other key press events, the function is being called.
    I also tried to create a action and add it to the action map. But that is also not working.
    Can anyone explain me why it is not working and give me the solution.
    Thanks in advance,
    Anu

    public static void removeTabFromFocusTraverval(Component c) {
         int id = KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS;
         Set strokes = c.getFocusTraversalKeys(id);
         Set newStrokes = new HashSet(strokes);
         newStrokes.remove(KeyStroke.getKeyStroke("TAB"));
         c.setFocusTraversalKeys(id, newStrokes);
    }

  • How to binding a key press event of "Esc" to "cancle" button

    I create a class extended JComponent. Than I add a button named "cancle " to it.
    Than I add the class's instance to a JDialog object.
    I try to get the key press event through add a keyListener to the class instance, but no works.
    I try to add a keymap and action map to the dialog 's getRootPane() also no works.
    Who can tell me how can I do?

    Thats the way I did it:
        // map escape key
        ActionListener escapeActionListener = new ActionListener()
          public void actionPerformed(ActionEvent e)
            cancelPressed();
        this.registerKeyboardAction( escapeActionListener,
                                     KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0, false),
                                     JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );

  • How to handle form close event or escape key press event for user defined f

    Experts,
    Please let me know how to handle form close event or escape key press event for user defined form...
    Thanks & Regards,
    Pravin.

    Hi
    You can catch the form close event like this
    If ((pVal.FormType = 139 And (pVal.EventType = SAPbouiCOM.BoEventTypes.et_FORM_CLOSE)) And (pVal.Before_Action = True)) Then
          Try
                   SBO_Application.SetStatusBarMessage(pVal.EventType.ToString())
          Catch ex As Exception
                    SBO_Application.SetStatusBarMessage(ex.Message)
            End Try
          End If
    Hope this helps
    Regards
    Arun

  • Can we fire key press event programmatically????

    hi there,
    is it possible in java to fire a key press event (of the associated component) programmatically??? like we can fire action event of a button by saying
    button.doClick();
    thanks in advance.
    anshu

    You can do so by using awt.Robot.keyPress(), just don't forget to do awt.Robot.keyRelease() afterwards!
    Note that it doesn't work for Applets unless you sign them, for security reasons (you don't want to go into a site and have the applet click ctrl+alt+del for you, right?)
    Cheers!
    Moti

  • Key pressed event

    I need message to be displayed when certain key pressed. Why it's not working?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class TestKey extends JPanel implements KeyListener {
         public TestKey(){
              addKeyListener(this);
         public static void main(String arg[]){
               JFrame frame = new JFrame();
                  frame.setTitle("Test my keybord, man!");
                  frame.setSize(300, 200);
                  frame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent e) {
                      System.exit(0);
                  Container contentPane = frame.getContentPane();
                  contentPane.add(new TestKey());
                  frame.setVisible(true);
         public void keyPressed(KeyEvent ke){
              System.out.println("key pressed");
         public void keyTyped(KeyEvent ke){
              System.out.println("key typed");
         public void keyReleased(KeyEvent ke){
              System.out.println("key released");
    }

      public TestKey(){
        setFocusable(true);//<----------
        addKeyListener(this);
      }

  • Key Press Events

    Hi there,
    Im relatively new to java and need to implement a program which listens for a key press e.g. say the letter "n" and then performs an action, Is there a simple way to do this?
    I've found some stuff on the web about the KeyListener class but i don't understand it very well.
    Im wanting a solution which does this in the simplest way possible, any help you can give me would be greatly appreciated.
    Cheers

    yeh thats probly a good idea lol basically:
    I have this system using a virtual reality suite at my university, on the 3 large screens in the suite i have some background images of different environments. The backgrounds are displayed using media player classic, one media player for each screen, left, mid and right. I have a web page which is connected to the media players which when refreshed changes to the next item in the playlist (in the media players) so all 3 players "change scene" at the same time.
    Now my java program currently sends a refresh to this web page which in turn changes the background on the 3 screens. at the same time the program uploads an image onto the backgrounds at given co-oardinates. What im wanting next and am struggling with is for the image to be uploaded and the backgrounds to change when i press a key an for this to be repeated everytime i press that same key.
    This way i can cycle through all the different backgrounds with a simple keypress.

  • How to change a h:outputText value in the current form on key pressed event

    Hello Suners,
    Greetings! I'm developing my first JSF web application and i'm trying to figure a way out to change outputText value when key pressed on another inputText so that when the user is typing his name for example he can see the letters showing respectively in the outputText.
    I managed to do it onchange but the user must focus out of the inputText to see his name in the outputText which is not right and the form must submit onchange event which is annoying.
    <h:inputText value="#{login.username}" title="name" id="name" required="true" onchange="this.form.submit()" >
                                <f:validateLength maximum="10" minimum="1"/>
                                <f:validator validatorId="myValidator"/>
                                <f:valueChangeListener type="classes.MyListener"/>
    </h:inputText>Is there any listener i can associate with the "onkeypress" attribute? Can anyone help me to do that with JSF?
    King Regards,

    hi, with JSF 2 you got the ajax tag, just tried it and it works fine :)
    <h:inputText id="myinput" value="#{back.name}">
        <f:ajax execute="@this" event="keyup" render="outtext"/>
    </h:inputText>
    <h:outputText id="outtext" value="#{back.name}"/>or before JSF 2
    <h:outputScript name="jsf.js" library="javax.faces" target="head"/>
    <h:inputText id="myinput" value="#{back.name}" onkeyup="jsf.ajax.request(this, event, {render: 'outtext'}); return false;"/>
    <h:outputText id="outtext" value="#{back.name}"/>The name property is a simple String in the bean.
    Hope this helps
    Edited by: hereps on Aug 21, 2010 7:18 AM

  • Some basic questions about foriegn key , and relationships.

    Hi
    Thank you for reading my post
    I read some documents about foreugn key and tables relation ships.
    but i still can not understnad some stuff.
    1-when we have a foreign key , we have two tables that we want to relate them together
    in a way that one of ? table columns forced to be a value from ?? table column.
    what is name of those two tables , i saw , child-parent , ..... which confuse me.
    can some one please tell me correct name of those two tables ?
    2-some times we need some kind of master details relation like :
    one-to-many : i this case MANY table will have a column to point a record in ONE table , can this relation be a foreign key relation ?
    3-we can achieve many-to-many relation only by using a helper table to host both tables primary keys in a record to relate them together.
    can you point me to some resources that help me to find answers to this questions ?
    or explain them to me ?
    thank you for your time.

    These are critical database basics that you need to understand. I would seriously recommend getting some study in, because proper relational database design relies on the basic principle of data and relationships and a process called normalization.
    In reality, you only really need one gigantic table to host data. It would include everything you would want to know about something - let's take a sales order for example. You would have to record the customer's name, address, etc. along with every item they ordered, etc. You would have a HUGE table full of data that appeared over and over and over again. This is bad design for two basic reasons: it is difficult to query, and it is very easy to have minor mistakes like capitalization or alternate spellings that prevent things from matching up properly. For example, let's say Bob orders 40 widgets and 40 digits. In our hypothetical table, we could put it in as Bob - 40 widgets and Robert - 40 digits. See how confusing this can get even in a simple example? And let's say you wanted to correct all of Robert's orders to say Bob and you found out there were 40 orders from "Robert" How would you know which ones to change?
    The process of normalization helps to reduce the chance for these types of errors in addition to creating a good basis for indexes. You normalize the data by creating sets of parent/child tables with a "key" value to match them. In our hypothetical situation, you could create a table for orders and a table for customers. In the customers table you give all the detail for the customer in one place, and you assign each customer a unique number or ID. In the orders table we add the customer ID (NOT the name) and we ensure that we are getting the customer we want, in addition to saving a lot of space and eliminating redundancy. In our example, the customers table is the "parent" table and the orders table is the "child" table. The child table references the unique entries in the parent table via that id. That reference is referred to as a foreign key. The foreign key in the child table points back to the original and complete record in the parent table and eliminates the redundancy of keeping all that extra data for every order. Foreign keys in child tables always refer to a primary/unique key in the parent field.
    That help?

  • A question about foreign key to multiple tables

    Hello everybody,
    I have a question about creating foreign key and I would appreciate if you could kindly give me a hand. Here are my tables:
    CREATE TABLE TEAM1(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM1 ADD CONSTRAINT PK_TEAM1 PRIMARY KEY(team_id);
    CREATE TABLE TEAM2(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM2 ADD CONSTRAINT PK_TEAM2 PRIMARY KEY(team_id);although the structure of both the tables is exactly the same, the values (in particular team_id) in both tables are different.
    Also I have another table named AGENT
    CREATE TABLE AGENT(agent_id VARCHAR2(20), team_id VARCHAR2(20));
    ALTER TABLE AGENT ADD CONSTRAINT PK_AGENT PRIMARY KEY(agent_id)Now the problem is that the column team_id in AGENT table is actually a foreign key, but the value can be in either TEAM1 or TEAM2. As far as I know a foreign key points only to one table.
    How can I deal with this problem? Whenever there is an INSERT or UPDATE I have to make sure that the value of the column "team_id" in the table "AGENT" is a valid value either in "TEAM1" or "TEAM2"
    Thanks in advance,
    Kind Regards,
    Dariyoosh

    Do you have the ability to change the data model? If so a more appropriate structure may be something like this:
    CREATE TABLE TEAM(team_id VARCHAR2(20), team_name VARCHAR2(20));
    ALTER TABLE TEAM ADD CONSTRAINT PK_TEAM PRIMARY KEY(team_id);
    ALTER TABLE TEAM ADD CONSTRAINT UK_TEAM UNIQUE (team_name);
    CREATE TABLE TEAM_PROJECT(team_id VARCHAR2(20), project_id VARCHAR2(20));
    ALTER TABLE TEAM ADD CONSTRAINT PK_TEAM_PROJECT PRIMARY KEY(team_id, project_id);
    ALTER TABLE AGENT ADD CONSTRAINT FK_TEAM_PROJECT1 FOREIGN KEY (team_id) REFERENCES TEAM(team_id);
    CREATE TABLE AGENT(agent_id VARCHAR2(20), team_id VARCHAR2(20));
    ALTER TABLE AGENT ADD CONSTRAINT PK_AGENT PRIMARY KEY(agent_id);
    ALTER TABLE AGENT ADD CONSTRAINT FK_TEAM FOREIGN KEY (team_id) REFERENCES TEAM(team_id);Edited by: Centinul on Jun 25, 2010 10:50 AM

  • Key Press Event

    I have been pouring through the TLF API docs looking for
    events to handle key presses on a TextFlow and I am not finding
    anything. I'm sure it's simple, can anyone give me a clue? I'm
    looking to detect Ctrl+B, Ctrl+I, etc.. to trigger formatting.

    The events go to the DisplayObjectContainerController. You
    will want to override the processKey event functions to add special
    handling. Those are in the protected methods section and are
    inherited from a base class.

  • Capture key press events with ExtendScript?

    Is it possible to do this?  I can't find an example in the documentation or online anywhere.  I'd really like to know when the user presses the arrow keys while viewing the slideshow in Bridge.
    Thanks!

    Thanks for the example Paul.  I can see how to listen to key down events on Windows and Dialogs that I create.  Do you know of way to listen for global (app-wide) key down events? These are not defined:
    app.addEventListener('keydown',...)
    app.document.addEventListener('keydown',...)
    I'm trying to add to the slideshow mode by having a little palette dialog with the context information shown that I need.  The default caption box doesn't have what our artists want.  If the palette window is in focus, I get the keydown event, but if they're using the arrow keys to flip through the slideshow, I can't capture those.
    Thanks for the help.

  • Make Tab Key Press Event

    Hi You all,
    I'm trying to make an automatic Tab Key Press after fill some data to oEditText  , plz guide me how can i do that ?
    I will appreciate your help.
    Peter.
    Edited by: PeterHoang on Oct 12, 2011 12:22 PM

    Hi
    You can use sendkeys method for this
    SBO_APPLN.SendKeys("{TAB}")
    Regards
    Arun

Maybe you are looking for

  • N73 paired devices keep asking for passcode

    Hello all, Everytime when a paired bluetooth device tries to connect to my Nokia N73, the phone asks for the Passcode (0000). It even happens when I authorize those paired devices. I use these BT devices: - Nokia BT carkit - Tom Tom Go 710 - SE Bluet

  • Reg: IDOC to file for PEXR2002

    Hi folks, Here my scnario is once fund transfer happend idoc are generated. I have to pick the generated idocs and transfer to a file. I have done the configuration and design. But after the idoc is generated it is not transfered to XI system how can

  • Selecting in CS5 illustrator

    Hi, I have upgraded to CS5 from 10 and am finding it a little less behaved, for me, my fault i"m sure. I am having the wierdest time copying and pasting the actual drawing into ID CS5 without a huge surrounding box which is awkward and bothersome. Wh

  • Is there "Shuffle mode" in L8 like in PT ?

    HI, I am the new in L8, work with PT HD everyday, I wonder if there is something like +Shuffle mode+ of PT in L8 and where can I find it. Thanks for your help.

  • How do I lodge a complaint about Apple Care server support?

    I'm having a nightmare time with my year old OS X 2.2.1 server (Postgres has recently started crashing and taking down Wiki when it does so, for no apparent reason), and called Apple Support in the UK.  They were totally unhelpful - refusing to engag