JohnOne Posted March 30, 2011 Share Posted March 30, 2011 (edited) Here is a little tutorial I decided to make. (yes another tutorial) It is intended for people with absolutely no knowledge of programming/scripting at all. It also assumes you do not know how to use autoit3 help file. What it does assume, is that you have installed autoit3 and scite4autoit which can be found here Autoit > Scite4autoit The most important thing to know, is how to navigate and use the helpfile Please do not underestimate how valuable this resource is. By default the help file is located in your myprograms or myprogramsx86 of you OS drive in the folder AutoIt3 It looks like this with the ? on it, click it Once the helpfile loads you will see essentially two panels, the one on the left is about navigation The one on the right is about information, and for now, just focus on the index tab and click it to see something like this in the left panel Notice it says "Type in the keyword to find", this is where we can find what we are looking for. For example, if I want to find a string function, or browse all the string functions, I simply type "string" into the field below the prompt, and it navigates automatically to the items in the index, like so. If you highlight one of the items in the list and hit enter, or double click on an item, it will bring up information about that item in the right side panel, like so. Above I clicked on the String function and it shows me everything i need to know about that function. Firstly, it tells me in essence what it does. "Returns the string representation of an expression." Secondly, it shows me how to enter the function into scite editor "String ( expression )" In the scope of this post, the expession here is the paramater we pass to the function for processing. A paramater is any variable or literal we put inside the braces of a function. It also tells me the return value - "Returns a string." - a string it what is between those two quotes (text if you will) So what is a return value? Its what the function pumps out after you pass it the correct paramaters, you can test it in the example at the bottom of the right panel. But not before you take a look at another important part of the information, The remarks. "Maximum string length is 2147483647 characters (but keep in mind that no line in an AutoIt script can exceed 4095 characters.)" Here its telling us that if we put a string of over 4095 characters on one line in our script, it will fail. Never skip the remarks, it will cost you valuable time and cause you headaches. Every time you are going to use a function, you should have that function open in the helpfile and refer to it every step of the way. All the information in that panel is important, read it all, and then, notice the little button at the bottom of the example entitled "Open this Script", press that, and the script will automagically open in your scite4autoit editor, and is ready to run, by hitting the F5 key Q. What is a variable? A. $this_is_a_variable = "this is a literal string"; A variable will always have the $ at the beginning and never have a space in it (those are rules) Look at the example $var = String(10) ;$var is the string "10" ;$var is the variable here, and 10 is a literal paramater passed to the String function. Lets take the String function out of the equasion and consider this statement (in the scope of this post a statement is information you type into scite which is telling autoit3 something it needs to know) $var = 10 Here the variable $var is now equal to the literal value 10, it is named a variable because it can change its value. $var = $var + 1 $var is now equal to 11, 10 however, will always be 10. Lets have a look at another function, you remember how to find what we need in the helpfile? then find FileRead. Heres what it tells us. Read in a number of characters from a previously opened text file. This means it will read into the variable it is assigned, (think $var) the amount of individual characters we want from a file that autoit3 has already opened. FileRead ( "filehandle/filename" [, count] ) This is like a prototype of the function we will enter into our editor, notice the bracets "[" and "]" they are telling us that this paramater is optional! more below. Parameters filehandle/filename - The handle of a file, as returned by a previous call to FileOpen. Alternatively you may use a string filename as the first parameter. Forget filehandle for now, filename here is the path to the file we want to read from, for example "c:usersscriptsmyfile.txt" count - [optional] The number of characters to read. Default read the entire file. Its quite common for beginners to misunderstand these [ and ], you dont type them literally into your script, they are just to let you know that you can completely leave out that paramater if you do not need it. In this case, if you want to read the whole file into your variable ($var) you would leave out everything between and including those bracets. If you do need it you would remove the bracets and enter your paramater. Return Value Success: Returns the binary/string read. @extended is set to the number of bytes/characters returned. This tells us the function will return a string if we gave it a filename as a paramater, since we are reading the file, the string will be the contents of the file. Special: Sets @error to -1 if end-of-file is reached. @error information tells us information about why the call to a function may have failed. It is important to check the @error state after each function you use. Failure: Sets @error to 1 if file not opened in read mode or other error. Looking at the example usually shows you how to check for errors. Remarks If a filename is given rather than a file handle - the file will be opened and closed during the function call - for parsing large text files this will be much slower than using filehandles. Note: Do not mix filehandles and filenames, i.e., don't FileOpen a file and then use a filename in this function. Use either filehandles or filenames in your routines, not both! Both ANSI and UTF16/UTF8 text formats can be read - AutoIt will automatically determine the type. A file can be read as binary(byte) data by using FileOpen with the binary flag - in this case count is in bytes rather than characters. There are plenty of good tutorials on this forum created by various members, which is why it is important to know how to search the forums. But hang on, this tutorial is about how to use the helpfile, so cast your mind way back to when we learnt how to find what we need It was typing it into the index tab prompt field, so type "tutorial" into that, and you will find basic tuts in their also. Edited February 8, 2018 by JohnOne Shrapnel, 232showtime, LAPIII and 1 other 4 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 30, 2011 Author Share Posted March 30, 2011 (edited) Another way you can access the help file, which I always use, is by pressing the F1 key on your keyboard while your scite4autoit editor is active. Furthermore, if you left (Primary) click your mouse on a native autoit function name or keyword while in the editor and then press F1 the help file will open just where you need it (on the page of the function/keyword/macro etc.. you clicked) And another thing that is sometimes overlooked here on the forums is the online help, and how easily it can be accessed. Heres an example, click on any of the native function names which appear between these autoit tags If FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt") EndIf FileOpen(("setup.txt") FileOpenDialog() ;etc... Edited April 25, 2011 by JohnOne fikri1979 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted March 30, 2011 Author Share Posted March 30, 2011 reserved: AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
somdcomputerguy Posted March 30, 2011 Share Posted March 30, 2011 This is great JohnOne. A tutorial which focuses on what is undoubtedly (IMO) the most important AutoIt resource available. Outstanding. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change. Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted April 9, 2011 Share Posted April 9, 2011 Someone should add this to Wiki - Tutorials .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
meows Posted April 23, 2012 Share Posted April 23, 2012 Thank you guys!I would ask for some detail though. As for some reason these did not work for me.Running version 2.28 Aug 7 2011 13:34:43by Neil Hodgson. Updated: Valik & Joswait, that is in the editor, help about. how do you find the version you are running of audoit? i just downloaded it a week ago.Example.If FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt") EndIf FileOpen(("setup.txt") FileOpenDialog() ;etc...I put this in the program and it gives.>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Program Files (x86)AutoIt3test1v.au3" /UserParams +>09:44:34 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3C:Program Files (x86)AutoIt3test1v.au3(1,61) : ERROR: syntax errorIf FileExists("setup.exe") Then FileDelete("setup.exe") Else~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3(1,91) : ERROR: FileWrite() [built-in] called with wrong number of args.If FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt")~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3(1,93) : ERROR: syntax errorIf FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt") EndIf~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3(1,122) : ERROR: syntax errorIf FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt") EndIf FileOpen(("setup.txt") FileOpenDialog~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3(1,146) : ERROR: single line 'If' missing 'Then'.If FileExists("setup.exe") Then FileDelete("setup.exe") Else FileWrite("setup.txt") EndIf FileOpen(("setup.txt") FileOpenDialog() ;etc...~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3 - 5 error(s), 0 warning(s)!>09:44:34 AU3Check ended.rc:2>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:Program Files (x86)AutoIt3test1v.au3" +>09:44:37 AutoIT3.exe ended.rc:0>Exit code: 0 Time: 3.178Now how would this be used? It will not work for me at all.SO to try and figure out how to do this i put in the favorate post,Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm',And get this.>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:Program Files (x86)AutoIt3test1v.au3" /UserParams +>09:49:12 Starting AutoIt3Wrapper v.2.1.0.8 Environment(Language:0409 Keyboard:00000409 OS:WIN_7/Service Pack 1 CPU:X64 OS:X64)>Running AU3Check (1.54.22.0) from:C:Program Files (x86)AutoIt3C:Program Files (x86)AutoIt3test1v.au3(1,111) : ERROR: syntax error (illegal character)Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^C:Program Files (x86)AutoIt3test1v.au3 - 1 error(s), 0 warning(s)!>09:49:12 AU3Check ended.rc:2>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:Program Files (x86)AutoIt3test1v.au3" C:Program Files (x86)AutoIt3test1v.au3 (1) : ==> Unterminated string.:Run('hh mk:@MSITStore:'&StringReplace(@AutoItExe,'.exe','.chm')&'::/html/tutorials/helloworld/helloworld.htm','->09:49:15 AutoIT3.exe ended.rc:1>Exit code: 1 Time: 4.057It would not open anything but the error box.I want to learn, but this makes it hard.I put a list on a form with the Koda Form designer, and want to know how to access the files in the list.So I looked at the onclick Standard control event. as stated in the Koda help. That is all it says, period. So I went to the Audoit help and there is nothing at all for list! Nor anything in help about a standard control event. So I guess it is not so standard.So I looked for onclick and nothing listed.Now I did find ControlClick ( "title", "text", controlID [, button [, clicks [, x [, y]]]] )So I ran the example looking for enlightenmentControlClick("[CLASS:Notepad]", "", "MDIClient1")And there were no errors, but what does this mean? As no window poped up just the text here.+>10:06:17 AU3Check ended.rc:0>Running:(3.3.8.1):C:Program Files (x86)AutoIt3autoit3.exe "C:Program Files (x86)AutoIt3test1v.au3" +>10:06:17 AutoIT3.exe ended.rc:0>Exit code: 0 Time: 0.997So thinking that the controlID The control to interact with. See Controls. Would give me my answer, on how to interact with my list and run a program when the user clicks on it. And ControlID saysID - The internal control ID. The Control ID The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID.So i have a answer finally. I go to the Audoit window and click on the finder tool. and go to the Koda Form Designer and click and click and nothing ever shows in the Audoit v3 Window Info.So now, I am at a total loss, but maybe I need to put the form with the list box into Audoit,<P>#include <GUIConstantsEx.au3><BR>#include <GUIListBox.au3><BR>#include <WindowsConstants.au3><BR>#Region ### START Koda GUI section ### Form=<BR>$Form1 = GUICreate("list", 592, 431, 192, 132)<BR>GUISetIcon("C:Program Files (x86)AutoIt3TryitHag1Play.ico", -1)<BR>GUISetBkColor(0xFFFF00)<BR>$List1 = GUICtrlCreateList("", 56, 384, 401, 86)<BR>GUICtrlSetData(-1, "1.exe|2.exe|3.exe|4.exe|5.exe")<BR>GUISetState(@SW_SHOW)<BR>#EndRegion ### END Koda GUI section ###</P> <P>While 1<BR> $nMsg = GUIGetMsg()<BR> Switch $nMsg<BR> Case $GUI_EVENT_CLOSE<BR> Exit</P> <P> EndSwitch<BR>WEnd</P>It works, so I get all excited and get the Audoit v3 Window Info and start going through the tabs and clicking on the form and the list and the files and nothing ever shows in the Audoit v3 Window Info.SO please, how do you use the list box to run a exe and how to hide and unhide the files in a list box. Link to comment Share on other sites More sharing options...
ChickPea Posted February 8, 2018 Share Posted February 8, 2018 On 30/03/2011 at 1:11 AM, JohnOne said: Here is a little tutorial I decided to make. (yes another tutorial) It is intended for people with absolutely no knowledge of programming/scripting at all. It also assumes you do not know how to use autoit3 help file. What it does assume, is that you have installed autoit3 and scite4autoit which can be found here http://www.autoitscript.com/site/autoit/downloads/ Autoit > into that, and you will find basic tuts in their also. There are a whole heap of those images, presumably where there should be diagrams. If you need them hosting, I can provide server space (gratis). Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2018 Author Share Posted February 8, 2018 Thanks, I will update when have the chance. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
JohnOne Posted February 8, 2018 Author Share Posted February 8, 2018 Done, thanks again. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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