Sign in to follow this  
Followers 0
LiberrY

Macro creation

10 posts in this topic

Hi there, im not very new to AutoIt but im not perfect in scripting :P now my question: how do i do something like this: i press "q" and the script presses 5 times left mouse button

i thought something like that:

$var1=?pressedkey?("q")

while $var1=$var1

do mouseclick("left")

do mouseclick("left")

do mouseclick("left")

do mouseclick("left")

do mouseclick("left")

wend

Share this post


Link to post
Share on other sites



#include <Misc.au3>
HotKeySet("{ESC}", "Leave")
HotKeySet("q", "ClickMe")
While 1
    Sleep(10) ; For CPU usage sake
WEnd

Func ClickMe()
    While _IsPressed("51") ; Wait until Q is released to do action
        Sleep(10) ; Waiting for Q to be released to perform action
    WEnd
    MouseClick("Left", MouseGetPos(0), MouseGetPos(1), 5) ; Action: Click left mouse button 5 times where mouse currently sitsq
EndFunc   ;==>ClickMe

Func Leave()
    Exit
EndFunc   ;==>Leave

Share this post


Link to post
Share on other sites

thx guy for quick reply, the script is working but only when i press q for a while, so when i press q only very short it is only pressing left mouse button one time, when i hold q 3-5 seconds its doing its job.

maybe this is fixable?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Ooops, forgot to switch the hotkey status.

#include <Misc.au3>
HotKeySet("{ESC}", "Leave")
HotKeySet("q", "ClickMe")
While 1
    Sleep(10) ; For CPU usage sake
WEnd

Func ClickMe()
    HotKeySet("q", "Nothing" )
    While _IsPressed("51") ; Wait until Q is released to do action
        Sleep(10) ; Waiting for Q to be released to perform action
    WEnd
    MouseClick("Left", MouseGetPos(0), MouseGetPos(1), 5) ; Action: Click left mouse button 5 times where mouse currently sitsq
    HotKeySet("q", "ClickMe")
EndFunc   ;==>ClickMe

Func Nothing()
    Sleep(1); Nothing
EndFunc

Func Leave()
    Exit
EndFunc   ;==>Leave

EDIT: Second oops, Fixed so you don't get q's pressed at all

Edited by danwilli

Share this post


Link to post
Share on other sites

thank you, but it does only half its job, because sometimes it only presses one time, sometimes 3, sometimes nothing happens, everytime its based on how long i press q. when i only tip it it only presses one time.

Share this post


Link to post
Share on other sites

Perhaps the game is not picking up the clicks fast enough.

Try this with delay:

#include <Misc.au3>
Global $delay = 10 ; Adjust delay here
HotKeySet("{ESC}", "Leave")
HotKeySet("q", "ClickMe")
While 1
    Sleep(10) ; For CPU usage sake
WEnd

Func ClickMe()
    HotKeySet("q", "Nothing" )
    While _IsPressed("51") ; Wait until Q is released to do action
        Sleep(10) ; Waiting for Q to be released to perform action
    WEnd
    For $a = 1 To 5
        MouseClick("Left") ; Action: Click left mouse button 5 times where mouse currently sitsq
        Sleep($delay)
    Next
    HotKeySet("q", "ClickMe")
EndFunc   ;==>ClickMe

Func Nothing()
    Sleep(1); Nothing
EndFunc

Func Leave()
    Exit
EndFunc   ;==>Leave

Share this post


Link to post
Share on other sites

sry, but not really working.

btw, where did you know from that its for a game xD

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

ahh thank you, i edited the script a little bit so that its working perfect now, again thank you very much, you're my hero now xD

EDIT: can someone pls tell me how to use "Shift" as hotkey? i know that ALT is "!" but what is shift?

edit2: i found out how it works :P but thx

Edited by LiberrY

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