Getting the keyboard modifiers key state before injecting event.

I'm using the Robot to inject keyboard events into a host computer from multiple clients.
Since each client can have different modifiers keys (i.e. Shift, Alt, Ctrl, ...) set at a time and
clients can interrupt each other, I need to be able to read from the host computer what
modifier keys are set at that moment to get things back into synch.
The KeyEvent class has a way to get the modifier keys through:
KeyEvent.isShiftDown();
KeyEvent.isControlDown():
But this doesn't help (apparently) because that information is only available to a
Keyboard listener when a key is pressed.
What I need is a way to "get" the current keyboard modifier keys state before injecting
an event through the Robot.
Would anyone know how to do this?

So... the clients send input events to the host and the host in turn simulates those events with the use of a Robot. Is that correct?
If so then the program needs to save the last injected keyboard input that had a modifier mask in a field somewhere. Whenever you need to ask if any modifier keys are being pressed, you need only to look at this field and see if it is a pressed event. However, this method won't be able to detect a person physically at the host computer typing stuff.
The central problem is that you can query keyboard input from OS (such as asking if shift is currently pressed) without a focused window using the standard api. But a focused window kind of defeats the purpose of what you are trying to do.

Similar Messages

  • Changing keyboard modifier keys

    I use an editor (EMACS) which makes major use of the 'ctrl' key so I swap it with the 'caps lock' key so my little finger can hit it without getting a cramp. It works just fine about 90% of the time but the other 10%, when I hit the 'caps lock' key instead of getting the 'ctrl' function I get the 'caps lock' function and my editing screws up terribly. It is really frustrating because if I don't notice, and if I hit what I think is <ctrl>k to kill a line I get a 'K' in the text instead.
    PowerBook G4    

    I solved this problem by finding and altering an applescript that will change the keyboard modifier keys. I wish I could still find the web page so I could post it, but here's the applescript I used to change to PC layout:
    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
    click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
    click pop up button 3 of sheet 1 of window "Keyboard & Mouse"
    click menu item 4 of menu 1 of pop up button 3 of sheet 1 of window "Keyboard & Mouse"
    delay 1
    click pop up button 4 of sheet 1 of window "Keyboard & Mouse"
    click menu item 3 of menu 1 of pop up button 4 of sheet 1 of window "Keyboard & Mouse"
    click button "OK" of sheet 1 of window "Keyboard & Mouse"
    end tell
    end tell
    tell application "System Preferences"
    quit
    end tell
    (end of script)
    And here's the script I used to change it back to Mac layout:
    tell application "System Preferences"
    activate
    set current pane to pane "com.apple.preference.keyboard"
    end tell
    tell application "System Events"
    tell process "System Preferences"
    click radio button "Keyboard" of tab group 1 of window "Keyboard & Mouse"
    click button "Modifier Keys…" of tab group 1 of window "Keyboard & Mouse"
    click button "Restore Defaults" of sheet 1 of window "Keyboard & Mouse"
    click button "OK" of sheet 1 of window "Keyboard & Mouse"
    end tell
    end tell
    tell application "System Preferences"
    quit
    end tell
    (end of script)
    I saved the scripts as executibles with neat Apple and XP custom icons and put them in the Dock. Pretty slick.

  • Keyboard Modifier Keys trouble

    Hi!
    I have gotten a new problem, I never had before.
    While having an external USB-keyboard plugged in, I swapped the Option and Command keys here:
    System Preferences -> Keyboard & Mouse -> Keyboard -> Modifier Keys
    (I find this useful when I use external PC keyboards via KVM switches and such, as they have the Windows key and Alt key opposite, at least on Norwegian keyboards.)
    And usually that only applies to the external keyboard. But now, on my new macbook, it now applies to the built in keyboard. And I am not able to turn it off. Or: When I turn it off or choose Restore Defaults, nothing happens. Even though Command is listed as the Command key, Option still works as the Command key, and Option as the Command key.
    So, does anyone know if there's a file I might delete or modify or something?
    flips 8)

    It seems the settings are stored in ~/Library/Preferences/ByHost/.GlobalPreferences.<UUID>.plist
    First I deleted both com.apple.keyboard.modifiermapping trees/entries.
    Then I re-entered the correct setting for only the external keyboard. (My guess is that I just overlooked the option of changing mapping for just one of the keyboards or "All".) Still I would consider it a bug not being able to reverse the setting without manually deleting it from the correct plist file ...
    flips 8)

  • OIM - Task Assignment Adapter - How to get the object instance key?

    Hello experts,
    I'm trying to use a task assignment adapter to assign an approval task dynamically. Basically, the user can request a resource like "CustomApp Profiles" and we create an object form to let them choose the profile that he needs. Each profile has an owner, which is populate in a Lookup (Owner is the code and Profile is the decode).
    So, in the approval task, I need to get the profile selected by user in the object form and search into the lookup who is the owner of that profile. But I don't know how can I get the object instance key using the parameters that can be mapped to a task assignment adapter.
    Looking into the OIM documents, I believe that the easier way is using the request key, because the REQ_KEY is a foreign key in OBI table.
    Did anyone knows how can I get the object instance key using the request key? Can I use some API or should I execute a SQL statement directly in OIM database?
    Best Regards,
    Nitto

    To retry a task that is in a rejected state, you use the SCH_KEY which is the task key.  In OIM, all rejected tasks are listed in the OTI table.  It contains all the important information about a rejected or pending task.
    You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
    -Kevin

  • Getting the Object Access key

    This weird question,
    But does any one know how to get the object access key for Standard SAP object is changed..
    Normally when we try to do any modification on Standard SaP object it asks for and access key.. We need to enter it once, after which the object is open for editing.
    I have an SAP object which as been modified .
    I want to know that number?? Is it possible..
    Any help will be highly appreciated..
    Regards,
    Samir.

    Hi Samir,
    You have to contact SAP Support to obtain the access key for a Standard SAP Object. The correct channel for that is the OSS, where yo can raise a message requesting the same.
    But you are saying that there's one object that has already been modified. Who has done the modification ? When they have done it, they must have specified the access key. If you want to modify the same object, then the best thing for you to do is to contact the person who has changed it.
    By the way, have the modifications been done using the Modififcation Assistant?
    Regards,
    Anand Mandalika.

  • Do we have a way to get the differences between xtext model before and after partial parse?

    Do we have a way to get the differences between xtext model before and after partial parse?
    As an example i have file contains 4 lines, xtext parsed this file and generated its model, then i made small modification in line number 3, so xtext partially parsed the file and generated another model.
    The question is could we get the nodes that has been deleted from the model?
    could we get the new nodes added to the model?
    could we get the differences between the two models?

    Workflow {
    bean = StandaloneSetup {
    scanClassPath = true
    platformUri = "${runtimeProject}/.."
    // The following two lines can be removed, if Xbase is not used.
    registerGeneratedEPackage = "org.eclipse.xtext.xbase.XbasePackage"
    registerGenModelFile = "platform:/resource/org.eclipse.xtext.xbase/model/Xbase.genmodel"
    component = ParseXextModel{
    //Load the xtext model and keep the reference of the inmem model
    component = DirectoryCleaner {
    directory = "${runtimeProject}/src-gen"
    component = DirectoryCleaner {
    directory = "${runtimeProject}/model/generated"
    component = DirectoryCleaner {
    directory = "${runtimeProject}.ui/src-gen"
    component = DirectoryCleaner {
    directory = "${runtimeProject}.tests/src-gen"
    component = Generator {
    pathRtProject = runtimeProject
    pathUiProject = "${runtimeProject}.ui"
    pathTestProject = "${runtimeProject}.tests"
    projectNameRt = projectName
    projectNameUi = "${projectName}.ui"
    encoding = encoding
    language = auto-inject {
    uri = grammarURI
    // Java API to access grammar elements (required by several other fragments)
    fragment = grammarAccess.GrammarAccessFragment auto-inject {}
    // provides a compare view
    fragment = compare.CompareFragment auto-inject {}
    component = ParseXextModel{
    //Load the xtext model again and keep the reference of the inmem model
    component = CompareModel {
    //Implement this using EMF Comapre to see the differnces between 2 models
    }

  • Keyboard modifier key remap suddenly not working

    I am using a MacBook Pro running OS X 10.6.8 (Snow Leopard). I use a third-party USB keyboard that is laid out (naturally) Windows-style, with the Alt keys inside (closer to the space bar than) the “Windows logo” keys. I use the Modifier Keys button in the Keyboard preference panel to remap these to the standard Mac configuration, with the Command keys on the inside and the Option keys on the outside.
    Today those modifier keys are suddenly reversed back to the default Windows layout. The Keyboard panel still shows my preferred (remapped) configuration, but it is not being honored. I have tried reverting to the default layout and then back again, I have rebooted the system, nothing works—the modifier keys are still stuck in the Windows configuration. I rely heavily on keyboard macros in my work, most of which use the modifier keys, and those keystrokes are built into my fingers as second nature. The reversed modifier keys are driving me crazy. Please help: what can I do to make the keyboard honor my settings in the Keyboard preference panel?

    Same problem here. Been working fine for a couple years and now suddenly the modifier key mapping is being ignored.

  • I want to make the keyboards numerical keys shortcuts for buttons.

    I want to make the keyboards numerical keys shortcuts for buttons, without a modifier key is this possible ? e.g. press '1' on the keyboard button 1 is pressed on the GUI.

    The number keys are not valid hot keys for our controls. The easiest workaround would be to use fhe F keys instead (F1 for button 1, etc.) However, if you are set on the number keys you could implement this with a panel callback. You could have a panel callback that monitors all keypress events and then, depending on the key pressed, calls the code that would be called with a button press of the button for that key.
    Best Regards,
    Chris Matthews
    Measurement Studio Support Manager

  • How to get the process instance key so as to retry a rejected task through api while ad provisoing?

    Hi All,
    How to get the process instance key so as to retry a rejected task through API while AD provisioing state?
    API URL - http://docs.oracle.com/cd/E27559_01/apirefs.1112/e28159/toc.htm
    Thanks

    To retry a task that is in a rejected state, you use the SCH_KEY which is the task key.  In OIM, all rejected tasks are listed in the OTI table.  It contains all the important information about a rejected or pending task.
    You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
    -Kevin

  • E71: Any way to get the keyboard backlight to alwa...

    I have a multi-lingual keyboard with the English letters printed in a blue paint that is almost impossible to see without the backlighting. So, my question is: is there a way to get the keyboard backlighting to always turn on with any press of a button?
    Thanks,
    Message Edited by msafi on 17-Dec-2008 04:12 AM

    Yes, when you delete an email, click on settings then click on the Mail, Contacts, Calendars and then make sure "Ask Before Deleting" is on. Not for sending .

  • How do I get the F1 - F13 keys to work ?

    How do I get the F1 - F13 keys to work ? I am trying to get the F5 key to refresh a page for me instead of using the mouse.

    From the Apple Help menu:
    Use these keyboard shortcuts to access the menu bar, Dock, and other areas on the screen. In the Keyboard Shortcuts pane of Keyboard & Mouse preferences, you can choose to move the keyboard focus to text boxes and lists only, or to all controls.
    Action
    Shortcut
    Move to the menu bar
    Control-F2
    Move to the Dock
    Control-F3
    Move to the active window or the next window behind it
    Control-F4
    Move to the toolbar of the active window
    Control-F5
    Move to a floating window (for example, the Font panel or Color window)
    Control-F6
    Move to the next window in the active application
    Command-accent (`)
    Move to the previous window in the active application
    Command-tilde (~)
    Change the current full keyboard access setting (text boxes and lists, or all controls)
    Control-F7
    Move to the window's drawer
    Command-Option-accent (`)
    Move to the status menus in the menu bar
    Control-F8
    Show or hide the Character Palette
    Command-Option-T

  • TS1702 I cannot get the keyboard to come up on the ipad mini when in the citrix receiver.  Has anyone ran into this and do you know how to fix it?

    I cannot get the keyboard to come up on the ipad mini when in the citrix receiver.  Has anyone ran into this and do you know how to fix it?

    I am not familiar with Citrix Reciever but is it possible it is open or being used in another open app?
    Try quitting all apps then try again.
    Quit all apps: Double tap the Home button and swipe the app preview page up for each open app

  • Getting the "last modified" property of a file located on HTTP server

    Hello
    I'd like to read a file (on http server) according to his "last modified" time. Can anybody tell me how to get the "last modified" property in a J2ME/CLDC application?
    Thanks in advance

    the file that you want get is in the server?
    you can use java.io.File.lastModified() which in J2SE to get a long num.
    then you can transform long int to orther class that you need ,and do this in server.
    at the end of all you can send this info to J2ME/CLDC app with stream.

  • On my new iPhone, at the Apps store, I tried to make a purchase, the popup screen shows my Apple ID and asks for my password, but no keyboard appears so that I can enter the password.  How do I get the keyboard to appear??

    On my new iPhone, at the Apps store, I tried to make a purchase, the popup screen shows my Apple ID and asks for my password, but no keyboard appears so that I can enter the password.  How do I get the keyboard to appear??

    On your iPad, delete the existing account then sign back in with the new ID and password.

  • How do I get the keyboard on my macbook pro to light up?

    how do i get the keyboard on my macbook pro to light up?

    Welcome to Apple Support Communities
    What MacBook Pro have you got? Only Unibody MacBooks Pro (Late 2008 and newer) have a backlit keyboard. If you have one of these MacBooks Pro, you can set up its illumination in System Preferences > Keyboard. See > http://support.apple.com/kb/ht4882

Maybe you are looking for