Jump to content
Sign in to follow this  
Scriptmaster

Script repeat needed

Recommended Posts

Scriptmaster

Hello GUIs (Pun)

Jokes aside I am currently creating a simple bit of software that executes a human command (like open cd tray) fed in through an inputbox which is then executed as autoit3

the script goes like this

(Not actual script, real one 960 lines!)

dim $question
$question = inputbox("command", "Type your command", "")
if $question = "cd tray open"
      cdtray("D:", "open")
endif
if $question = "shutdown"
      shutdown(1)
endif

Sorry for any messups in my code the real one works.

at the end of my script i want an inputbox where you can type in yes/no then an mini version of the full script above.

dim $question
$question = inputbox("command", "do you want to go again?", "YES/NO")
if $question = "no"
       "WHAT DO I HAVE TO TYPE TO STOP THE SCRIPT"
endif
if $question = "shutdown"
       "RE-START SCRIPT"
endif

I would use 'goto' but it does not work?

I need the script to re-start from line 8 (after variables declared(time/date/username/shutdown password))

I can not put it into an infinate loop because if I use a hotkey to exit it will stop slap bang in the middle of my script (BAD!!!!)

please could someone help...


shutdown(1)

Share this post


Link to post
Share on other sites
qsek

How about using functions? :) (Pun)

Look here: http://www.autoitscript.com/autoit3/docs/faq.htm#4

Edited by qsek

Teamspeak 3 User Viewer - Quick and functional TS3 Query script, which shows online users.Cached Screenshot Deleter - Deletes older Fraps Screenshots if they exceed a specified limit.Unresolved Topics:Intercept and modify dragdrop text behaviour in scite

Share this post


Link to post
Share on other sites
Robjong

; using InputBox
_Foo()
Dim $sAnswer
While 1
    $sAnswer = InputBox("Repeat?", "do you want to go again?", "YES/NO")
    If @error Then
        ConsoleWrite("!> INPUTBOX CANCELED/CLOSED" & @CRLF)
        ExitLoop
    ElseIf $sAnswer = "no" Then
        ConsoleWrite("-> STOP SCRIPT" & @CRLF)
        ExitLoop
    ElseIf $sAnswer = "yes" Then
        ConsoleWrite("-> RE-START SCRIPT" & @CRLF)
        _Foo()
    Else
        ConsoleWrite("!> INVALID ANSWER" & @CRLF)
    EndIf
WEnd

Func _Foo()
    ConsoleWrite("RUN SCRIPT" & @CRLF)
    ; script here ...
EndFunc


; using MsgBox
_Bar()

Dim $iAnswer
While 1
    $iAnswer = MsgBox(4, "Repeat?", "do you want to go again?")
    If $iAnswer = 7 Then
        ConsoleWrite("-> STOP SCRIPT" & @CRLF)
        ExitLoop
    ElseIf $iAnswer = 6 Then
        ConsoleWrite("-> RE-START SCRIPT" & @CRLF)
        _Bar()
    EndIf
WEnd

Func _Bar()
    ConsoleWrite("RUN SCRIPT" & @CRLF)
    ; script here ...
EndFunc

Share this post


Link to post
Share on other sites
Scriptmaster

That does not make sense.

If you type no it plays the script and if you type yes it asks you (Yes/no) again

but i have removed the first

; using InputBox
_Foo()
Dim $sAnswer
While 1
    $sAnswer = InputBox("Repeat?", "do you want to go again?", "YES/NO")
    If @error Then
        ConsoleWrite("!> INPUTBOX CANCELED/CLOSED" & @CRLF)
        ExitLoop
    ElseIf $sAnswer = "no" Then
        ConsoleWrite("-> STOP SCRIPT" & @CRLF)
        ExitLoop
    ElseIf $sAnswer = "yes" Then
        ConsoleWrite("-> RE-START SCRIPT" & @CRLF)
        _Foo()
    Else
        ConsoleWrite("!> INVALID ANSWER" & @CRLF)
    EndIf
WEnd

and it works like a charm. thanks for your help I appreciate it, I will give credit.

when I am finished i will upload, if you type credits it will bring up your name!

Edited by Scriptmaster

shutdown(1)

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  

×