AHK Timer based Text sending script

I'd like to create a script that is toggled by a key. It would say about 10 lines of text, 1 line per 15 seconds. Can someone help me?

Thank you!

Posted Oct 8, 2017, 4:29 AM UTC

12
GroggyOtter•

Making a toggle can be found in the "Read This Before Posting!" stickied tutorial post.

Sending characters is done with Send.

Sleep can be used for creating delays

A more sophisticated way would be using a SetTimer.

Hope this helps you create your script.

1
elbitjusticiero•

Your description of what you want is too brief. Do you already know which strings you'll be sending, and what should happen when you've already sent all ten? Should the script stop sending text or wrap around and go on?

EDIT: I made some assumptions so that I could at least attempt to help you. This is a short script that toggles this behaviour with the F1 key (press F1 to start cycling, press F1 again to deactivate it). It wraps around so it's always sending the same strings over and over. Edit the strings array to put your own strings there.

F1::
	SendIt() {
		Static doit    := false
		Static strings := [ "Hello"
		                  , "world"
		                  , "whassuuuup!!!" ]
		doit := !doit 
		
		if ( doit ) { 
			SetTimer, SendIt_Main, 1500
		} else {
			SetTimer, SendIt_Main, off
		}
	
	SendIt_Main: 
		TextToSend := strings.RemoveAt(1) 
		SendRaw % TextToSend "`n"
		strings.Push(TextToSend) 
	return
	} 
return

I tested it minimally so it should work well.

1