Jump to content
Sign in to follow this  
Wikipete

Help please, can you see anything wrong with this?

Recommended Posts

Wikipete

Please see end post. Topic changed.

Edited by Wikipete

 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
newbiescripter

well this is kind of messy :)

Have you tried to run it? I don't think so cause you would have got alot of errors..

You can't include a file in an if statement and you have an EndFunc command without starting with a Func command..

I've have this little example but I don't know what you really are trying to do:

#include <IE.au3>
$answer = Msgbox (0x6, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")
If $answer = 10 or $answer = 11 Then
    _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")
Else
    Exit
EndIf

Next time you post some code put it in [autoit.] [/autoit.] without the "." :)

Regards

EDIT: try to explain what you are trying to do, then it's easier to help you.

Edited by newbiescripter

Share this post


Link to post
Share on other sites
Quinch

Well, the code seems to be something of a mess; I'm not sure whether that's because you copypasted it {tip: under "insert special item" in the posting form, pick "codebox" and paste the code there}, or because it's written that way. If you're new to scripting, no biggie and welcome.

Now, let's see;

If $sAnswer = >9 then More-or-equal sign is >=

#include <IE.au3> #includes are usually placed at the start of the script; they rarely use enough resources to cause any noticeable slowdowns, and this way you can easily check what's included and what isn't.

$oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")Endif EndIfs are, if I am not mistaken, always placed in a new line, and alone. Someone correct me if I'm wrong.

MsgBox (6+64, "Please install the file to your system, I... Your syntax is wrong, I believe, either that or you forgot to add the title value to the msgbox. As it is, all that text will be placed in the messagebox title, rather than the contents, while the contents will read simply "1279".

The EndIfs, Elses etc. are a bit of a mess, and most of them were extraneous. In any case, I think this might be what you were aiming for...

CODE
#include <IE.au3>

Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")

If $sAnswer >=9 then

$oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")

MsgBox (6+64, "Downloading...", "Please install the file to your system, I will give you 2 mins to do this, If you finish before this period is up, please click continue. I have included a free game, just incase you get bored.", 1279)

Run ("C:\Documents and Settings\Admin\Desktop\MWR_Snake_5")

Sleep (120000)

EndIf

Share this post


Link to post
Share on other sites
DMEE

Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")

If $sAnswer = >9 then

#include <IE.au3>

$oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")Endif

MsgBox (6+64, "Please install the file to your system, I will give you 2 mins to do this, If you finnish before this period is up, please click continue. I have included a free game, just incase you get bored.", 1279, 0)

Run ("C:\Documents and Settings\Admin\Desktop\MWR_Snake_5")

Sleep (120000)

Endif

else Exit

EndFunc

There are a few errors in the script.

1. the operator to compare two values can be found in the help file; you probably need >= instead of =>

2. the endif at the end of line 4 is not permitted, this will give a syntax error.

3. In general each if should have an accompanying endif and each else statement should be preceded by an if ... then statement, so don't use the endif before the else statement

4. an Endfunc should be preceded by a func funcname() statement.

this will result in something like:

Func funcname()
    #include <IE.au3>
    Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")
    If $sAnswer >= 9 then
        $oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")

        MsgBox (6+64, "Please install the file to your system, I will give you 2 mins to do this, If you finish before this period is up, please click continue. I have included a free game, just incase you get bored.", 1279)
        Run ("C:\Documents and Settings\Admin\Desktop\MWR_Snake_5")
        Sleep (120000)
    Else 
        Exit
    Endif
EndFunc

In the beginning there was nothing and then even that exploded - anonymous

Share this post


Link to post
Share on other sites
Quinch

DMEE, is the Else -> Exit needed? Afterall, if the set condition isn't fulfilled, there is nothing left to do, so the script ends...?

Share this post


Link to post
Share on other sites
Wikipete

Well, the code seems to be something of a mess; I'm not sure whether that's because you copypasted it {tip: under "insert special item" in the posting form, pick "codebox" and paste the code there}, or because it's written that way. If you're new to scripting, no biggie and welcome.

Now, let's see;

If $sAnswer = >9 then More-or-equal sign is >=

#include <IE.au3> #includes are usually placed at the start of the script; they rarely use enough resources to cause any noticeable slowdowns, and this way you can easily check what's included and what isn't.

$oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")Endif EndIfs are, if I am not mistaken, always placed in a new line, and alone. Someone correct me if I'm wrong.

MsgBox (6+64, "Please install the file to your system, I... Your syntax is wrong, I believe, either that or you forgot to add the title value to the msgbox. As it is, all that text will be placed in the messagebox title, rather than the contents, while the contents will read simply "1279".

The EndIfs, Elses etc. are a bit of a mess, and most of them were extraneous. In any case, I think this might be what you were aiming for...

CODE
#include <IE.au3>

Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")

If $sAnswer >=9 then

$oIE = _IECreate ("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe")

MsgBox (6+64, "Downloading...", "Please install the file to your system, I will give you 2 mins to do this, If you finish before this period is up, please click continue. I have included a free game, just incase you get bored.", 1279)

Run ("C:\Documents and Settings\Admin\Desktop\MWR_Snake_5")

Sleep (120000)

EndIf

Thanks, Problem solved!


 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
newbiescripter

DMEE, is the Else -> Exit needed? Afterall, if the set condition isn't fulfilled, there is nothing left to do, so the script ends...?

I think that DMEE has maked the Else Exit because he made it in a function, which could be called anywhere in a code.

Regards

Share this post


Link to post
Share on other sites
Wikipete

Unrelated to the above, can anyone point me in the direction of a help file, or explain how to jump between lines in script.

For example:

If $sAnswer = 6 then  
        msgbox (0+64, "Please set up yor screen accoring to your own preferences", "This is not reccomended, but if you like to have a creative flare, good on you.")
        ;I then want to jump to... (line 47)
    Else 
      msgbox (0+64, "Please set up your screen accoring to the following image", "Please set your own preferences as to left and right justification of either window")
      Sleep (100)
      ;... here. How can I do this. (Line 51)
    Endif

 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
ReaImDown

Unrelated to the above, can anyone point me in the direction of a help file, or explain how to jump between lines in script.

For example:

If $sAnswer = 6 then  
        msgbox (0+64, "Please set up yor screen accoring to your own preferences", "This is not reccomended, but if you like to have a creative flare, good on you.")
        ;I then want to jump to... (line 47)
    Else 
      msgbox (0+64, "Please set up your screen accoring to the following image", "Please set your own preferences as to left and right justification of either window")
      Sleep (100)
      ;... here. How can I do this. (Line 51)
    Endif
heh?

use func...


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites
newbiescripter

Here is an example in how to use function:

If $sAnswer = 6 then
        function1()
    Else
        function2()
    Endif
    
Func function1()
    msgbox (0, "STATUS", "sAnswer is 6")
EndFunc

Func function2()
    msgbox (0, "STATUS", "sAnswer is not 6")
    Sleep (100)
EndFunc

Regards

Share this post


Link to post
Share on other sites
ReaImDown

Here is an example in how to use function:

If $sAnswer = 6 then
        function1()
    Else
        function2()
    Endif
    
Func function1()
    msgbox (0, "STATUS", "sAnswer is 6")
EndFunc

Func function2()
    msgbox (0, "STATUS", "sAnswer is not 6")
    Sleep (100)
EndFunc

Regards

tehe, hah, what he said :)

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites
Wikipete

tehe, hah, what he said :)

Cheers thanks guys!

I am getting used to this!


 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
Wikipete

Right ok, I have built this, anything immediately wrong with it?!

Just a note about what I am trying to do: I am trying to install multiple applications onto a computer using one script and with programs from various sources, if you follow the lines through it should become clear. If you require further clarification, please just give me an ear bashing. Thanks!

If $sAnswer >=9 then 
    InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", "autoit.exe")
    MsgBox (6+64, "Downloading...", "Please install the file to your system, I will give you 2 mins to do this, If you finish before this period is up, please click continue. I have included a free game, just incase you get bored.", 1279)
    Sleep (120000)
    MsgBox (0+64, "Autoit.exe (the installation file) is now on your desktop", "Congratulations, Autoit was successfully dowmloaded! You can now run the installer (on the desktop) and the demo called Autoit.exe off the same disk as this program. I hope you enjoy using it.")
        Else
            Func function 2 
                EndFunc
                    EndIf
    $decision = MsgBox (6+64, "Make a decision", "Do you wish to continue installing the rest of the downloads on this disk?")
        If $decision = 6 Then
            function2 () 
                EndFunc
        Else
        Exit
            EndFunc
                EndIF
                    $sAnswer2 = msgbox (4+64, "Did you beat me to it?", "Have you already installed autoit and wish to install another program on your system?")
                    if $sAnswer2 = 7
                Exit
            else
        function2 ()
    Endif
EndFunc
;-----------------------------------------------------------------------------------------Install-app2----------------------------------------------------------------

func function2 ()
    Endfunc
MsgBox (0+64 , "Part 2", "Welcome to the next application that is part of this bundle for installation with Peter B's 'Macrolism'")

Thanks, any help would be vastly appreciated!

Edited by Wikipete

 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
newbiescripter

Well I think you maybe should start with something easier until you now the most simple commands.

Before you can call a function it should be declared for example:

Func hello()
    MsgBox(0,"Hello","How are you today?")
Endfunc

when that is done you can call the function by simply wirte the function name in the source like this:

hello()

then the source code will do what is declared in the function hello() and then return to the place in the source code where it's was called when it is done with it.

Hope you understand, but I think you should try create something more easy to begin with..

Regards

Share this post


Link to post
Share on other sites
Wikipete

Well I think you maybe should start with something easier until you now the most simple commands.

Before you can call a function it should be declared for example:

Func hello()
    MsgBox(0,"Hello","How are you today?")
Endfunc

when that is done you can call the function by simply wirte the function name in the source like this:

hello()

then the source code will do what is declared in the function hello() and then return to the place in the source code where it's was called when it is done with it.

Hope you understand, but I think you should try create something more easy to begin with..

Regards

Thanks for the explanation. I don't think that function thing is what I am looking for... ah, I will have a play. I am building something specifically for a purpose I need, so to work on something simpler would be a little annoying considering I am a time limit. (I know thats a little ilogical and stephan covey would murder me, damn... i am chatting). Thanks!

 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
newbiescripter

Well if the function isn't what you are looking for then i can't help you.

I do also programming in C++ and it has in the beginning a "Go to" command, but it's not used anymore since it gives you a very confused code and therefor it has been replaced with a function. Not programmers use the Go to commands anymore.

Regards

Share this post


Link to post
Share on other sites
Wikipete

Well if the function isn't what you are looking for then i can't help you.

I do also programming in C++ and it has in the beginning a "Go to" command, but it's not used anymore since it gives you a very confused code and therefor it has been replaced with a function. Not programmers use the Go to commands anymore.

Regards

Thanks! I have figued it out and learnt how to use the func instruction.

Very likely I will be back in the near future.

func downloadcomplete ()
    msgbox (0+64, "Thanks", "The download that you requested has completed and is ready for your installation. Please just click on the icon on the desktop to install it. Please be warned that your computer may need to be restarted in order to successfully install the software you just downloaded. Thanks, and enjoy your new software!")
        Endfunc
Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")
If $sAnswer >=9 then
    InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", "autoit.exe")
        $continuepressed = MsgBox (6+64, "Downloading...", "Please install the file to your system, I will give you 90 seconds to do this, If you do not finish before this period is up, please click continue when you are ready. I have included a free game, just incase you get bored.", 1279)
            Elseif $continuepressed = 10 or 11 then
                downloadcomplete ()
            Else 
                Sleep (90000)
if $continuepressed = 2 then        
    msgbox (0+64, "Please restart this application", "The software was NOT installed on your computer, please restart this application before running any other program off the disk in your disk drive")
Endif
    $decision = MsgBox (4+64, "Make a decision", "Do you wish to continue installing the rest of the downloads on this disk?")
        If $decision = 7 Then
            msgbox (0+64, "Thanks", "Only Autoit was installed on your system, if you have not already installed the other applications, please do so immediately by restarting this application and running completely through it. If not, please enjoy your renewed version of Autoit.")
Exit
Else
    $sAnswer2 = msgbox (4+64, "Did you beat me to it?", "Have you already installed autoit and wish to install another program on your system?")
        If $sAnswer2 = 7 Then
            msgbox (0+64, "You are confusing", "Please decide what you actually want to do before running this installer again. Thank you.")
Exit
Else
    msgbox (0+64, "Great!", "Lets insall the other applications on this CD")
Endif
;Continue to second part of script.
;-----------------------------------------------------------------------------------------Install-Win-spy----------------------------------------------------------------
Endif
MsgBox (0+64 , "Part 2", "Welcome to the next application that is part of this bundle for installation with Peter Bryant's 'Macrolism'") 
Endif

Thanks for all your help!


 Run (Brain.exe)
.

Share this post


Link to post
Share on other sites
Wikipete

Well if the function isn't what you are looking for then i can't help you.

I do also programming in C++ and it has in the beginning a "Go to" command, but it's not used anymore since it gives you a very confused code and therefor it has been replaced with a function. Not programmers use the Go to commands anymore.

Regards

Thanks! I have figued it out and learnt how to use the func instruction.

Very likely I will be back in the near future.

func downloadcomplete ()
    msgbox (0+64, "Thanks", "The download that you requested has completed and is ready for your installation. Please just click on the icon on the desktop to install it. Please be warned that your computer may need to be restarted in order to successfully install the software you just downloaded. Thanks, and enjoy your new software!")
        Endfunc
Dim $sAnswer = Msgbox (6+64, "Hello again!", "The latest version of Autoit will now be downloaded to your computer, If you do not wish to do this yet, please click cancel and this presentation will cancel and you will return to normal functionality of your computer. If you do wish to proceed, click continue.")
If $sAnswer >=9 then
    InetGet("http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe", "autoit.exe")
        $continuepressed = MsgBox (6+64, "Downloading...", "Please install the file to your system, I will give you 90 seconds to do this, If you do not finish before this period is up, please click continue when you are ready. I have included a free game, just incase you get bored.", 1279)
            Elseif $continuepressed = 10 or 11 then
                downloadcomplete ()
            Else 
                Sleep (90000)
if $continuepressed = 2 then        
    msgbox (0+64, "Please restart this application", "The software was NOT installed on your computer, please restart this application before running any other program off the disk in your disk drive")
Endif
    $decision = MsgBox (4+64, "Make a decision", "Do you wish to continue installing the rest of the downloads on this disk?")
        If $decision = 7 Then
            msgbox (0+64, "Thanks", "Only Autoit was installed on your system, if you have not already installed the other applications, please do so immediately by restarting this application and running completely through it. If not, please enjoy your renewed version of Autoit.")
Exit
Else
    $sAnswer2 = msgbox (4+64, "Did you beat me to it?", "Have you already installed autoit and wish to install another program on your system?")
        If $sAnswer2 = 7 Then
            msgbox (0+64, "You are confusing", "Please decide what you actually want to do before running this installer again. Thank you.")
Exit
Else
    msgbox (0+64, "Great!", "Lets insall the other applications on this CD")
Endif
;Continue to second part of script.
;-----------------------------------------------------------------------------------------Install-Win-spy----------------------------------------------------------------
Endif
MsgBox (0+64 , "Part 2", "Welcome to the next application that is part of this bundle for installation with Peter Bryant's 'Macrolism'") 
Endif

Thanks for all your help!


 Run (Brain.exe)
.

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  

×