Sign in to follow this  
Followers 0
tropunk

Newbie Help: How to make a program run continuously?

5 posts in this topic

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()
    Send("a")
EndFunc   ;==>inputA

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

HotKeySet("+{X}", "inputZ");
Func inputZ()
    Send("z")
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

sleep(1000)

wend

and add a hotkey for the exit func

func _exit()

exit

endfunc

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  
Followers 0