Jump to content
Sign in to follow this  
AiQA

Drag and Drop

Recommended Posts

AiQA

Hello

I'm trying to create a relatively simple script and I'm having trouble figuring out where to start with it.

What I want to do is this:

Keypress gets mouse location and triggers a drag and drop from there to a specified coordinates, sets mouse back at original location.

Any information on helping me get this started would be appreciated.

Thanks.

Edited by AiQA

Share this post


Link to post
Share on other sites
motionman95

Here's something to get you started:

$cInfo = GUIGetCursorInfo()
If $cInfo[2] = 0 Then
;If the left mouse key is up

$mousePos = MouseGetPos()
;Get the mouse's position (x,y)

$origX =;The X to start dragging from
$origY =;The Y to start dragging from
$destX =;The X to stop dragging at
$destY =;The Y to stop dragging at

MouseClickDrag("left", $origX, $origY, $destX, $destY)
;MouseClickDrag(Mouse button to press, X to start drag from, Y to start drag from, X to end drag, Y to end drag)

;Good luck!
EndIf

EDIT: Replaced "}" with "EndIf". Whoops.

Edited by motionman95

Share this post


Link to post
Share on other sites
qazwsx

you could also use hotkeyset to set the hot key rather than constantly polling for it. Great example. Just enough to get started without giving the script.

Share this post


Link to post
Share on other sites
AiQA

Thanks for the help!

Using the basics supplied by motionman95 I've set it into a function and using qazwsx idea of using hotkeyset set a key to call the script.

However when I run the script it doesn't seem to do anything. No error or tray icon. Do I need to set up a While to call the function? Ideally I'd like to be able to run the draganddrop script on a keypress.

Thanks.

Share this post


Link to post
Share on other sites
AiQA

Thanks for the help!

Using the basics supplied by motionman95 I've set it into a function and using qazwsx idea of using hotkeyset set a key to call the script.

However when I run the script it doesn't seem to do anything. No error or tray icon. Do I need to set up a While to call the function? Ideally I'd like to be able to run the draganddrop script on a keypress.

Thanks.

I've figured it all out and got it to work. Thanks for your help!

I have another question though. Is there a faster movement function than the drag and drop? I see it click, drag, drop.. but is there a way to speed up the process or make the mouse move faster? With predetermined end coordinates would it be faster to set a click and unclick?

Share this post


Link to post
Share on other sites
AiQA

I've figured it all out and got it to work. Thanks for your help!

I have another question though. Is there a faster movement function than the drag and drop? I see it click, drag, drop.. but is there a way to speed up the process or make the mouse move faster? With predetermined end coordinates would it be faster to set a click and unclick?

Found the speed modifier. :P

Share this post


Link to post
Share on other sites
Meg

I have a question. I understand the code above and it works perfect in my script.

However I need help with having to repeat this task. Meaning, I need to select the rows below one at time and drag and drop to the window on the right until there are no rows left on the left hand side.

I need to create an array and loop but I am not sure on how to go about doing it.

Thanks.

Share this post


Link to post
Share on other sites
JLogan3o13

@Meg did you happen to notice this post is over 9 years old? Autoit is constantly growing and changing as a language; what worked a decade ago may not work the same now (hopefully it is easier). This is one reason we discourage people from resurrecting very old threads. You will get a lot better response if you simply create a new thread, explaining what you are trying to do (in as much detail as possible), what you have tried on your own (post your code) and what issues, errors, etc. you're having.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Meg

Yes I noticed that, I thought it might still get a response. I had to modify the code a bit so it will work with the new version.

I will start a new thread. Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×