Jump to content

Macro creation


LiberrY
 Share

Recommended Posts

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

Link to comment
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

Link to comment
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?

Link to comment
Share on other sites

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
Link to comment
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
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...