Jump to content
Sign in to follow this  

Newbie Help: How to make a program run continuously?

Recommended Posts


Hello guys, I just registered here.

I've been looking on AutoIt for a week now, amazing language...but got stuck in this one.

I'm making a program to input certain characters for certain keys.

Here's a smaller version of what I want:

HotKeySet("+{S}", "inputA");
Func inputA()
EndFunc   ;==>inputA

HotKeySet("+{W}", "inputQ");
Func inputQ()
EndFunc   ;==>inputQ

HotKeySet("+{X}", "inputZ");
Func inputZ()
EndFunc   ;==>inputZ

Now the problem is, upon executing, the program runs one-off and exits.

I want it to run continuously until I press End or something.

I tried _isPressed in While/WEnd but then realized functions don't work in loops :-P

Is there anything that'll make the program stop until certain key is pressed? It doesn't have the good old getch(); :-(

Share this post

Link to post
Share on other sites

Put this at the bottom to keep yout script alive

while 1



and add a hotkey for the exit func

func _exit()



Worked...thanks a lot man!

But hey, this seems magic to me.

I need a theoretical explaination...the sleep function gets the delay of just 1 sec. then how come its looping continuously?

Share this post

Link to post
Share on other sites

Basically the script is just asleep forever/until you exit.

HotkeySet function will interupt the current function ( which is Sleep() ) and run the called function.

Alright...that great! Never came across this idea :mellow:

Thanks again dude!

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.