Zerohour Posted September 3, 2005 Share Posted September 3, 2005 Well I've been working my ass off trying to figure out how to do this and I think I've figured it out except I keep getting an error about WEnd. I'm completly lost and out of my league.expandcollapse popup; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box where you can start or stop a script to feed your mag in PSO:BB. Run?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!") Exit EndIf $text = InputBox("AutoIt Example", "Please type in the word ""start"" to initialize or ""stop"" to halt and close the sctipt.") If @error = 1 Then MsgBox(4096, "Error", "You pressed 'Cancel' - Closing!") EndIf If $text = "start" Then MsgBox(4096, "Initalizing", "Starting the script - Here we go!") WinActivate ("PHANTASY STAR ONLINE Blue Burst") $bLoop = 1 $cnt = 0 While $bLoop = 1 sleep( (1000 * 60) ) $cnt = $cnt + 1 if $cnt = 5 then Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $cnt = 16 then Send("{ESC 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ESC 3}") if $cnt > 17 then $cnt = 0; Reseting Timer EndIf If $text = "stop" Then MsgBox(4096, "Halting", "Stoping the script - Goodbye!") $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too :) EndIf ; Print the success message MsgBox(4096,"AutoIt Example", "Script Stoped.") ; FinishedThe error is:Line 81; FinishedError: "While" statement has no matching "WEnd" statement.Any help would be apreciated! Link to comment Share on other sites More sharing options...
Sokko Posted September 3, 2005 Share Posted September 3, 2005 (edited) The error message speaks the truth. Your "While $bLoop = 1" statement has no matching "WEnd", which marks the point at which the code to be looped stops. Like: While $variable = 123 ;Code to be looped as long as $variable equals 123 WEnd Edited September 3, 2005 by Sokko Link to comment Share on other sites More sharing options...
BigDod Posted September 3, 2005 Share Posted September 3, 2005 (edited) expandcollapse popup; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box where you can start or stop a script to feed your mag in PSO:BB. Run?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!") Exit EndIf $text = InputBox("AutoIt Example", "Please type in the word ""start"" to initialize or ""stop"" to halt and close the sctipt.") If @error = 1 Then MsgBox(4096, "Error", "You pressed 'Cancel' - Closing!") EndIf If $text = "start" Then MsgBox(4096, "Initalizing", "Starting the script - Here we go!") WinActivate ("PHANTASY STAR ONLINE Blue Burst") $bLoop = 1 $cnt = 0 [COLOR=red]EndIf[/COLOR] While $bLoop = 1 sleep( (1000 * 60) ) [COLOR=red]WEnd[/COLOR] $cnt = $cnt + 1 if $cnt = 5 then Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $cnt = 16 then Send("{ESC 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ESC 3}") [COLOR=red]EndIf[/COLOR] if $cnt > 17 then $cnt = 0; Reseting Timer EndIf If $text = "stop" Then MsgBox(4096, "Halting", "Stoping the script - Goodbye!") $bLoop = 0 ; Exit the loop - ExitLoop would have been an alternative too :) EndIf ; Print the success message MsgBox(4096,"AutoIt Example", "Script Stoped.") ; Finished I have marked in red the ones that I have noticed EDIT Oops the colouring did not work !!! Edited September 3, 2005 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 Thanks for the speedy replies. Since this was my first time coding ever, I don't think I did too bad! Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 (edited) Err you can only color code in quotes... Edit:Change [ code ] [ / code ]To [ quote ] [ / quote ] Edited September 3, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) That fixed the errors when I tried to start the script but the input box didn't stay open for me to actually type in stop to turn it off. Any sugestions on how to do this? (I know you can turn the script off in the taskbar but I wanted to do a complex setup for my first try so that I could learn more than just send! ) BTW: I was wondering if I could have it setup to select the window each counter period that way I can still do other stuff on my computer. Would that be possible without interupting the script? Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 You would need a GUI to stay up if you wanted to use "Stop and Start". What exactly would you like to do... and maybe we could give an idea on how we would attempt it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) I was attempting to make my script into a trashy app What I want it do is to have the input box continue to run while the script is going, that way you can turn it off and on without completly disabling it.i.e. You typed start into the box and the script start! Wooo! but you need to stop it and you want to be lazy so you just type stop into the box. Viola, the script is stoped and you can easily start it up again.Maby a better solution would to be a "pause" feature.Is that even possible with autoit?Also, could someone please answer this?BTW: I was wondering if I could have it setup to select the window each counter period that way I can still do other stuff on my computer. Would that be possible without interupting the script? Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 The pause button would be a HotKey.... (nicely demonstrated in the helpfile) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Valuater Posted September 3, 2005 Share Posted September 3, 2005 heres a small idea... i think it looks cleaner ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box where you can start or stop a script to feed your mag in PSO:BB. " & @CRLF & @CRLF & " Please press yes to *Run* the program ") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!", 1.5) Exit EndIf the original message has two lines and the "good bye" message box leaves after 1.5 seconds you should use this same timer idea on the other " good bye" message boxes hope that helps 8) Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) Hmmm, I guess it was overkill to have "start" and "stop" in there than. I'll dig around the help file and see what I can pull up on the "hotkey". Everything that's part of the script I've stolen from the example files. Just the way I learn I guess.Any suggestions on how I should remove the input box then?heres a small idea... i think it looks cleaner; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box where you can start or stop a script to feed your mag in PSO:BB. " & @CRLF & @CRLF & " Please press yes to *Run* the program ") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!", 1.5) Exit EndIfthe original message has two lines and the "good bye" message box leaves after 1.5 secondsyou should use this same timer idea on the other " good bye" message boxeshope that helps8)<{POST_SNAPBACK}>I'll look into it. I think I'm the only person who's going to use it so I don't really care. Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) Going into the help file I found the script for pausing but I'm curious. Global $Paused HotKeySet("{PAUSE}", "TogglePause") is obvious enough but, Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Wouldn't that mean that the script would only be paused for .1 sec? Not to mention I'm still not exactly sure how I should cutout the input box either. Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 (edited) expandcollapse popup#include <GUICONSTANTS.AU3> Opt("WINTITLEMATCHMODE", 4) Global $Paused HotKeySet("{PAUSE}", "TogglePause") $MAIN_GUI = GUICreate("AutoIt Example", 125, 50) $BUTTON_1 = GUICtrlCreateButton("START", 10, 10, 50, 30, $BS_DEFPUSHBUTTON) $BUTTON_2 = GUICtrlCreateButton("STOP", 65, 10, 50, 30, $BS_DEFPUSHBUTTON) GUISetState() While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE Exit Case $MSG = $BUTTON_1 MAIN_LOOP() Case $MSG = $BUTTON_2 If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4,"Exit Chose","Are you sure you want to Exit?") Select Case $iMsgBoxAnswer = 6 Exit EndSelect EndSelect WEnd Func MAIN_LOOP() $CNT = 0 While 1 Sleep(60000) $CNT = $CNT + 1 If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") If $CNT = 5 Then Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $CNT = 16 Then If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") Send("{ESC 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ESC 3}") $CNT = 0 EndIf WEnd EndFunc ;==>MAIN_LOOP Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc ;==>TogglePauseYou can add whatever you want to it...EDIT: Forgot to add something for $Button_2 (Stop)EDIT_2: Had counter in the wrong place. Edited September 3, 2005 by ronsrules Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
quick_sliver007 Posted September 3, 2005 Share Posted September 3, 2005 Going into the help file I found the script for pausing but I'm curious.Global $PausedHotKeySet("{PAUSE}", "TogglePause")is obvious enough but,Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("")EndFuncWouldn't that mean that the script would only be paused for .1 sec?Not to mention I'm still not exactly sure how I should cutout the input box either. <{POST_SNAPBACK}>Think of While $paused as While 1. Also think of $paused = NOT $paused as...If $paused = 0 then $paused = 1 Else $paused = 0 EndIfSo if $paused = 1 then the loop runs until $paused = 0.Also think of 1 as true and 0 as false. So it is like if $paused = true then do loop, if pause = false then don't do loop. . Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) I'm a bit confused on how you set up the counter. Why'd you put it at the end? I had set the counter up so that every minute it added 1. With the counter set up like that would it still work the same? The code winds up looking like this when I edited it using how you set it up. Please correct me if this is wrong. expandcollapse popup#include <GUICONSTANTS.AU3> Opt("WINTITLEMATCHMODE", 4) Global $Paused HotKeySet("{PAUSE}", "TogglePause") $MAIN_GUI = GUICreate("AutoIt Example", 125, 50) $BUTTON_1 = GUICtrlCreateButton("START", 10, 10, 50, 30, $BS_DEFPUSHBUTTON) $BUTTON_2 = GUICtrlCreateButton("STOP", 65, 10, 50, 30, $BS_DEFPUSHBUTTON) GUISetState() While 1 $MSG = GUIGetMsg() Select Case $MSG = $GUI_EVENT_CLOSE Exit Case $MSG = $BUTTON_1 MAIN_LOOP() Case $MSG = $BUTTON_2 If Not IsDeclared("iMsgBoxAnswer") Then Dim $iMsgBoxAnswer $iMsgBoxAnswer = MsgBox(4,"Exit Chose","Are you sure you want to Exit?") Select Case $iMsgBoxAnswer = 6 Exit EndSelect EndSelect WEnd Func MAIN_LOOP() $CNT = 0 While 1 Sleep(60000) $CNT = $CNT + 1 If $CNT = 5 Then If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $CNT = 10 Then If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $CNT = 15 Then If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $CNT = 16 Then If Not WinActive("PHANTASY STAR ONLINE Blue Burst") Then WinActivate("PHANTASY STAR ONLINE Blue Burst") Send("{ESC 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ESC 3}") $CNT = 0 EndIf WEnd EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Edit: Fixed the code because of the mistake I notcied! Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 lol that was a mistake.... I'll fix it Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 (edited) That's awsome! Makes me feel good that I'm noticing stuff and learning the code! and props to quicksilver for helping me understand how the pause func works! Edited September 3, 2005 by Zerohour Link to comment Share on other sites More sharing options...
Zerohour Posted September 3, 2005 Author Share Posted September 3, 2005 rons with your code I'm getting a new error Error reading the file: GUICONSTANTS.AU3 Any info on fixing? Link to comment Share on other sites More sharing options...
Valuater Posted September 3, 2005 Share Posted September 3, 2005 (edited) I thought you wanted to stay hidden (no gui).. so i did this expandcollapse popup; Press Esc to terminate script, Pause/Break to "pause" Global $Paused, $bLoop, $cnt = "", $text HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("{F1}", "ShowMessage") ; Prompt the user to run the script - use a Yes/No prompt (4 - see help file) $answer = MsgBox(4, "AutoIt Example (English Only)", "This script will open an input box where you can start or stop a script to feed your mag in PSO:BB. " & @CRLF & @CRLF & " Please press yes to *Run* the program ") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $answer = 7 Then MsgBox(4096, "AutoIt", "OK. Bye!", 1.5) Exit EndIf Call("ShowMessage") While $bLoop = 1 $cnt = $cnt + 1 if $cnt = 5 then Send("{ESC 3}") Sleep(500) Send("{F4}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ENTER}") Sleep(3000) Send("{ESC 5}") EndIf If $cnt = 16 then Send("{ESC 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN 3}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{DOWN}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ENTER}") Sleep(500) Send("{ESC 3}") EndIf if $cnt > 17 then $cnt = 0; Reseting Timer EndIf WEnd ; Print the success message MsgBox(4096,"AutoIt Example", "Script Stoped.", 4) Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() $text = InputBox("AutoIt Example", "Please type in the word ""start"" to initialize or ""stop"" to halt and close the sctipt.") If @error = 1 Then MsgBox(4096, "Error", "You pressed 'Cancel' - Closing!", 3) $bLoop = 0 EndIf If $text = "stop" Then MsgBox(4096, "AutoIt", "OK. Bye!", 1.5) Exit EndIf If $text = "start" Then MsgBox(4096, "Initalizing", "Starting the script - Here we go!") WinActivate ("PHANTASY STAR ONLINE Blue Burst") $bLoop = 1 $cnt = 0 EndIf EndFunc ; Finished but ron got there first too.... dag nabbit 8) Edited September 3, 2005 by Valuater Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted September 3, 2005 Moderators Share Posted September 3, 2005 What version are you using? How did you install it? Is you input folder in the correct spot? On my computer it's: C:\Program Files\AutoIt3\Include Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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