Page 1 of 1

Setting up a loop macro for a game

Posted: 27 Oct 2020, 13:25
by ricardo_rafael
Hi, I'm trying to configure some scrip that allow to spam some keys

The idea is when I press F3, the macro automatically send the key 7 and then create a loop between F3 + Left click and finally when I press again F3 the macro stops/Start

So need the macro send one time the "7" key before the spam loop between F3 + left click and also I want the way to activate/deactivate the macro pressing the same key of the loop which is in this case F3

Here is the macro:

Code: Select all

#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetMouseDelay, -1
SetDefaultMouseSpeed, 0
SetWinDelay, -1
SetControlDelay, -1
SendMode Input
#SingleInstance, Force   <- I don't know if this line is the problem, I'm set this here because I don't want more than one macro like this works at the same time
FileCreateDir,%A_ScriptDir%\tut Assets
SetWorkingDir,%A_ScriptDir%\tut Assets

f3::
loop
{
GetKeyState, state, f3,P
if state = U
break
sleep, 5
send, {7}
sleep, 5
send, {f3}
sleep, 5
send, {Click, down}
sleep, 5
send, {Click, up}
}
return
Esc::ExitApp

This configuration is the only one that actually work well but don't allow send the "7" key before the loop

Code: Select all

f3::
loop
{
GetKeyState, state, f3,P
if state = U
break
sleep, 5
send, {f3}
sleep, 5
send, {Click, down}
sleep, 5
send, {Click, up}
}
return
[Mod edit: [code][/code] tags added.]

I am learning ahk, so I'm not an expert but I being starting to understand the basics

Thanks in advance!