← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #263845]: dragDrop does not work using Jython script

 

Question #263845 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/263845

    Status: Open => Answered

RaiMan proposed the following answer:
I made tests on Mac and Windows and could not reproduce your problems.

just the plain dragDrop() works in all situations with the same workflow
in IDE and running the script.py from command line with plain Jython.

--- script on Mac:
try:
  switchApp("Safari")
except:
  import sys
  import os
  dir = os.path.dirname(sys.argv[0])
  import org.sikuli.basics.SikulixForJython
  from sikuli import *
  setBundlePath(dir)
  switchApp("Safari")

hover("logo.png")
src = Mouse.at()
tgt = src.offset(0, -250)
hover(tgt)
tgt = Mouse.at()

# first dragDrop
dragDrop(src, tgt)

# second dragDrop with basic mouse actions
hover(src)
mouseDown(Button.LEFT)
hover(tgt)
mouseUp()
click(tgt)

--- script on Windows
try:
  hover()
except:
  import sys
  import os
  dir = os.path.dirname(sys.argv[0])
  import org.sikuli.basics.SikulixForJython
  from sikuli import *
  setBundlePath(dir)

popup("move mouse to source and press enter")
src = Mouse.at()
hover(src.offset(0,50))
hover(src)
popup("move mouse to target and press enter")
tgt = Mouse.at()
hover(tgt.offset(0,50))
hover(tgt)
click(src)
dragDrop(src, tgt)

The initial try:except: is to detect wether we are running in IDE or
from plain Jython and to set the bundle path in case of Jython.

To run Jython I use the built-in:
java -cp <path-to>sikulix.jar org.python.util.jython <path-to>script.sikuli/script.py

I tested with the latest version 1.1.0 (nightly build from later today),
which contains Jython 2.7b4

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.