Trying to select text with mouse functions

Asked by Maurice Richard

Originally I tried using OCR, but it's not as consistent as I need it to be.
So I'm trying to select a section of text on the page with mouse functions.

I've tried many variations, but I always get the same error:
"Invalid combination of button flags"

Here's a current snippet of the code:
    regTheText = Region(XText, YText, XTextLength, YTextLength )
    leftPoint = regTheText.getTopLeft()
    rightPoint = regTheText.getBottomRight()
    hover(leftPoint)
    mouseDown(Button.LEFT)
    wait(0.5)
    mouseMove(rightPoint)
    mouseUp(Button.LEFT)

It doesn't seem to like the mouseDown command.
Is my code incorrect? Or do I need to import something specific?

Any help is appreciated.

Thanks!
Maurice

Question information

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

this works for me with latest 1.1.4 on Windows 10:
switchApp("Edge")
r = selectRegion()
hover(r.getTopLeft())
mouseDown(Button.LEFT)
wait(0.3)
mouseMove(r.getBottomRight())
mouseUp()
type("c", Key.CTRL)
wait(0.5)
print App.getClipboard()
click()

Revision history for this message
Maurice Richard (flashfires) said :
#2

Thank-you RaiMan, this worked for me.
It's much appreciated!

Revision history for this message
Maurice Richard (flashfires) said :
#3

Thanks RaiMan, that solved my question.