← Back to team overview

sikuli-driver team mailing list archive

[Bug 1858107] Re: Drag and Drop Not working

 

see your related question.

** Changed in: sikuli
       Status: New => Invalid

-- 
You received this bug notification because you are a member of Sikuli
Drivers, which is subscribed to Sikuli.
https://bugs.launchpad.net/bugs/1858107

Title:
  Drag and Drop Not working

Status in Sikuli:
  Invalid

Bug description:
  2.0.1-2019-11-22_16:54/Mac10.15.2/Java13(64)13.0.1+9
  Mac OS 10.15.2

  
  Drag and Drop not working

  Work around

  def Test_Mouse_Down():
      x,y = Get_Mouse_Location("Position Mouse in Safe Location to Try Mouse Down : Make sure this has Focus then press return") ; dragLocation = Location(x,y) ; dropLocation = Location(x,y-50)
      Get_Focus() # get focus
      hover(Location(x,y))
      print "Do a Mouse Down"
      mouseDown(Button.LEFT)
      wait(2)
      mouseMove(Location(x,y-30))
      wait(2)
      mouseUp(Button.LEFT)

  Drag and Drop was working on my Old 2009 Imac using release 1.1.3
  but cannot make it work on my New Imac using above release

  I did try to install 1.1.3 on this machine to compare the results of
  my test script

  https://answers.launchpad.net/sikuli/+question/687698
  but unfortunately its not supported so I cannot provide more info.

  
  MyFull Test Script to assist you in Fixing this Bug.

  import os
  Home_Directory = os.environ['HOME']
  print "Home_Directory",Home_Directory

  def Screen_Shot_and_Copy(screenshotsDir,Screen_Shot_File):
      import shutil
      import os
      some_region = SCREEN # for whole screen
      someRegion = App.focusedWindow() # for the frontmost windo
      img = capture(some_region)
      my_file = Screen_Shot_File
      print "Sub_Take_Screen_Shot_and_Copy() "+screenshotsDir + my_file + ".png" 
      localtime = time.localtime(time.time())
      timestring = time.strftime ('%m%d%H%M%S')
      my_file = my_file + ".png"
      shutil.move(img, os.path.join(screenshotsDir, my_file))

  def Get_Mouse_Location(v_Desc):
      popup(v_Desc)
      #"Position Mouse in Safe Loaction to Drag From Make sure this has Focus then press return")
      getmouseLoc = Env.getMouseLocation()
      x = getmouseLoc.getX()
      y = getmouseLoc.getY()
      return x,y

  def Get_Focus():
      click(Location(134, 114)) # get focus

  def Testing_Drag(dragLocation,dropLocation,v_Mouse_Delay,v_Wait):
      global g_MoveMouseDelay
      print "Drag",dragLocation.x,dragLocation.y,"to drop",dropLocation.x,dropLocation.y,"v_Mouse_Delay",v_Mouse_Delay,"Wait",v_Wait
      Get_Focus() # get focus
      Settings.MoveMouseDelay = v_Mouse_Delay # What Mouse Speed works
      hover(dragLocation)
      drag(dragLocation)   
      wait(v_Wait) #  Wait between Drag and Drop
      dropAt(dropLocation)
      wait(1) # Wait for drop to finish

  def Call_Drag_Drop(v_It,dragLocation,dropLocation):
      global g_MoveMouseDelay
      v_Try = 0 # Tried diff MoveMouseDelay - worked fine with delay of 5 on 1.1.3
      v_Try_Start = 4 # No good try longer MoveMouseDelay between Drag and Drop
      v_Try_Start = 8
      v_Try_Start = int(input("Start Mouse Delay","8"))
      v_No_Trys = int(input("No. of Incrementing 1sec Delays from "+str(v_Try_Start),"6"))
      v_No_Waits = int(input("No. of Incrementing 0.5sec Waits between Drag and Drop Starting with 1.5 ","3"))
      
      while v_Try < v_No_Trys : # Increasing MoveMouseDelays
          v_Try = v_Try + 1
          for hh in range(v_No_Waits): # Increasing Waits between Drag and Drop
              Settings.MoveMouseDelay = g_MoveMouseDelay
              setRect(621,398,828,837)
              if exists(v_It):
                  v_pos = find(v_It)
              else:
                  print "Get start right"
                  highlight(5)
                  exit(0)
              v_Wait = 1.5+(0.5*hh) ; v_Mouse_Delay = v_Try+v_Try_Start 
              Testing_Drag(dragLocation,dropLocation,v_Mouse_Delay,v_Wait)
              # some fails open a building - try to close it
              if exists("1577951818153.png"):
                  click("1577951818153.png")
              setRect(416,398,862,396)
              
              if exists(v_It):
                  v_pos2 = find(v_It)
                  if v_pos.x <> v_pos2.x or v_pos.y <> v_pos2.y:
                      print v_pos
                      print v_pos2
                      popup("Moved")
                      exit(0)
              else:
                  print "Not found"
                  exit(0)
              Settings.MoveMouseDelay = g_MoveMouseDelay
          v_Try = 200

  def Test_Mouse_Down():
      x,y = Get_Mouse_Location("Position Mouse in Safe Location to Try Mouse Down : Make sure this has Focus then press return") ; dragLocation = Location(x,y) ; dropLocation = Location(x,y-50)
      Get_Focus() # get focus
      hover(Location(x,y))
      print "Do a Mouse Down"
      mouseDown(Button.LEFT)
      wait(2)
      mouseMove(Location(x,y-30))
      wait(2)
      mouseUp(Button.LEFT)
      
  def Combo_Action(Combo_Header,v_Actions):
      #sikulixToFront()
      selected = select(Combo_Header, options = v_Actions)
      if selected == "Nothing Selected":
         popup("You did not select an item")
         print("You did not select an item")
         exit(0)
      return selected 


  v_Selected = ""

  while v_Selected<>"Exit":
      v_Selected = Combo_Action("Testing What",("Drag and Drop","Mouse Down","Exit"))
      print v_Selected
      
      if v_Selected ==  "Mouse Down":
          Test_Mouse_Down()
          
      
      if v_Selected == "Drag and Drop":
          g_MoveMouseDelay = 1
          ################### Image to Test With ###################
          screenshotsDir = Home_Directory+"/Desktop/"
          screenshotsDir = input("Save Image to Directory with trailing /",screenshotsDir)
          # File Name of Image
          Screen_Shot_File = "v_Bridge"
          # Get an image to see if it moves
          x,y = Get_Mouse_Location("Position Mouse on Image to Test Move : Make sure this has Focus then press return")
          setRect(x,y,20,20)
          Screen_Shot_and_Copy(screenshotsDir,Screen_Shot_File)
          v_Image = screenshotsDir+Screen_Shot_File+".png"
          
          ################### Get Drag and Drop ###################
          x,y = Get_Mouse_Location("Position Mouse in Safe Location to Drag From Make sure this has Focus then press return") ; dragLocation = Location(x,y) ; dropLocation = Location(x,y-50)
          ################### Test Drag Drop ###################
          Call_Drag_Drop(v_Image,dragLocation,dropLocation)
      # Results so far
      # Moved at  - but only worked once
      # v_Mouse_Delay 6 Wait 1.5
      # v_Mouse_Delay 8 Wait 1.5 and loaded a FARM which must have been interpreted as a click not drop or drag
      # v_Mouse_Delay 9 Wait 1.5 and again loaded FARM

To manage notifications about this bug go to:
https://bugs.launchpad.net/sikuli/+bug/1858107/+subscriptions


References