Repeating Macro Topic is solved

Ask gaming related questions (AHK v1.1 and older)
InjectWeed

Repeating Macro

03 Dec 2016, 10:09

Hi! So I'm new to both the forums and to AutoHotKey, and I need a little bit of help running a script. I would like the said script to be able to repeatedly type one message until I press the activating key again. For example, While in a game, I would like it to be able to type Hi over and over again every 5 minutes or so. In addition, if it could be possible to make it run a constant MOUSE 1 BUTTON in the background, where it is constantly pressing the MOUSE 1 BUTTON, and repressing it every time the "Hi" macro is said. If I could get help with this I would really appreciate it, I don't know if this is even possible, but if it is, or something similar to it, I would really appreciate any help.
InjectWeed

Re: Repeating Macro

03 Dec 2016, 12:06

It would also work if it were to just do the "Hi" Text Over and over, I would like that to be the "F" key
luciga
Posts: 30
Joined: 01 Dec 2016, 08:52

Re: Repeating Macro

04 Dec 2016, 16:08

Hello, I can't help you with the mouse click background, but the type part is pretty simple.
If you want to press F:

f: Send {Hi}
If you need to press enter for send the message:
f:: Send Hi {Enter}

If you want to repeat this, use loop:

t::
Loop, 2
{
Send Hi {Enter}
Sleep 300000
}

Put some value after loop (if 0 or just Loop means infinite, and I'm learning about break the infinite loop)
Note 300000 means 5 minutes.
You can remove {Enter} if you don't need to use it for typing in your game. Like this:
t::
Loop, 5 (for example)
{
Send Hi
Sleep 300000
}

Hope it helps you.
Source:
https://autohotkey.com/docs/commands/Loop.htm
https://autohotkey.com/docs/commands/Send.htm
User avatar
evilC
Posts: 4823
Joined: 27 Feb 2014, 12:30

Re: Repeating Macro  Topic is solved

05 Dec 2016, 08:40

Something like this should work (Untested)

Code: Select all

TimerOn := 0
MessageFreq := 1000 * 60 * 5
MessageText := "Hi"
return

$f::
	TimerOn := !TimerOn
	if (TimerOn){
		Send {LButton Down}
		SetTimer, TypeMessage, % MessageFreq
		GoSub, TypeMessage
	} else {
		Send {LButton up}
		SetTimer, TypeMessage, Off
	}
	return

TypeMessage:
	Send {LButton up}
	Send % MessageText
	Send {LButton Down}
	return

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 65 guests