8879899714 Posted August 27, 2007 Share Posted August 27, 2007 hi guys, i need some help here. hope someone here can give me some pointers. i am quite new to this programming thing. just would like to pick up someting new. just hope the experts here can give me some pointers so that i can learn on the way. ok, i have written a short simple program after reading some threads and figuring out. basically, this program is suppose to start when i press F7 and stop when i press F6 again. when the program starts, it will press 1 and 2 with 1 sec interval each. can anyone correct my program? #include <GUIConstants.au3> Dim $start HotKeySet("F7","StartLoop"); when F7 pressed, the loop will start Func StartLoop() $start=1 ; setting the condition EndFunc HotKeySet("F6","QuitLoop"); when F6 is pressed, the loop will stop Func QuitLoop() $start=0 ; setting the condition EndFunc While $Start=1; Start looping continuously until button press Send("1"); 1 is pressed Sleep(100); paused for 1 sec Send("2") ; 2 is pressed Sleep(100); paused for 1 sec Wend; Link to comment Share on other sites More sharing options...
qazwsx Posted August 27, 2007 Share Posted August 27, 2007 use the code box it makes it easier to read. Why do u include gui constants unless i missed somthing i don't think you use them any where. I would declare $start globally, also your script will open and close as soon as u run it because it has nothing to do since $start = "" not 1. I would look at the pause command in the help file and replace the sleep in the pause command with your key pressing code. If any of that was unclear just ask and ill try to explain it better. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 27, 2007 Share Posted August 27, 2007 (edited) More standardized formatting, with the functions at the bottom. Removed the unused #include. Fixed the While/WEnd loop to be functional. Fixed the Sleep() delays to be in seconds (note the parameter is in milliseconds). Added a short Sleep() to the While/WEnd loop to keep from using 100% of CPU time. Added ESC to exit.: Global $start HotKeySet("F7", "StartLoop"); when F7 pressed, the loop will start HotKeySet("F6", "QuitLoop"); when F6 is pressed, the loop will stop HotKeySet("{ESC}", "_Quit") ; when ESC is pressed, exit the script While 1 If $start Then ; Start looping continuously until button press Send("1"); 1 is pressed Sleep(1000); paused for 1 sec Send("2") ; 2 is pressed Sleep(1000); paused for 1 sec EndIf Sleep(20) WEnd Func StartLoop() $start = 1 ; setting the condition EndFunc ;==>StartLoop Func QuitLoop() $start = 0 ; setting the condition EndFunc ;==>QuitLoop Func _Quit() Exit EndFunc ;==>_Quit Edited August 27, 2007 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
8879899714 Posted August 28, 2007 Author Share Posted August 28, 2007 hi guys, thanks for the big pointers. realised that my program really need some good practise and guidance Link to comment Share on other sites More sharing options...
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