Sign in to follow this  
Followers 0
Wolfeinstein

Badly formatted "Func" statement

6 posts in this topic

Why i get this error? "Badly formatted "Func" statement"

Sorry for my bad english

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=

$Form1 = GUICreate("Defcon0815 LogApp by epvp", 172, 247, 499, 116)

$Button1 = GUICtrlCreateButton("Metin2", 8, 208, 153, 33, 0)

GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $F3

run ("d:\Jocuri\Metin2 RO\bypass.bat","d:\Jocuri\Metin2 RO")

EndSwitch

HotKeySet ( "{F2}", "log" )

WEnd

func log()

send ("accountname")

Send ("{Enter}")

sleep (1000)

send ("password")

sleep (1000)

Send ("{Enter}")

sleep (5000)

Send ("{Enter}")

EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use [ autoit] your code [ /autoit] to format your code example properly when posting an example!

Then you defined Log() as your function but Log() is already a build-in function (Calculates the natural logarithm of a number.)!

Use a different name, e.g. _Log()

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Defcon0815 LogApp by epvp", 172, 247, 499, 116)
$Button1 = GUICtrlCreateButton("Metin2", 8, 208, 153, 33, 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $F3
            run ("d:\Jocuri\Metin2 RO\bypass.bat","d:\Jocuri\Metin2 RO")
    EndSwitch
    HotKeySet ( "{F2}", "_log" )
WEnd

func _log()
    send ("accountname")
    Send ("{Enter}")
    sleep (1000)
    send ("password")
    sleep (1000)
    Send ("{Enter}")
    sleep (5000)
    Send ("{Enter}")
EndFunc

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯

Share this post


Link to post
Share on other sites

Looks suspicious... What exactly is this for?

I have fixed your code and commented it so you can tell what is wrong:

#include <GUIConstants.au3>

HotKeySet ( "{F2}", "_log" )        ;Hotkey decleration is not put in the while loop.
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Defcon0815 LogApp by epvp", 172, 247, 499, 116)
$Button1 = GUICtrlCreateButton("Metin2", 8, 208, 153, 33, 0)
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUISetState()                   ;Does not need to contain @SW_SHOW
#EndRegion ### END Koda GUI section ###

While 1                         ;properly indented to make code easier to read
    Switch GUIGetMsg()          ;No need for $nMsg variable
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1           ;Should be $Button1, not $F3 - That's the impression I get anyway
            run ("d:\Jocuri\Metin2 RO\bypass.bat","d:\Jocuri\Metin2 RO")
    EndSwitch
WEnd

func _log()                     ;Functions always start with an underscore
    send ("accountname")
    Send ("{Enter}")
    sleep (1000)
    send ("password")
    sleep (1000)
    Send ("{Enter}")
    sleep (5000)
    Send ("{Enter}")
EndFunc

shanet


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

UEZ makes a good point I always add "_" to the start of any Function e.g. _Custom() because this is what I read somewhere on the Forum. I was told it was good programming practice and now I understand why!


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

thank you all!what an epic fail=)

Share this post


Link to post
Share on other sites

You will always get that error when you name your function the same as one of the AutoIt built in functions.

Func Run() would fail as would Func StringInStr(). By preceding the name with an underscore (or any legal character for that matter) will solve the problem. It's just an AutoIt convention that user defined functions start with an underscore but not absolutely required.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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