Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 click drag
#1
I wonder if I could be pointed towards what is probably a simple coding solution. I am trying to automate a click and drag on a GUI for an audio looper on mac osx. I can position the cursor , but now I need to click and drag a short distance , in a prescribed timeframe , around three seconds start to finish , and then have the cursor reposition itself at the starting point. I can do it in a very roundabout way with AutoMouseClick and Repeater using macros , but it would seem python should offer a much simpler solution. I have found this piece of script
#!/usr/bin/python
import sys
import time
from Quartz.CoreGraphics import * # imports all of the top-level symbols in the module
def mouseEvent(type, posx, posy):
 theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
 CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
 mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclickdn(posx,posy):
 mouseEvent(kCGEventLeftMouseDown, posx,posy);
def mouseclickup(posx,posy):
 mouseEvent(kCGEventLeftMouseUp, posx,posy);
def mousedrag(posx,posy):
 mouseEvent(kCGEventLeftMouseDragged, posx,posy);
ourEvent = CGEventCreate(None); 
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
mouseclickdn(60, 100);
mousedrag(60, 300);
mouseclickup(60, 300);
time.sleep(1);
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
but I think it needs some drag duration input to work as I would like.
I was hoping pyautogui would be useful , but with no experience of these things the installation on mac is rather difficult.

Any help or pointers appreciated.
Oli
Quote
#2
If you're not too deeply dependant on Quartz, wxpython has some good tools for this.
see: https://wxpython.org/Phoenix/docs/html/d...rview.html
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  GUI with drag and drop functionality sayyedkamran 5 1,084 Dec-17-2019, 07:29 PM
Last Post: Denni
  [PyQt] Drag items across tabs Alfalfa 5 549 Sep-01-2019, 11:58 PM
Last Post: Alfalfa
  [PyQt] Drag and drop converter Raures 0 1,902 Oct-01-2017, 07:44 PM
Last Post: Raures
  Drag and Drop GUI crystallized_neuron 3 11,993 Apr-26-2017, 08:41 PM
Last Post: joe_anonimist
  Drag and drop image object vijaysagi 1 8,323 Apr-06-2017, 09:36 AM
Last Post: wuf

Forum Jump:


Users browsing this thread: 1 Guest(s)