Sign in to follow this  
Followers 0
FreeBeing

Bug in my script I don't understand

4 posts in this topic

Hi,

I added to my script conditions to check if we use XP or Vista or 7, but it don't work.

I get error :

G:\AutoIt>Au3Check.exe raccourcis_clavier.au3

AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007

G:\AutoIt\raccourcis_clavier.au3(27,2) : ERROR: missing EndIf.

Func

^

G:\AutoIt\raccourcis_clavier.au3(25,33) : REF: missing EndIf.

If (@OSVersion == "WIN_XP") Then

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

G:\AutoIt\raccourcis_clavier.au3(30,2) : ERROR: syntax error

EndIf

^

raccourcis_clavier.au3 - 2 error(s), 0 warning(s)

My script :

#NoTrayIcon
EnvSet("SEE_MASK_NOZONECHECKS", 1)

;Raccourcis clavier
HotKeySet("^!t", "Taches")
Func Taches()
    ShellExecute("taskmgr")
EndFunc
HotKeySet("^!p", "Peripheriques")
Func Peripheriques()
    ShellExecute("devmgmt.msc")
EndFunc
HotKeySet("^!c", "cmd")
Func cmd()
    ShellExecute("cmd", "", @ScriptDir)
EndFunc

;Partie Aida64
HotKeySet("^!a", "Aida64")
Func Aida64()
    ShellExecute("aida64.exe", "", @ScriptDir & "\..\Majs_Commun\aida64")
EndFunc
;Fin partie Aida64

If (@OSVersion == "WIN_XP") Then
    HotKeySet("^!s", "SolitaireXP")
    Func SolitaireXP()
        ShellExecute("sol.exe")
    EndFunc
    HotKeySet("^!d", "DemineurXP")
    Func DemineurXP()
        ShellExecute("winmine.exe")
    EndFunc
EndIf

If (@OSVersion == "WIN_VISTA") Or (@OSVersion == "WIN_7") Then
    HotKeySet("^!s", "Solitaire")
    Func Solitaire()
        ShellExecute(@ProgramFilesDir & "\Microsoft Games\Solitaire\Solitaire.exe")
    EndFunc
    HotKeySet("^!d", "Demineur")
    Func Demineur()
        ShellExecute(@ProgramFilesDir & "\Microsoft Games\Minesweeper\Minesweeper.exe")
    EndFunc
EndIf
;Fin raccourcis clavier

;Dodo
While 1
    Sleep(120000)
WEnd
;Fin Dodo boucle

Maybe an idea ?

Thank you :)

Share this post


Link to post
Share on other sites



Move your functions (FUNC-ENDFUNC) to the end of the script in stead of putting them inside of an IF-ENDIF

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Maybe an idea ?

Yes, don't use Func inside an If. No matter what you do, ALL Funcs will be read at compiling time. So, put the Funcs outside Ifs and your script will work.

Edit: I'm always 30 seconds late :)

Edited by sahsanu

Share this post


Link to post
Share on other sites

Thank you, it works ! :)

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  
Followers 0