m0rfin Posted August 20, 2008 Posted August 20, 2008 Hi, im trying to make a simple timer script that presses a key in a certain time. But i cant get it to loop.. so i was wondering if someone could help me? Func toggla() Send ("{F9}") Sleep(120000) Send ("{F8}") Sleep(25000) EndFunc HotKeySet("f","toggla"); While 1 WEnd
Kerros Posted August 20, 2008 Posted August 20, 2008 (edited) Your loop is not calling anything. try this HotKeySet("f","toggla"); Placing the hotkey in here is not necessary, but will allow you to do the function manually if you want to. HotKeySet("{ESC}", "Terminate");a way to break out of the script While 1 Toggla() sleep(100); or however long you want to wait in microseconds. WEnd Func toggla() Send ("{F9}") Sleep(120000) Send ("{F8}") Sleep(25000) EndFunc Func Terminate() Exit EndFunc Edited August 20, 2008 by Kerros Kerros===============================================================How to learn scripting: Figure out enough to be dangerous, then ask for assistance.
therks Posted August 20, 2008 Posted August 20, 2008 Have a look at the example for HotKeySet. I'm sure you can modify that to suit your needs. My AutoIt Stuff | My Github
martin Posted August 20, 2008 Posted August 20, 2008 (edited) Hi, im trying to make a simple timer script that presses a key in a certain time. But i cant get it to loop.. so i was wondering if someone could help me? Func toggla() Send ("{F9}") Sleep(120000) Send ("{F8}") Sleep(25000) EndFunc HotKeySet("f","toggla"); While 1 WEndThe way you have written your scipt means that when you press the key f the function toggla will be called. It will execute the statements then finish. You could change the function so that it keeps looping like this Func toggla() while 1 Send ("{F9}") Sleep(120000) Send ("{F8}") Sleep(25000) wend endfunc You then have a problem because there is no way to stop it looping. So have some way of stopping Toggla. Maybe like this Global $keepGoing HotKeySet("f", "toggla"); HotKeySet("g", "EndToggla") While 1 sleep(100);add a sleep here or it will use a lot of CPU time when it's not executing toggla WEnd Func toggla() $keepGoing = True While $keepGoing = True Send("{F9}") Sleep(120000) Send("{F8}") Sleep(25000) WEnd EndFunc ;==>toggla Func EndToggla() $keepGoing = False EndFunc ;==>EndToggla Edited August 20, 2008 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now