Some key combo doesn't work #43

nagappan opened this Issue Nov 26, 2012 · 8 comments


None yet

4 participants

Atomac team member

test in an instance of ldtpd.Core

test.generatekeyevent('') # Not working
test.keypress('') # Not working
test.generatekeyevent('abc') # Caps lock not working
test.keyrelease('') # Not working

Atomac team member

Is this something I need to fix in ATOMac or is this an LDTP issue?

Atomac team member

This is ATOMac issue and not LDTP. Thanks

Atomac team member

Can you post an example of the ATOMac code that's not working?

Atomac team member

import atomac
print window


I have an example that isn't working for me

generatekeyevent(COMMAND + DOWN)

The error message says to "Please provide only one character to send" - line 370 of AXClasses

Atomac team member

Saw this from LDTP forum -
I was able to get around with by using osascript

cmd = "osascript -e \'tell application \"System Events\" to keystroke \"" + myString + "\"'"

@ladza ladza added a commit to ladza/pyatom that referenced this issue Feb 24, 2014
@ladza ladza Fix for not working key combos (Issue #43). d6ebafb

ldtp.keypress and ldtp.keyrelease appear to be completely broken in atomac.

Sample code segments:
1: ldtp.keypress('<shift>'); ldtp.keypress('a'); ldtp.keyrelease('a'); ldtp.keyrelease('<shift>')
2: ldtp.keypress('<shift>'); ldtp.generatekeyevent('a'); ldtp.keyrelease('<shift>')

On both Windows and Linux, running either of the above scripts from an interactive Python console will type an uppercase A in the currently active window (which is generally the console itself).

On my Mac test system, however, script 1 throws an "Unsupported modifiers" exception, and script 2 types a lowercase "a".

Closer inspection of reveals that both KeyPressAction and KeyReleaseAction (which are triggered from keypress and keyrelease) do nothing but attempt to press/release the modifier keys*, throwing an exception for any keys not having modifiers. On Windows and Linux, these functions work with any keys, not just modifiers (e.g. for interacting with a game which uses WASD for movement).

Furthermore, they don't even appear to be working when they are only given modifiers, as demonstrated by the second code sample (which should print an uppercase A because the shift key is supposed to be pressed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment