Linux Drag and Drop

Asked by Jeff_Vallis

1.1.2(2018-03-08_08:37)/Linux4.13.0-37-generic/Java8(64)1.8.0_161-b12
Read all I can find on Drag and Drop - you can see I have been trying other answered question
# I want to Drag the screen up to see the lower part of the screen
# When I find how to do this I need to drag screen fromleft to right to alsosee the missing side info
# Can someone give me an example that works
# This Code did nothing
if 1 == 1:
    #print "Drag Down"
    #dragregion = Location(817, 688)
    #dropRegion = Location(817, 210)
    x1 = Location(817, 688)
    x2 = Location(817, 210)
    print "Drag Up"
    dropregion = x1
    dragRegion = x2
    hover(dragregion) ; wait (2) ; hover(dropRegion) ; wait(2)
    click(dragregion)
    if 1 == 1:
        # Try Drag and Drop
        #What I really wanted to do was this
        print "DragDrop Down"
        v_result = dragDrop(dragregion, dropRegion)
        keyUp()
        print v_result
    if 1 == 0:
        print "Manual Drag Drop"
        mouseDown(Button.LEFT)
        v_result = mouseMove(dropRegion)
        mouseUp(Button.LEFT)
        print v_result

Any replies would be appreciated
Just in case U are wondering - Manula Drag and drop on th scrren does work
ie. Left Click and hold move cursor up release

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
Jeff_Vallis (vallis-pj) said :
#1

So I messed up the code above trying to make it look pretty
if 1 == 1:
    x1 = Location(817, 688)
    x2 = Location(817, 210)
    dropregion = x1
    dragregion = x2
    hover(dragregion) ; wait (2) ; hover(dropregion) ; wait(2)
    click(dragregion) # get focus
    if 1 == 0:
        # Try Drag and Drop
        #What I really wanted to do was this
        print "DragDrop Down"
        v_result = dragDrop(dragregion, dropregion)
        keyUp()
        print v_result
    if 1 == 0:
        print "Manual Drag Drop"
        mouseDown(Button.LEFT)
        v_result = mouseMove(dropregion)
        mouseUp(Button.LEFT)
        print v_result
        wheel(Location(472, 269), WHEEL_DOWN, 25)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

try this:

dropregion = Location(817, 688)
dragregion = Location(817, 210)
click(dragregion)
wait(1)
mouseDown(Button.LEFT)
wait(0.5)
mouseMove(dropregion)
wait(0.5)
mouseUp()

and play with the wait times in wait(0.5)

If you get it working: the reason behind: especially for drag-drop-ops the GUI might need some time to "know" that it is a drag-start.

if not: ????? ;-)

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#3

Tried on the Linux Google Chrome Game and did not work
https://plarium.com/en/strategy-games/vikings-war-of-clans/game/

Created Image - Put it on Desktop - Used above with no changes to wait - Item moved ok
So your code works on Linux but not in the game

In the game I can manually Drag the Screen Left Right Up Down

I expect yu have better things to do than answer questions from a 74year old playing games so thanx for the try
You can close this if you like

Revision history for this message
RaiMan (raimund-hocke) said :
#4

LOL, so it is like the 2 pensioners sitting on the park bench and talking about their diseases.

I am 69 and have enough time.

at the problem: games sometimes try to block non-manual mouse/key actions.
But if clicking in the game is accepted (leads to the same actions as manually), then the drag-drop should work also.

... and then it is all about timing: so play with the wait times (is Settings.MoveMouseDelay set to 0? play with this value also)
... and experiment manually in this sense

... possible to move the world using keyboard?

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#5

Mouse Preferences
Changed
Drag and Drop
Threshold from Medium to Small
no Change to results
Will try again either later or tomorrow

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#6

This is what I have been trying both work on desktop

Settings.MoveMouseDelay = 0
setRect(316,203,786,541)
v_Image_Desk ="1522682609903.png" # the image that I am moving on the desktop
v_Image = "1522664408893.png" # image on vikings screen
v_Do_Which = "Viking"
Start_Pos = find(v_Image)
dropregion = Location(714, 632)
dragregion = Location(714, 596)
if exists(v_Image_Desk):
    print "Make sure its in right place from last time"
    v_Do_Which = "Desk"
    v_Image = v_Image_Desk
    drag(dropregion)
    wait(v_Wait)
    dropAt(dragregion)
    wait(3)
    if v_Do_Which == "Desk":
        click(Location(1236, 513)) # remove highlight
        print "Remove Highlight"
    wait(3)

if 1 == 2:
    for i in range(20):
        v_Wait = 0.5
        for j in range(i):
            v_Wait = v_Wait + 0.2
        # Vikings Fails
        # Desktop Works
        #click(dragregion) ; wait(1)
        print "Next do Drag"
        drag(dragregion)
        wait(v_Wait)
        dropAt(dropregion)
        print "Previous do Drop"
        wait(3)
        if v_Do_Which == "Desk":
            click(Location(1236, 513)) # remove highlight if desk
            print "Remove Highlight"
        x = find(v_Image)
        if Start_Pos.x <> x.x or Start_Pos.y <> x.y:
            print "Found with Wait of",v_Wait
            #click(dropregion) ; wait(1)
            drag(dropregion)
            wait(v_Wait)
            dropAt(dragregion)
            wait(3)
            if v_Do_Which == "Desk":
                click(Location(1236, 513)) # remove highlight
                print "Remove Highlight"
            wait(3)
            exit(0)
    exit(0)
if 1 == 1:
    # Desktop works
    # Vikings Fails
    for i in range(50):
        v_Wait = 0.5
        for j in range(i):
            v_Wait = v_Wait + 0.2
        print "Next click location Wait",i,v_Wait
        click(Location(dragregion.x, dragregion.y))
        wait(1)
        mouseDown(Button.LEFT)
        wait(0.5+v_Wait)
        mouseMove(dropregion)
        wait(0.5+(v_Wait))
        mouseUp()
        wait(1+(v_Wait))
        print "Previous mouseUp"
        if v_Do_Which == "Desk":
            click(Location(1236, 513)) # remove highlight
            print "Remove Highlight"
        x = find(v_Image)
        if Start_Pos.x <> x.x or Start_Pos.y <> x.y:
            print "Moved with wait of ",v_Wait
            print "Move it back"
            click(Location(dropregion.x, dropregion.y))
            wait(1)
            mouseDown(Button.LEFT)
            wait(0.5+v_Wait)
            mouseMove(dragregion)
            wait(0.5+(v_Wait))
            mouseUp()
            wait(1+(v_Wait))
            print "Previous mouseUp"
            if v_Do_Which == "Desk":
                click(Location(1236, 513)) # remove highlight
                print "Remove Highlight"
            exit(0)
    exit(0)
exit(0)

Revision history for this message
RaiMan (raimund-hocke) said :
#7

ok, then it does not work with Sikulix (Java Robot) mouse actions.

Any chance for me to check that myself on an Ubuntu 16.04?

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#8

Still no joy

Revision history for this message
RaiMan (raimund-hocke) said :
#9

????

Revision history for this message
Jeff_Vallis (vallis-pj) said :
#10

Sent as Private message

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

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