Capturing Text in Region with Mouse events, if text can be selected and copied using ctrl/cmd-c

Asked by Dave

I would like to share a solution that allows one to capture the text from a region using Mouse events.

reg = selectRegion() # dynamically define region
hover(reg) # by default focus is on center point of region
mouseMove(-120, -20) #refocus to upper left of region, numbers depend on region size
mouseDown(Button.LEFT)
mouseMove(240, 40) # highlights entire region
mouseUp(Button.LEFT)
reg.type("c", KEY_CTRL) # copy highlighted text
value = Env.getClipboard()
print str(value) # prints contents of region

There may a more elegant solution; but this is at least one solution!

Question information

Language:
English Edit question
Status:
Expired
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
RaiMan (raimund-hocke) said :
#1

thanks.
Might be helpful in situations, where Region.text() does not work sufficiently.
Depends on the that text can be selected and copied.

Should be put into a function with parameters that define the mouse move.

Revision history for this message
Launchpad Janitor (janitor) said :
#2

This question was expired because it remained in the 'Open' state without activity for the last 15 days.