Simulate Key Event " "

Does anybody know how to simulate keys that are only available while holding down the shift key? I have a VI that is based on an API that simulates key events, including the shift key. It works great. But I do not know how to get characters, such as ">", that are combinations of the shift key. It seems to me that just sending the code for the shift key and then the code for "." generates two events and only results in the "." since the shift key was not kept down... Any help in this issue is very welcome!! Thanks! /Mikael (LV 6.1)

Look up an ASCII chart. The ASCII code for ">" is 62. There is a "keybd_event" function inside user32.dll. It's syntax is:
void keybd_event(unsigned char bVk, unsigned char bScan, unsigned long dwFlags, unsigned long dwExtraInfo);
Use the Call Library Function Node to call this function. Wire the ASCII code (62) to the first U8 input, and 0 to the next three inputs. This simulates the key being pressed. Then pause for a few milliseconds. Then call the function again, wire the ASCII code to the first U8, wire 2 to the first U32, wire 0 to the other U8 and U32. This simulates releasing the key. You can simulate any keystroke by using this function and the ASCII code. You must use it twice, once for key down and once for key up.
- tbob
Inventor of the WORM Global

Similar Messages

  • Simulate arrow key events in labview

    Hello,
    I am trying to simulate the arrow key events (left, right, up & down) in labview. Lets say I would like the events to happend when a slider bar goes beyond a certain threshlold (later I will inteface it with a daq).
    I found this example but, I can not figure out how to move the arrow keys (and I have not experiance with the User32.dll):
    http://zone.ni.com/devzone/cda/epd/p/id/3711
    I would really appreciate the help.
    Many thanks
    Solved!
    Go to Solution.

    Hi,
        I need to get multiple-key-press of arrow-keys. i.e., if I press Up-Arrow-Key, keep hold it down, while being pressed down press Left-Arrow-Key and keep it pressed(now both keys are pressed First: Up, Second: Left). Now my requirement is I need to get the following sequence of Key-Values -
    Up-Key, Left-Key, Up-Key, Left-Key, Up-Key, Left-Key ...etc., 
    as long as both keys are kept dow.
    -Any help is appreciated
    -Beginer

  • How to generate key events to a componet without keyboard

    I want to generate a key event, a Keylistener is already there, (in fact, java3D's KeyNavigatorBehavior). I want to use other input methods instead of key pressings, so how I generate the key event manually
    thx,

    Look at java.awt.Robot. It has a keyPress() method to simulate key presses.

  • Simulation of Key events ????

    Hello there,
    I would like to simulate a succession of pressed key events in order to trace the mem. allocations of a midlet under constant setup.
    How could I trigger those events from my application ? which low-level method should I called ?
    I tied to found myself in the API and also to 'google' for a solution, but so far it wasn't successful....
    Any idea will be welcome !
    Thanks

    Hi khsay!
    If you are using Windows as OS you can never get your application to run in realtime, you have to use LV Realtime to do that.
    If you use the event structur i a while loop you get as close as possible, i think.
    I have modified your caps.vi so it reacts on booth CAPS button and CAPS key on the keyboard.
    Hope this helps!
    Regards
    /Thomas
    Attachments:
    caps[1].vi ‏41 KB

  • Send a press key event without Batch Input?

    Hi.
    I need send a auto press key event (by example: press F8), by code.
    When I put a instruction in the report, the report simulate the key pressed.
    Exist some FM to do it? Is it posible?
    Thanks!

    Hi Marcos,
    you can use the method I recommended in an additional timer object method .
    Please adapt the below sample program I used to display the current time with auto update:
    *& Report  ZZCLOCK
    *& may be used to keep connection
    REPORT  zzclock.
    *       CLASS lcl_gui_timer DEFINITION
    class lcl_gui_timer definition inheriting from cl_gui_control.
      PUBLIC SECTION.
        CONSTANTS:  eventid_finished TYPE i VALUE 1 .
        CLASS-DATA: interval TYPE i VALUE '0'.
        EVENTS:     finished .
        METHODS:
                 cancel
                      EXCEPTIONS
                         error,
                 constructor
                     IMPORTING
                         lifetime TYPE i OPTIONAL
                         value(shellstyle) TYPE i OPTIONAL
                         value(parent) TYPE REF TO cl_gui_container OPTIONAL
                     EXCEPTIONS
                         error,
                 run
                     EXCEPTIONS
                         error,
                 dispatch REDEFINITION.
    ENDCLASS.                    "lcl_gui_timer DEFINITION
    *       CLASS lcl_event_handler DEFINITION
    CLASS lcl_event_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
                    on_finished
                           FOR EVENT finished OF lcl_gui_timer.
    ENDCLASS.                    "lcl_event_handler DEFINITION
    DATA: gui_timer TYPE REF TO lcl_gui_timer.
    DATA: event_handler TYPE REF TO lcl_event_handler.
    DATA: timeout_interval TYPE i VALUE '9'.
    PARAMETERS:
                p_datum TYPE sy-datum,
                p_uzeit TYPE sy-uzeit.
    AT SELECTION-SCREEN OUTPUT.
    * set to time rounded to 10 seconds
      p_datum = sy-datum.
      p_uzeit = sy-uzeit.
      CREATE OBJECT gui_timer.
      SET HANDLER event_handler->on_finished FOR gui_timer.
      gui_timer->interval = timeout_interval.
      CALL METHOD gui_timer->run.
    *       CLASS lcl_event_handler IMPLEMENTATION
    CLASS lcl_event_handler IMPLEMENTATION.
      METHOD on_finished.
    * Start Timer again
        gui_timer->interval = timeout_interval.
        CALL METHOD gui_timer->run.
    * cause PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = 'REFR'.
      ENDMETHOD.                    "on_finished
    ENDCLASS.                    "lcl_event_handler IMPLEMENTATION
    *       CLASS lcl_gui_timer IMPLEMENTATION
    CLASS lcl_gui_timer IMPLEMENTATION.
      METHOD constructor.
        TYPE-POOLS: sfes.
        DATA clsid(80).
        DATA event_tab TYPE cntl_simple_events.
        DATA event_tab_line TYPE cntl_simple_event.
        IF clsid IS INITIAL.
          DATA: return,
                guitype TYPE i.
          guitype = 0.
          CALL FUNCTION 'GUI_HAS_OBJECTS'
            EXPORTING
              object_model = sfes_obj_activex
            IMPORTING
              return       = return
            EXCEPTIONS
              OTHERS       = 1.
          IF sy-subrc NE 0.
            RAISE error.
          ENDIF.
          IF return = 'X'.
            guitype = 1.
          ENDIF.
          IF guitype = 0.
            CALL FUNCTION 'GUI_HAS_OBJECTS'
              EXPORTING
                object_model = sfes_obj_javabeans
              IMPORTING
                return       = return
              EXCEPTIONS
                OTHERS       = 1.
            IF sy-subrc NE 0.
              RAISE error.
            ENDIF.
            IF return = 'X'.
              guitype = 2.
            ENDIF.
          ENDIF.
          CASE guitype.
            WHEN 1.
              clsid = 'Sapgui.InfoCtrl.1'.
            WHEN 2.
              clsid = 'com.sap.components.controls.sapImage.SapImage'.
          ENDCASE.
        ENDIF.
        CALL METHOD super->constructor
          EXPORTING
            clsid      = clsid
            shellstyle = 0
            parent     = cl_gui_container=>default_screen
            autoalign  = space
          EXCEPTIONS
            OTHERS     = 1.
        IF sy-subrc NE 0.
          RAISE error.
        ENDIF.
        CALL METHOD cl_gui_cfw=>subscribe
          EXPORTING
            shellid = h_control-shellid
            ref     = me
          EXCEPTIONS
            OTHERS  = 1.
        IF sy-subrc NE 0.
          RAISE error.
        ENDIF.
    * Register the events
        event_tab_line-eventid = lcl_gui_timer=>eventid_finished.
        APPEND event_tab_line TO event_tab.
        CALL METHOD set_registered_events
          EXPORTING
            events = event_tab.
      ENDMETHOD.                    "constructor
      METHOD cancel.
        CALL METHOD call_method
          EXPORTING
            method     = 'SetTimer'
            p_count    = 1
            p1         = -1
            queue_only = 'X'
          EXCEPTIONS
            OTHERS     = 1.
        IF sy-subrc NE 0.
          RAISE error.
        ENDIF.
      ENDMETHOD.                    "cancel
      METHOD run.
        CALL METHOD call_method
          EXPORTING
            method     = 'SetTimer'
            p_count    = 1
            p1         = interval
            queue_only = 'X'
          EXCEPTIONS
            OTHERS     = 1.
        IF sy-subrc NE 0.
          RAISE error.
        ENDIF.
      ENDMETHOD.                    "run
      METHOD dispatch .
        CASE eventid.
          WHEN eventid_finished.
            RAISE EVENT finished.
        ENDCASE.
      ENDMETHOD.                    "dispatch
    ENDCLASS.                    "lcl_gui_timer IMPLEMENTATION
    Hope that's what you are looking for. I got the idea from a project where they used it to auto refresh an ALV grid...
    You may also search this forum for keywords timer or autorefresh. It has been discussed here earlier.
    Regards,
    Clemens

  • Macbook misses some key events for a few seconds

    I have noticed that for last two months or so something strange happens to my Retina MBP. Once in a couple of days it stops responding to some key events. It is like it handles only one keypress out of 4-5. Nothing seems to be wrong with the keyboard and it is not about a particular key or keys. And about 10-15 seconds later everything goes back to normal. I do not see any suspicious messages in the logs, the computer is connected to the power supply...It happens just by itself in the middle of the day, when I am typing.
    Almost looks like some interrupts get lost by the system while it is busy with something else. But I have checked the load level and running processes - nothing interesting there....And whatever it is - it happens during a very short period of time.

    Hi,
    No, I have not returned my MBP yet. In fact, I would rather avoid doing this unless I am convinced if it is a hardware issue. And I do believe it is not. Just recently I have spent some time investigating it and I have found very stroing correlation between the moments when this happens and these messages in the kernel log:
    Jan 13 10:49:54 mbp-wifi kernel[0]: Sandbox: sandboxd(96471) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi kernel[0]: Sandbox: sandboxd(96499) deny mach-lookup com.apple.coresymbolicationd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96497]): mdworker(96497) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:54:31 mbp-wifi.home sandboxd[96499] ([96498]): mdworker(96498) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96503]): mdworker(96503) deny mach-lookup com.apple.ls.boxd
    Jan 13 10:56:32 mbp-wifi.home sandboxd[96504] ([96502]): mdworker(96502) deny mach-lookup com.apple.ls.boxd
    And I have also noticed that my Spotlight database gets reconstructed too often, which means it gets corrupted.
    From all this I conclude that it is most likely the software issue and it seems to be linked to spotlight. I saw people reporting similar things. So now I am researching on how to fix it without disabling the spotlight.
    In general, I believe that the quality of Apple software is going down, it is not like 4-5 years ago And Apple does seem to care less and less about it.
    If in your case it happens all the time, not just once in a while, and you see that a particular key has problems - it is possible that we are talking about the different issues and yours might be really about the keyboard.

  • Detect key events on anything

    If I have a JFrame with many components on it, how do I detect if a key is pressed, without having to add a listener to every component? For example, how can I check for the escape key being pressed, but not having to have componentN.addKeyListener(this); for everything?
    Thanks
    US101

    The correct way to collect the key events is the following:
    from java 1.2 to java 1.3 use the FocusManager. This class can be found in the javax.swing package. You would then need to extend the DefaultFocusManager and override specific behavior.
    for java 1.4 use the KeyBoardFocusManager. This class can be found in the java.awt package.
    Please see the following for a better explanation:
    http://java.sun.com/j2se/1.4/docs/api/java/awt/doc-files/FocusSpec.html
    Thanks for your time,
    Nate

  • Catching key events in application

    I have a JFrame with a JDesktop containing lots of JInternalFrame with various of components such as JTextFields etc.
    Now, i want to have a "main" listener that will catch key events no matter which component that has focus. For example pressing CTRL+A should produce something in the application no matter which component that has focus.
    How do I implement this in an easy way?

    It doesnt seem to work to add a KeyListener to the JFrame...
    this.addKeyListener(new KeyAdapter(){
                   public void keyTyped(KeyEvent e){
                        System.out.println("KeyTyped()");
                   public void keyPressed(KeyEvent e){
                        System.out.println("KeyTyped()");
              });Adding that to the JFrame gives nothing to System.out when a JTextArea inside an JInternalFrame has focus.

  • Associating key events to a TextBox

    Hello All!
    Can anybody tell me how to associate key events with a TextBox? Something like when a certain key is pressed and released, a certain combinations of characters is inserted e.g. =-)
    I am trying to develop a simple application that allows users to type text with non-English characters, e.g. Russian and for that I have created a canvas and I am using key events i.e. KeyPressed and KeyReleased methods. Using a canvas is a bit insufficient because users cannot move the cursor freely through the text.
    I have read on te web that I can create a CustomeItem and override the KeyPressed methods but I could not do it; I could not find any simlar code example.
    Can anybody help me by providing me with a simple example or suggesting me an alternative way?
    Many thanks in advance

    {color:#008080}*Hello again!*
    I managed to create a CustomItem that overrides KeyPressed method, but now I am having difficulties making my textBox reacts to my keyPressed method.
    The early version of this CustomeItem overrides the KeyPressed method by assigning each key to a certain collection of chars. When a key is pressed, a string of these chars is drawn on the Canvas, which works fine. Now because I want to be able to edit the text, e.g. delete a certain char in the middle of the string, I want to use a TextBox or a TextField. The current problem is that my TextBox does not react to my key presses the way I want (I used setString() method); it reacts to the original key presses which print the original chars (from A through to Z and 1 through to 9).
    Is it possible to set the contents of a TextBox or TextField depending on my key presses? Could you suggest me an alternative way?
    Many thanks in advance!!{color}

  • Object Movement with Key Events

    Hi everybody!
    Im trying to move an object over the screen with keyboard buttons. The problem I have come across with is that I would like to use the right button to move right, up button to move forward, etc. but I cant push, for example, right and up buttons at the same time to make a diagonal movement. How can I solve this?
    Thank you and regards.

    I added key events to a sequence and than check them in the program.
    Something like this:
    class Car extends CustomNode {
        var keys:KeyCode[];
        public override function create(): Node {
            ImageView {
                transforms: [ Translate{ x: bind x, y: bind y }, Rotate{ angle: bind direction}]
                x: -w
                y: -h
                image: Image { url: "{__DIR__}car.png"}
                onKeyPressed: function( e: KeyEvent ) {
                    insert e.code into keys;
                    if(e.code == KeyCode.VK_UP){
                        ds = 2.0;
                    }else if(e.code == KeyCode.VK_DOWN){
                        ds = -2.0;
                    }else if(e.code == KeyCode.VK_LEFT){
                        da = -1.0;
                    }else if(e.code == KeyCode.VK_RIGHT){
                        da = 1.0;
                onKeyReleased: function( e: KeyEvent ) {
                    delete e.code from keys;
        public function move(){
              // check keys
    }

  • KEY events in MIDlets

    Hello all,
    I am basically new to J2ME MIDP development and also new to this
    forum. So apologies if this has already been covered or turns out to
    be a stupid question :) Here goes:
    I am trying to develop a MIDlet where I have a Form to accept certain
    values from the user. This is fairly straightforward and is easy to
    create with the high level Form a and TextField objects.
    Now, I wish to add a functionality to my MIDlet, in which, the user
    can press a specific key.. say the "Select" key or the "Call" key.. at
    any time during the form to start another thread of operation which
    performs something totally different... say for example, the user is
    entering values into the form and in between somewhere he presses this
    specific key and the phone start playing music. I hope you get my
    point.
    Basically I want to listen for key pressed or key held events on a
    Form object. Now I understand that Key events can be found only on the
    low-level Canvas based UIs. So is it possible to do it with Screen class
    elements..?
    Thanks,
    Nik

    You can try to use a CustomItem. What events will be delivered to the custom item depends on the implementation, though. Also these events will be only delivered when the CustomItem is focused.
    Have a look at the J2ME Polish GUI for using CustomItems for MIDP/1.0 devices as well.
    http://www.j2mepolish.org
    Best regards,
    Robert

  • Binding Mouse and Key Events.

    Hi,
    When a user clicks the Ctrl + V the data from the clipboard
    is pasted into the user area. Instead of using this can we do it
    using a mouse click. For now, I am planning to bind the event code
    of these combinations (CTRL + V == 86) to the mouse click. But when
    I tried this I am unable to bind this key event to the mouse event.
    Can anyone help me out for getting out of this problem.
    Regards,
    eodC.

    No, it isn't.
    Kind regards,
      Levi

  • How to consume key events

    I would like to create a subclass of TextBox that only allows numeric input. My idea was to provide my own onKeyType() handler and consume any key events that do not correspond to digits. However, I can't find any way to consume key events from further processing. How do I do this?
    Are there any other suggestions how to accomplish the task of providing your own filter concerning valid key input?
    /Bengt

    I also wanted a kind of validators for the TextBox class of JavaFX. So I've tried solving the problem using the SwingTextField class and some Java APIs. The following is my code for a SwingTextField accepting only digits, but I do want it to be much simpler.
    import java.awt.AWTEvent;
    import java.awt.event.AWTEventListener;
    import java.awt.event.KeyEvent;
    import java.awt.Toolkit;
    import javafx.ext.swing.SwingTextField;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javax.swing.JComponent;
    class DigitKeyEventHookListener extends AWTEventListener {
        public-init var  source:JComponent;
        public  override function  eventDispatched( event:AWTEvent):Void {
            if (event.getSource().equals(source)) {
                var keyEvent : KeyEvent = event as KeyEvent;
                var keyCharacter = keyEvent.getKeyChar();
                var isDigit = false;
                var code = keyEvent.getKeyCode();
               if ((KeyEvent.VK_0 <= keyCharacter) and (keyCharacter <= KeyEvent.VK_9)) {
                       isDigit = true;
                if ((code ==KeyEvent.VK_DELETE) or (code ==KeyEvent.VK_BACK_SPACE)) {
                    isDigit = true;
                if ((code ==KeyEvent.VK_LEFT) or (code ==KeyEvent.VK_RIGHT)) {
                    isDigit = true;
               if (not isDigit) {
                    keyEvent.consume();
    function createSwingTextField() : SwingTextField{
        var field = SwingTextField {
            columns:12
        var listener =  DigitKeyEventHookListener{
            source: field.getJTextField()
        Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.KEY_EVENT_MASK);
        return field;
    Stage {
        title: "Digit Box"
        width: 200
        height: 80
        scene: Scene {
            content: createSwingTextField()
    }

  • No key event when compose keys are pressed

    I am supporting a legacy application for Sabre which maps some of the keys differently. For example, on a French keyboard the Compose key which is used to put a ^ on top of the vowel characters is to be remapped to produce a special character called a "Change Character" that has a special use for reservation agents that use Sabre
    The problem is, the first time you press the ^ compose key there is no key event apparently because the VM figures it doesn't yet know what key to report, it is expecting you to press a character such as 'o' and then you get an 'o' with a '^' on top of it.
    If you press the ^ compose key a second time, you get the following key events:
    keyPressed
    keyTyped
    keyTyped
    keyReleased
    On the screen you will see two ^ characters appear. Currently I remap the ^ character to the "Change Character", and I suppress the second keyTyped event so that I only get one character. The problem is that the user ends up having to press the key twice to get one "Change Character."
    I have no fix for this problem because there is no key event produced when they press the ^ compose key the first time.
    By the way, this behavior appears to have been introduced with jdk 1.3. The older jdk did produce a key event the first time you pressed the compose key. I would expect that this behavior was considered to be a bug and was fixed in jdk 1.3.
    Is there some other way to detect when the user presses a compose key? If not, is it possible for future jdk releases to report a keyPressed event when a compose key is pressed? This event would not cause a character to appear on the screen, but would allow programs to detect when the compose key is pressed.
    There is already a key on the French keyboard that behaves this way. It is the key to the left of the '1' key and it has the pipe symbol on it. If you press Shift plus this pipe key, no character is produces but a keyPressed event with a keycode of 222 is produced. I merely point this out to show that there is a way to report key events whithout producing output on the screen.
    Thanks, Brian Bruderer

    I don't know if this actually helps, but it seems that you can bind an Action to a dead key like the circumflex of the French keyboard
    Keymap keymap = textPane.addKeymap("MyEmacsBindings", textPane.getKeymap());
    Action action = getActionByName(DefaultEditorKit.beginAction );
    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_DEAD_CIRCUMFLEX);
    keymap.addActionForKeyStroke(key, action);I saw this on a Swing tutorial and modified it slightly. Have a look at it :
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Chris

  • 2nd JFrame at Full Screen not registering key events

    I've written an application that launches other applications distributed as JARs with a particular method (replacing the main method). These other applications run at full screen.
    Whilst I have got these other applications to work in that they display correctly and do everything else, I require them to register key events. If I run these applications on their own (i.e. having not been launched by the primary application) then the key events are processed correctly. However when they are launched from the primary application the key events are not registered.
    I have tried requesting focus from the full screen JFrame but it doesn't seem to be able to.
    Any ideas?

    Possible that the keystrokes are really being trapped by the other gui, which stops registering them when it's not visible.
    IF that's the case, you'll need to re-design your keyboard trap as part of the second JFrame, wholly independent of the original JFrame or originating app. Also, it may be thread-starved i.e. operating off the originating program, which thread may be stopping when it has no focus.
    That's all the ideas I have.

Maybe you are looking for

  • What happened to the Titanium in ThinkPad T Series? Bring it back!

    I have owned seven T series ThinkPads in my life, and I have converted to MacBook Pro. Why has Lenovo removed the titanium from the T61? IBM had named the T series for its titanium. That is where the T had come from. They have said that they have rem

  • WEP Password

    Bought a new Mac Book Pro yesterday, unpacked and set it up. All things working except for connecting to my wireless router. Airport picks up the wifi network (let's call it SAM) but does not connect to it. I get a "password failed" message. SAM is w

  • Update table on a linked server

    I am creating a SP on server WDC1GISDBP2, I need to update a table on WDC1GISDBP3 (edtables is the database).  Both servers are running SS 2008r2 This is the error kicked back: Msg 102, Level 15, State 1, Line 4 Incorrect syntax near ';'. This is the

  • Is this training still valid for Flash Builder 4.7?

    Flash Builder 4 and Flex 4 Essential Training with David Gassner Watch the Online Video Course Flash Builder 4 and Flex 4 Essential Training this was made in 2010 I am interested in learning about Flash Builder but I know that you want to be current,

  • Flash Slide Show Problem

    Hi all, I have searched everywhere for a solution, but can't find one. I am hoping someone can help. I am not an experienced user with Flash and decided to create a presentation. There is no interaction, just a movie with text and music. I started ou