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
Similar Messages
-
Generate Key Events without pressing key???
Hi,
Is it possible to generate key events without pressing a key in swing???
i dont know if the question is logical or not, but just i want to generate some display as if the key is pressed by the user
Ashishassuming c represents a text field.
This will type the character 'a' in the text field:
c.dispatchEvent( new KeyEvent (c, KeyEvent.KEY_TYPED, 0, 0, KeyEvent.VK_UNDEFINED, 'a') );
This will invoke Ctrl+F1, which will show the tool tip for the text field:
c.dispatchEvent( new KeyEvent (c, KeyEvent.KEY_PRESSED, 0, KeyEvent.CTRL_MASK, KeyEvent.VK_F1) ); -
Getting key events without a jcomponent...
Is it possible to get key events without adding a keylistener to a jpanel? I want a class of mine to manage input of it's own, but it has no reference to a jpanel. They don't necessarily have to be KeyEvents, but just some way to detect if a key has been pressed (like the arrow keys). How can I do this? Thanks.
Lots of components can listen for key events.
What does your class subclass?It doesn't subclass anything. I am creating a custom menu system for my game using images I have made for the tileset. I would like it to handle some keyboard events of its own. (Like if the down arrow is pressed, it will move the focus down to the next component on its own). Right now I am currently passing the key events from my fullscreen jpanel to the menu class and it is handling them that way. Thanks. -
How to listen a key event without having any window component
Hi all,
I would like to know how can I listen key events from an application that doesn't use windows
Thanksyoiu can make a Thread run inside your application. This will listen for inputs in the command line. For examplethis is part of a chat server (on the console) with let the server manager to enter messages or commands.
The message or command entered on the console by the user is catched and processed as a String. The string is passed to the processConsole() method, you must define yourself.
Th Thread is never stopped, so the user may enter any message at any time
The core of you application should also be a Thread for better performance, but maybe it will also work without. Jst try and provide needed importstatements.
Runnable runInput = new Runnable() {
public void run() {
while(true) {
try {
byte buffer[] = new byte[255];
System.out.print(prompt);
System.in.read(buffer);//, 0, 255);
String inputString = new String(buffer, "Default");
processConsole(inputString);
catch(NullPointerException npe) {
System.out.println("Syntax error");
catch(Exception e) {e.printStackTrace(); }
Thread inputThread = new Thread(runInput);
inputThread.start(); -
Lag on key press (key event)
Hello, I am currently working on a simple game in Java. I've used Java's Key_Pressed in Key Event to control a ship moving back and forth with the up and down keys. I've noticed that when a key is pressed there is a short pause before the ship actually moves. What can I do to avoid this pause?
The "repeat rate" for holding a key down is controlled by the OS.
You should not be relying on multiple KeyEvents to move your component as the repeat rate will vary from machine to machine. Actually you should not be using KeyEvents anyway you should be using [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html]Key Bindings
On keyPressed binding you would start a Timer and then on keyReleased you stop the Timer. You can then control the interval at which the Timer fires so you game will be consistent on all machines. -
Surprising behaviour ..key pressed key event
Hello,
I am experiencing a supprising event key press issue. I have written below code in which my code getting called even though I didnt press any of the key,
_entryPane.getTextArea().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
doSendTypeStatus();
if(e.getKeyChar()==KeyEvent.VK_ENTER) {
if(e.isControlDown()) {As shown above , doSendTypeStatus() function getting called automatically ,i.e. with out being pressed any of the key on key board .
Thread [AWT-EventQueue-0] (Suspended (breakpoint at line 82 in LivehelpTextEntryPanel$1))
LivehelpTextEntryPanel$1.keyPressed(KeyEvent) line: 82
TextAreaPane$MyTextArea(Component).processKeyEvent(KeyEvent) line: 5058
TextAreaPane$MyTextArea(JComponent).processKeyEvent(KeyEvent) line: 2388
TextAreaPane$MyTextArea(Component).processEvent(AWTEvent) line: 4909
TextAreaPane$MyTextArea(Container).processEvent(AWTEvent) line: 1569
TextAreaPane$MyTextArea(Component).dispatchEventImpl(AWTEvent) line: 3615
TextAreaPane$MyTextArea(Container).dispatchEventImpl(AWTEvent) line: 1627
TextAreaPane$MyTextArea(Component).dispatchEvent(AWTEvent) line: 3477
DefaultKeyboardFocusManager(KeyboardFocusManager).redispatchEvent(Component, AWTEvent) line: 1713
DefaultKeyboardFocusManager.dispatchKeyEvent(KeyEvent) line: 627
DefaultKeyboardFocusManager.preDispatchKeyEvent(KeyEvent) line: 831
DefaultKeyboardFocusManager.typeAheadAssertions(Component, AWTEvent) line: 741
DefaultKeyboardFocusManager.dispatchEvent(AWTEvent) line: 592
AgentFrame(Component).dispatchEventImpl(AWTEvent) line: 3506
AgentFrame(Container).dispatchEventImpl(AWTEvent) line: 1627
AgentFrame(Window).dispatchEventImpl(AWTEvent) line: 1606
AgentFrame(Component).dispatchEvent(AWTEvent) line: 3477
EventQueue.dispatchEvent(AWTEvent) line: 456
EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: 201
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 151
EventDispatchThread.pumpEvents(int, Conditional) line: 145
EventDispatchThread.pumpEvents(Conditional) line: 137
EventDispatchThread.run() line: 100 can any one please help me in resolving this issue. I am implementing typing status feature in my chat application. but due to this key event behavior , my implementation is failing completely.
Looking for reply.
thanks in advance
AniWhat is the question?
doSendTypeStatus() function getting called automatically ,i.e. with out being pressed any of the key on key board .No, it is getting called whenever a key is pressed in the text area. It can be any key, but a key must be pressed. If you claim not to be pressing any keys, please print out the event.
// wrong:
if(e.getKeyChar()==KeyEvent.VK_ENTER) {
// right:
if(e.getKeyCode()==KeyEvent.VK_ENTER) {You should compare codes with codes, not chars
Lastly you might want to use a document listener instead, so you also get notified when the user pastes something in the text area. -
How to send Remote controller key event
Hi Sir,
Can anyone tell me "how to send key event from "Remote
Controller" to Flex application?
for example. I want to control the Flash player or my Flex UI
application from remote controller such as use firefly
controller/streamzap controller/Gyration controller. Normally user
will use mouse or keyboard to enter/generate event, now I want to
use "Remote controller" to generate the key event. In Flex, how can
I capture the key event from "remote controller"? Any sample code
to provide that will be good.
Thanks.
LinHere's a couple related threads
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=583877
http://forum.java.sun.com/thread.jspa?forumID=57&threadID=712386
I'd also suggest exploring the Search Forums available on the left,
which is how I found those threads:
http://onesearch.sun.com/search/onesearch/index.jsp?qt=focus+traversal+tab+text&subCat=siteforumid%3Ajava57&site=dev&dftab=siteforumid%3Ajava57&chooseCat=javaall&col=developer-forums -
Hi,
Could you tell me how to get F1 key event which is
nothing to do with any control's focuses?
For example, suppose there's a button saying "F1 exit",
and the focus is on some other button.
In such case, if user pushes F1, program should exits.
That's what I want to do.
Thank you.For example:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Example {
public static void main(String[] args) {
JPanel p = new JPanel();
p.add(new JButton("sample button"));
Action action = new AbstractAction("homer") {
public void actionPerformed(ActionEvent evt) {
System.out.println("DOH!");
KeyStroke stroke = KeyStroke.getKeyStroke("F1");
Object key = action.getValue(Action.NAME); //homer
p.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, key);
p.getActionMap().put(key, action);
JFrame f = new JFrame("Example");
f.setContentPane(p);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
} -
Manual bank statement: no batch input was generated
Hi,
maybe somebody has a clue with this problem regarding FF67: after the data processing, no batch input is generated in order to post the bank statement.
Please, I need your help with an OSS note or with a posting solution without batch input ( I tried to process the bank statement with "processing type = 4", but it didn't work).Hi Andrea,
Try to add value in <i>Session name for bank postings</i>
Do not hesitate to ask for further clarifications. Award points if useful.
Regards,
Siva -
Batch-input to transaction SM34
Hello,
I need to create a batch-input for the transaction SM34.
I have done a recording but there is a screen(dialog structure) that only appeares when I call the transaction without batch-input mode. So, I have done the recording with the option "Not a Batch-input Session". But the recording gives the TCODE "=%_GC 117 22" when I do double-click for displaying the details and when I try to call the transaction (options-nobinpt = 'X') from my report, this TCODE doesn't work.
Does anybody know if there is another way to display these details, without doing double-click? Or another way to pass this TCODE?
Thank you very much,
Maite.Hello,
I've solve my problem on my own.
I don't need to call the details by a double-click, I can go to Table View --> Other View. The TCODE of this option doesn't give any problem in the Batch-input.
Maite. -
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 !
ThanksHi 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 -
RemoteApp receives multiple KeyUp events without any keys being pressed
Hi All,
I have a very simple winforms app that I am using to try and track down what is happening with keyboard events when using RemoteApp.
Basically I have a form and a textbox that track the KeyDown, KeyPress and KeyUp events.
As soon as I start my app via RemoteApp I receive multiple KeyUp events without even pressing a key.
Does anyone know why RemoteApp would be sending these random KeyUp events.
The code of my simple test app is as follows:
Public Class Form1
Dim lst As New List(Of String)
Private Sub AddtoList(str As String)
lst.Add(str)
End Sub
Private Sub TextBox1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyDown
AddtoList("txt KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
End Sub
Private Sub TextBox1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
AddtoList("txt KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
End Sub
Private Sub TextBox1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
AddtoList("txt KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
End Sub
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
AddtoList("Form Closing")
IO.File.AppendAllLines(Application.StartupPath & "\SimpleKeyUp_v2.txt", lst)
End Sub
Private Sub Form1_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
AddtoList("Form KeyDown" & vbTab & "KeyCode is " & e.KeyCode)
End Sub
Private Sub Form1_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
AddtoList("Form KeyPress" & vbTab & "KeyChar is " & e.KeyChar)
End Sub
Private Sub Form1_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
AddtoList("Form KeyUp" & vbTab & "KeyCode is " & e.KeyCode)
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
AddtoList("Form Load")
End Sub
End Class
Simply opening and closing the app via RemoteApp gives the following results:
Form Load
Form KeyUp KeyCode is 9
txt KeyUp KeyCode is 9
Form KeyUp KeyCode is 16
txt KeyUp KeyCode is 16
Form KeyUp KeyCode is 16
txt KeyUp KeyCode is 16
Form KeyUp KeyCode is 17
txt KeyUp KeyCode is 17
Form KeyUp KeyCode is 17
txt KeyUp KeyCode is 17
Form KeyUp KeyCode is 9
txt KeyUp KeyCode is 9
Form KeyUp KeyCode is 18
txt KeyUp KeyCode is 18
Form KeyUp KeyCode is 9
txt KeyUp KeyCode is 9
Form KeyUp KeyCode is 18
txt KeyUp KeyCode is 18
Form KeyUp KeyCode is 9
txt KeyUp KeyCode is 9
Form Closing
Cheers and Thanks in Advance!
DwayneHi,
It seems that your issue has been out of the scope of this forum.For coding issue,I suggest you ask in the
MSDN forum to see whether anyone can help you out.
Regards,
Clarence
TechNet Subscriber Support
If you are
TechNet Subscription user and have any feedback on our support quality, please send your feedback
here.
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. -
Making a batch input without questions
Hello,
I'm trying to connect through a transaction PP01 infotype that I created to the table HRP1001. Thus I created a button in the layout of my infotype and I want when you press this button it back it runs the transaction PP01 again with the values pre-populated. I've done batch input, but I wonder if there is any way to do it without the user need to intervene when using 'A' class on call transaction
Best Regards.hi Ali Sanchez
Use report RSBDCSUB.
submit rsbdcsub and return.
Hope it will help you
Regards
deva -
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.
-
LSMW - Sending E-Mail about errors after a batch input has been processed..
Hi All,
I have a requirement in LSMW. The LSMW has to send an e-mail to a distribution list after all records are read and posted through LSMW i.e, if the method used is Batch Input Session then an e-mail has to be sent to a distribution list after the Batch Input Session has been processed. Kindly help me regarding this..
Regards,
MaheshHi,
You can trigger an event once all the records are being processed and use that event to start the workflow. From workflow you can send mails to the initiator of the Batch session.
Regards,
Sumalatha
Maybe you are looking for
-
Ipod not recognized by itunes but is by iphoto
Hi, My ipod is not recognized by itunes (it's does not appear in the left section) but it is in iphoto (aks me if I want to import 15 elements). I have follow the instructions bellow with no success. iPhone, iPad, iPod touch: Device not recognized in
-
Error While exporting project in OSB through eclipse
org.eclipse.core.runtime.AssertionFailedException: null argument: at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85) at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73) at org.eclipse.jface.viewers.StructuredViewer.a
-
Support of Korean Language(damn urgent)
Hai All, I have developed Applet application which has to run on the korean system. So i changed my systems regionsettings to korean. But when i tried to open the applet in IE. The IE got closed. Please if any one can help in this regard it would be
-
Windows 7 doesn't awaken with Ipod Nano 5G connected
Brand new HP computer w/Windows 7 and brand new Ipod Nano 5G. Left ipod connected to computer to charge. After computer powered down it would not restart. HP figured out that the Ipod was blocking the restart. If I unplug Ipod computer restarts fine.
-
belle introduced, amongst painful others, an SMS character count bug, where, when you type an SMS with the hardware keyboard, the SMS character count is not displayed. it is displayed only when you type using the onscreen keyboard. recently e7 receiv