McGod Posted November 11, 2006 Share Posted November 11, 2006 (edited) My first (but hopefully not last) Autoit tutorial! Today we will be doing the basics of autoit. We will be using todayVariablesIf StatementInputbox FunctionMsgBox FunctionExit FunctionBasic syntaxThis script will ask for your name, they say hello!So we need to start off by declaring a variable. There are three different scopes you can use to declare a variable: Global, Dim and Local. Global scope is used when you wish to use your variable throughout the script. You could use this for such things as names. So instead of having to type in the name of your script everywhere, you use type in your variable. Dim is usually used for declaring the variable before using it. Local is used mostly in functions when you wish to have a temporary variable. When you declare a Local variable within a function, it will automatically be destroyed when the function ends. By the way, you can tell variables because they have a $ infront of the variable name!Couple Examples:Global $autoit = "Rocks" Local $tutorial = 1 Dim $vari oÝ÷ Ù*-¡· z.Ê{*.Â)eºÇ)¬r^~íëÚ®&殶s`¤FÒb33c¶æÖP oÝ÷ Øé,¢z0Ê ¢Ö¯j¸nWyÉZçezÛ)ºÛ(çZµ¨§¶«{}Ò£§£«z "hºÇ¨º»Þ¯'â®Ë_ºw-ÈR¢Z()àjÚ.®Úî²Ü¡jwrè{¬yëajÛaz·ëp¢wuçij¶¦z׫³}î®oÝ÷ Ù.æ¥'hmçjYmêZ©µê춫{^Ø^ëmçèëaz«jgz¸æ§²+ljz)¶*'jZZ©µêÒ£§yçm¢ë"zn´1z.ÊzÊ0zwvÚv+hº»Ú®&æòi×bazö«¦å{Ø^z«Ë"v®¶s`¤FÒb33c¶æÖP¢b33c¶æÖRÒçWD&÷gV÷Cµ÷W"æÖRgV÷C²ÂgV÷CµvB2÷W"æÖSògV÷C²oÝ÷ Ø2¢çÇ!ûa{'§µêÞvz-)à{axéºÐhÆØ^¤É-é¨}ý÷jëh×6 Dim $name $name = InputBox ( "Your name", "What is your name?" ) If $name = "" Then MsgBox ( 1, "Error", "You did not enter a name!" ) Exit oÝ÷ ÚêåThats pretty much it, if you have trouble understanding just PM me ill be happy to explain.(WASNT SURE WERE TO POST) Edited November 11, 2006 by Chip [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
58hoo Posted November 11, 2006 Share Posted November 11, 2006 Thanks! Look forward to your next tutorial Link to comment Share on other sites More sharing options...
bropro Posted November 11, 2006 Share Posted November 11, 2006 Thanks!! useful!! Link to comment Share on other sites More sharing options...
ChrisL Posted November 11, 2006 Share Posted November 11, 2006 (edited) Global scope is used when you wish to use your variable without the script. You could use this for such things as names. So instead of having to type in the name of your script everywhere, you use type in your variable.Did you mean throughout?I know what you meant but it just sounds wrong IMHO! Edited November 11, 2006 by ChrisL [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
McGod Posted November 11, 2006 Author Share Posted November 11, 2006 Did you mean throughout?I know what you meant but it just sounds wrong IMHO!TY, I didn't notice that :"> [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
MHz Posted November 12, 2006 Share Posted November 12, 2006 (edited) So we need to start off by declaring a variable. There are three different scopes you can use to declare a variable: Global, Dim and Local. Global scope is used when you wish to use your variable throughout the script. You could use this for such things as names. So instead of having to type in the name of your script everywhere, you use type in your variable. Dim is usually used for declaring the variable before using it. Local is used mostly in functions when you wish to have a temporary variable. When you declare a Local variable within a function, it will automatically be destroyed when the function ends. By the way, you can tell variables because they have a $ infront of the variable name!Nice effort on the tutorial. I am concerned of your understanding of declaration keywords as to the scope that they use on variables. I have done some modification to your above paragraph that I understand as correct. I made smaller paragraphs to make it easier to read.So we need to start off by declaring a variable. There are three different keywords you can use to declare a variable: Global, Dim and Local. There are two scopes: Global scope and Local scope. Global variables use Global scope and the variables are seen anywhere within the script. Local declared variables use Local scope and are seen only within the functions that they were declared within.The Global keyword is used when you want to use your variable anywhere within the script. You could use this for such things as names. Instead of typing in the name of your script anywhere, you can use the Global variable instead.The Dim keyword is used within functions for conditionally declaring the variable as Global if the variable is already declared Global, else the Dim keyword declares the variable as Local.The Local keyword is used in functions when you wish to have a variable seen only within the function. A Local variable within a function will automatically be destroyed when the function returns.By the way, you can tell of which are variables because they have a $ symbol infront of the variable name.As for the conditional scope that the Dim keyword uses, then I would highly recommend using Global or Local, and only use Dim if the script can handle the scope that it may use. Edited November 12, 2006 by MHz 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