1

これは私のコード スニペットです。

reg = selectRegion("Selected a region")
reg.keyDown(KEY_CTRL)
reg.keyUp()

私の目的は、押しCTRLてから下にスクロールすることで行うように、いくつかの行を選択することですが、スローします

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Invalid key code

私が何か間違ったことをしたことは明らかです。これで誰か助けてもらえますか??

4

1 に答える 1

2

The documentation on special keys says to use CTRL with keyDown(). KEY_CTRL is used with type() or other cases where you want to add the modifier key as a mask. (And that's actually deprecated and should be KeyModifier.CTRL now, instead.)

For example:

reg.keyDown(CTRL)
... some code that scrolls ...
reg.keyUp(CTRL)

Or to press the "down" key twice while holding control:

reg.type(Key.DOWN + Key.DOWN, KeyModifier.CTRL);

(As a side-note, it's generally shift that's used as the modifier key for creating a selection and not control.)

于 2013-05-20T11:50:37.850 に答える