Select text by pressing SHIFT+END

Asked by Eugene S

Hi,

I want to select a line of text by pressing the following key combination:
Shift + End

I have attempted to do so in the following way:
type(Key.HOME)
type(Key.END, KeyModifier.SHIFT)

This way the cursor just moves to the end of the string, without selecting any text.

I have found the below post which seems to related to the same issue:
https://answers.launchpad.net/sikuli/+question/225794

It is stated there that the following combination should be used instead:
type (Key.END, KeyModifier.SHIFT + KeyModifier.CTRL )

I have tried that but got the same results.

I have also found this link where it says that it's a bug and it seems to be fixed in 1.0.0 version. However I am using the 1.0.1 version at the moment.
https://bugs.launchpad.net/sikuli/+bug/894312

Can someone please assist me with this issue? How can I select a string of text?

Thanks!
Eugene

Question information

Language:
English Edit question
Status:
Answered
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

UPDATE

Ok, I have found the below question with the workaround
https://answers.launchpad.net/sikuli/+question/143874

So it seems that this BUG will not be fixed since it's a java issue.

So the way I'm going to implement it is by detecting the current NUM_LOCK state and then act accordingly. For example:

val = Env.isLockOn(Key.NUM_LOCK)
if val == True:
 print "switching off..."
 type(Key.NUM_LOCK)
else:
 print "already off, doing nothing"

and then:
type (Key.END, KeyModifier.SHIFT | KeyModifier.KEY_CTRL )

or:
type (Key.END, KeyModifier.SHIFT + KeyModifier.CTRL )

Revision history for this message
jptlse (jptlse) said :
#2

To select a string of text, perhaps could you try to use right and left arrow keys, like describe below.
This example is ok for Mac keyboard. You have to adapt it for Windows keyboard.

click("your image or text if ocr is activated")

# Push down the key command with left arrow
keyDown(Key.CMD)
type(Key.LEFT)

# "key command" is still pressed + right arrow is pressed
keyDown(Key.SHIFT)
type(Key.RIGHT)

# The entire the line is selected

# Remove "virtual fingers" from the keyboard :)
keyUp(Key.CMD)
keyUp(Key.SHIFT)

# Validate you've selected the line with a copy of the string and a prompt
type('c', KeyModifier.KEY_CMD)
popup(Env.getClipboard())

Can you help with this problem?

Provide an answer of your own, or ask Eugene S for more information if necessary.

To post a message you must log in.