Sign in to follow this  
Followers 0
tammelol

Click and drag on command

11 posts in this topic

#1 ·  Posted (edited)

Hello, i'm totally new to scripting. I'd only like to get a script done which will drag and drop x,y to x,y on my command when pressing numpad keys (8,4,5,6). And so it wouldn't just complete the loop and close. I want it to be open and available whenever i press any of the numpad keys.

Can someone guide me through this process, so far i've managed to make it drag and drop but i don't know how to apply a faster speed or how to assign it on a specific button command.

Or if someone has too much free time would be willing to make this script for me :D

Kind Regards, tammelol

Edited by tammelol

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

There are many tutorial options to choose from. Go to Youtube.com and search keyword 'AutoIt Tutorial' a slew of options will appear for you. You use the same keyword and search the forums here, and you will also find multiple options.

Once you have a basic understanding of AutoIt, then lookup these following functions. They will give you a head start towards what you ask.

HotKeySet() ;Use this to set your Hotkeys (8,4,5,6)

MouseClickDrag() ; There is a parameter for setting the speed at which the mouse will move.

Now, after writing your first script, and you still having problems with it. Provide your script here, or at least show an example of it, and more ppl will be willing to respond and help you.

Asking for someone to make your script for you, is not going to work, there are freelance scripting sites that will cover those services.

Good Luck & Hope to see you around :D

Realm

Edit: btw, Welcome to the AutoIt Forums :oops:

Edited by Realm

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry.  

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thanks for reply and yes, i knew asking to someone to make a script for me is just... well stupid. Well, anyway this is what i have so far ( i decided to go with arrow keys ) but i keep getting error with HotKeySet command. However i managed to make it endless sleep. Perhaps someone can tell me what i am doing wrong.

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d
HotKeySet ( "{RIGHT}", "MouseClickDrag({left}, 400, 500, 500, 500")
While 1
    Sleep(100)
WEnd
;;;;;;;;
Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
Func Terminate()
    Exit 0
EndFunc
Func ShowMessage()
    MsgBox(4096,"","This is a message.")
EndFunc

It's the part with the HotKeySet RIGHT

EDIT: I managed to make it endless sleep and do the right drag but it occurs right away and not on my command

i changed the line to

HotKeySet ( "{RIGHT}", MouseClickDrag("left", 400, 500, 500, 500))
Edited by tammelol

Share this post


Link to post
Share on other sites

Sorry for double post, unable to edit, nevermind, i got it doing what i want, and it's getting interesting :D

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You have to put the MouseClickDrag in a function, and call that function with HotKeySet.

edit: Oh, I guess you don't..

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

tammelol,

The syntax is wrong...should be

HotKeySet("{RIGHT}", MouseClickDrag("left", 400, 500, 500, 500))

However, when I run this it immediatley executes the mousedrag and then loops.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Well i got it working like this

HotKeySet("{RIGHT}", "_Site1")
HotKeySet("{LEFT}", "_Site2")
HotKeySet("{UP}", "_Site3")
HotKeySet("{DOWN}", "_Site4")
Func _Site1()
MouseClickDrag("left", 400, 500, 500, 500, 3)
EndFunc ;==> _Site1
Func _Site2()
MouseClickDrag("left", 400, 500, 300, 500, 3)
EndFunc ;==> _Site2
Func _Site3()
MouseClickDrag("left", 400, 500, 400, 400, 3)
EndFunc ;==> _Site3
Func _Site4()
MouseClickDrag("left", 400, 500, 400, 600, 3)
EndFunc ;==> _Site4

But it's reactions are like really slow, the mouse is instantly in place yes but it takes like half a second to start dragging which is too long, i need it to start dragging immediately when i click.

Edited by tammelol

Share this post


Link to post
Share on other sites

tammelol,

Perhaps hotkeyset is not your best option. Can you explain exactly what you are trying to do. Also, consider the fllowing code:

#include <misc.au3>
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d
While 1
Sleep(100)
if _ispressed("02") then MouseClickDrag("left", 400, 500, 500, 500)
WEnd
;;;;;;;;
Func TogglePause()
$Paused = NOT $Paused
While $Paused
sleep(100)
ToolTip('Script is "Paused"',0,0)
WEnd
ToolTip("")
EndFunc
Func Terminate()
Exit 0
EndFunc
Func ShowMessage()
MsgBox(4096,"","This is a message.")
EndFunc

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

kylomas,

Well to put it simply, it's kind of a rhytm game, where arrows come and at the right time you need to drag a thingie in the direction the arrow is showing, as the tempo keeps increasing, it's difficult to control it with mouse, so i want to try this with keyboard controls, so plainly i need it to react as fast or faster than conventional mouse control. I know it sounds like a bunch of nonsense but it means a lot to me.

I tried your script but no known button on the keyboard sets off the command

MouseClickDrag("left", 400, 500, 500, 500)

Share this post


Link to post
Share on other sites

tammelol,

Whooops!!! No "gaming" stuff allowed here. PLease see rules...

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

The rules are crying because of this thread. Locked.

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0