oozma Posted February 27, 2009 Posted February 27, 2009 Hi All, First time creating an AutoIT script here. Below is a code that I've made, but I keep returning the error of: REF: missing Wend. While ^ ERROR: syntax error WEnd I've read through help and many threads, I'm not sure what I'm doing wrong... :/ Can anyone help? Thank you. While 1 = 1 call ("hs") Func HS() $hc = 0 Do Send (1) sleep(100) MouseClick("Right") sleep(5000) $hc = $hc + 1 Until $hc = 1 EndFunc Call ("MM") Func MM() $mc = 0 Do Send(8) sleep(100) MouseClick("Left") sleep(2200) $mc = $mc + 1 Until $mc = 22 EndFunc WEnd
Andreik Posted February 27, 2009 Posted February 27, 2009 The body of functions shouldn't be in any kind of loops. While 1 Call ("hs") Call ("MM") WEnd Func HS() $hc = 0 Do Send (1) sleep(100) MouseClick("Right") sleep(5000) $hc = $hc + 1 Until $hc = 1 EndFunc Func MM() $mc = 0 Do Send(8) sleep(100) MouseClick("Left") sleep(2200) $mc = $mc + 1 Until $mc = 22 EndFunc
oozma Posted February 27, 2009 Author Posted February 27, 2009 I love you saved me such a headache... other programs I've used are so different
oozma Posted February 27, 2009 Author Posted February 27, 2009 Sorry again for a question, how about... The hotkeys of !1 and !2 don't start or stop the script. It seems to stop instantly by itself I'm assuming it's something like... no while inside of a function. Thank you again for any help someone can offer. expandcollapse popupHotKeySet ("!1","Start") HotKeySet ("!2","Stop") Func Start() While 1 Call ("hs") Call ("MM") Call ("R") WEnd EndFunc Func Stop() ExitLoop EndFunc;==> Quit Func HS() $hc = 0 Do Send (1) sleep(50) MouseClick ("Right") sleep(5000) $hc = $hc + 1 Until $hc = 1 EndFunc;==> HS Func MM() $mc = 0 Do Send(8) sleep(50) MouseClick ("Left") sleep(2200) $mc = $mc + 1 Until $mc = 3 EndFunc;==> MM Func R() Send (0) sleep(50) MouseClick ("Left") sleep(230000) EndFunc;==> Resting
Zedna Posted February 27, 2009 Posted February 27, 2009 (edited) No need to use Call() in this case. expandcollapse popupHotKeySet ("!1","Start") HotKeySet ("!2","Stop") HotKeySet ("!3","Quit") Global $running = False While 1 If $running Then HS() MM() R() EndIf Sleep(100) WEnd Func Start() $running = True EndFunc Func Stop() $running = False EndFunc Func Quit() Exit EndFunc Func HS() $hc = 0 Do Send (1) sleep(50) MouseClick ("Right") sleep(5000) $hc = $hc + 1 Until $hc = 1 EndFunc;==> HS Func MM() $mc = 0 Do Send(8) sleep(50) MouseClick ("Left") sleep(2200) $mc = $mc + 1 Until $mc = 3 EndFunc;==> MM Func R() Send (0) sleep(50) MouseClick ("Left") sleep(230000) EndFunc;==> Resting Edited February 27, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
oozma Posted February 27, 2009 Author Posted February 27, 2009 Thank you much but when I compile, the start and quit hotkeys work but stop does nothing. It keeps running even after Alt+2
Zedna Posted February 27, 2009 Posted February 27, 2009 Thank you much but when I compile, the start and quit hotkeys work but stop does nothing. It keeps running even after Alt+2 After stop it finishes all three already running functions.It can be checked $running state also inside these functions to stop immediatelly. Resources UDF ResourcesEx UDF AutoIt Forum Search
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