Sign in to follow this  
Followers 0
llllJakubllll

Need Help

14 posts in this topic

I have never written a script in my life.

I'm looking for a way to set several keys on my keyboard to perform mouse clicks. So for example pressing "1" would trigger a mouseclick at x 375 y 764 coordinates.

Can anyone help me out with this please?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have never written a script in my life.

I'm looking for a way to set several keys on my keyboard to perform mouse clicks. So for example pressing "1" would trigger a mouseclick at x 375 y 764 coordinates.

Can anyone help me out with this please?

As a quick example.

HotKeySet("1", "one")

While 1
    Sleep(150)
WEnd

Func one()
    MouseMove(1,1)
Endfunc

I did a MouseMove but you would want to use a MouseClick.

Edited by schilbiz

Share this post


Link to post
Share on other sites

As a quick example.

HotKeySet("1", "one")

While 1
    Sleep(150)
WEnd

Func one()
    MouseMove(1,1)
Endfunc

I did a MouseMove but you would want to use a MouseClick.

So would the (1,1) be the x and y coordinates. For example MouseClick(437,582)?

Share this post


Link to post
Share on other sites

Welcome to the forums.

Yes the 1,1, is a x,y coord

However the Mouseclick() also needs the button

MouseClick('left',x,y)

The help file details all of this along with the other options for the functions.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Well my script looks like this:

HotKeySet("1", "one")

While 1

Sleep(150)

WEnd

Func one()

MouseClick('left'431,597)

Endfunc

When I double click to script to execute it I see it appear below in my taskbar and when I press 1 i get the following error message:

Line 9 (File C:\Documents and Settings\Jakub\My Documents\helloworld.au3"):

MouseClick('left'431,597)

MouseClick(^ ERROR

Error: Error in expression.

Edited by llllJakubllll

Share this post


Link to post
Share on other sites

I also tried removing the ' around left and adding a , and a space, etc.

Share this post


Link to post
Share on other sites

it should be smt like this:

HotKeySet("1", "one")

While 1
    Sleep(150)
WEnd

Func one()
    MouseClick("left", 431, 597)
Endfunc

Share this post


Link to post
Share on other sites

Your error was the single quote ' around the word left.

You needed a "

MouseClick("left",431,597)

Share this post


Link to post
Share on other sites

it should be smt like this:

HotKeySet("1", "one")

While 1
    Sleep(150)
WEnd

Func one()
    MouseClick("left", 431, 597)
Endfunc
Ok awesome it works, is there any way to speed this up now. The mouse moves pretty slow - I would like the motion to be as quick as possible. I tried changing the sleep to 50 thinking that may speed it up but it didnt change anything.

Share this post


Link to post
Share on other sites

I wanted to add 3 more functions and I was unable too. Do they all have to have their own scripts?

HotKeySet("1", "one")

While 1

Sleep(150)

WEnd

Func one()

MouseClick("left", 590, 498)

Endfunc

HotKeySet("2", "two")

While 2

Sleep(150)

WEnd

Func two()

MouseClick("left", 578, 549)

Endfunc

HotKeySet("3", "three")

While 3

Sleep(150)

WEnd

Func three()

MouseClick("left", 691, 499)

Endfunc

HotKeySet("4", "four")

While 4

Sleep(150)

WEnd

Func four()

MouseClick("left", 582, 598)

Endfunc

Share this post


Link to post
Share on other sites

I wanted to add 3 more functions and I was unable too. Do they all have to have their own scripts?

HotKeySet("1", "one")

While 1

Sleep(150)

WEnd

Func one()

MouseClick("left", 590, 498)

Endfunc

HotKeySet("2", "two")

While 2

Sleep(150)

WEnd

Func two()

MouseClick("left", 578, 549)

Endfunc

HotKeySet("3", "three")

While 3

Sleep(150)

WEnd

Func three()

MouseClick("left", 691, 499)

Endfunc

HotKeySet("4", "four")

While 4

Sleep(150)

WEnd

Func four()

MouseClick("left", 582, 598)

Endfunc

inspired by you i tried to make smt like this instead for finishing my bot :D and i think u should try this out

Global $paused
HotKeySet("{F3}", "togglepause")
HotKeySet("{ESC}", "terminate")
HotKeySet("1", "one")
HotKeySet("2", "two")
HotKeySet("3", "three")
HotKeySet("4", "four")

Func TogglePause()
    $paused = Not $paused
    While $paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip('Script is "Running"', 0, 0)
EndFunc  ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc  ;==>Terminate





While 1
    Sleep(150)
WEnd

Func one()
    MouseClick("left", 590, 498)
EndFunc  ;==>one



While 2
    Sleep(150)
WEnd

Func two()
    MouseClick("left", 578, 549)
EndFunc  ;==>two



While 3
    Sleep(150)
WEnd

Func three()
    MouseClick("left", 691, 499)
EndFunc  ;==>three



While 4
    Sleep(150)
WEnd

Func four()
    MouseClick("left", 582, 598)
EndFunc  ;==>four

I added an Pause and exit, so if u press F3 u will pause / unpause the script and ESC will end it. the functions u addad look okay just be sure to use right cords

and please start using code tags

Share this post


Link to post
Share on other sites

Azaw is f3 supposed to pause the script and disable the hotkeys so you can use the numbers 1-4 because even when paused the hotkeys still work?

Also is this the quickest it can go?

Share this post


Link to post
Share on other sites

Azaw is f3 supposed to pause the script and disable the hotkeys so you can use the numbers 1-4 because even when paused the hotkeys still work?

Also is this the quickest it can go?

Assuming you use SciTE you should look up MouseClick in Help, it will give you all the information you need to get started with MouseClick. I have added and removed a few things from Azaw's script so that it will do what you are asking, and about as fast as it can.

Global $paused
HotKeySet("1", "one")
HotKeySet("2", "two")
HotKeySet("3", "three")
HotKeySet("4", "four")
HotKeySet("{F3}", "togglepause")
HotKeySet("{ESC}", "terminate")

While 1
    Sleep(150)
WEnd

Func one()
    MouseClick("left", 590, 498, 1, 1)
EndFunc ;==>one

Func two()
    MouseClick("left", 578, 549, 1, 1)
EndFunc ;==>two

Func three()
    MouseClick("left", 691, 499, 1, 1)
EndFunc ;==>three

Func four()
    MouseClick("left", 582, 598, 1, 1)
EndFunc ;==>four

Func TogglePause()
    $paused = Not $paused
    While $paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip('Script is "Running"', 0, 0)
EndFunc ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc ;==>Terminate

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  
Followers 0