Adding UDFs to AutoIt and SciTE: Difference between revisions

From AutoIt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
Line 1: Line 1:
[[Category:SciTE]][[Category:UDF]]
[[Category:SciTE]][[Category:UDF]]
The ability to download UDFs created by other users is one of the major advantages of AutoIt, but are you one of the many coders who just add these UDFs to the existing "''Include''" folder which contains the standard UDFS distributed with AutoIt?  If so then there is much better way to do it - one which will prevent you from losing all of these additional UDFs when you upgrade.  Just use a user-defined folder to store all your UDFs - AutoIt makes this very easy to do.
The ability to download UDFs created by other users is one of the major advantages of AutoIt, but are you one of the many coders who just add these UDFs to the existing "''Include''" folder which contains the standard UDFS distributed with AutoIt?  If so then there is much better way to do it - one which will prevent you from losing all of these additional UDFs when you upgrade.  Just use a user-defined folder to store all your UDFs - AutoIt makes this very easy to do.
=Creating a Personal Include Folder=


Begin by creating a new folder to hold the additional UDFs - it is recommended that you do '''NOT''' put this folder in the AutoIt install folder (or it will get overwritten when you upgrade).  Then tell AutoIt about this folder.
Begin by creating a new folder to hold the additional UDFs - it is recommended that you do '''NOT''' put this folder in the AutoIt install folder (or it will get overwritten when you upgrade).  Then tell AutoIt about this folder.
Line 13: Line 15:
'''CYA Note''': Normal precautions are advised if modifying the registry.  
'''CYA Note''': Normal precautions are advised if modifying the registry.  


You now have a folder to store modified, downloaded or personal UDFs which are available to use with no need to specify the path and which will not be lost on upgrade.  But to make coding with these UDFs even easier you can also add '''CallTips''' and '''AutoComplete''' for them.
You now have a folder to store modified, downloaded or personal UDFs which are available to use with no need to specify the path and which will not be  
lost on upgrade.   
 
=Adding CallTips  and AutoComplete=
 
But to make coding with these UDFs even easier you can also add '''CallTips''' and '''AutoComplete''' for them.


As you might expect, the full ''SciTE4AutoIt3'' package makes it easy - have you downloaded and installed it yet? If you have then just open '''SciTEConfig''' on the '''Other Tools''' tab and press '''Run User Call Tip Manager'''.  Then you just need to select the UDF file to add and everything is done for you automatically.
As you might expect, the full ''SciTE4AutoIt3'' package makes it easy - have you downloaded and installed it yet? If you have then just open '''SciTEConfig''' on the '''Other Tools''' tab and press '''Run User Call Tip Manager'''.  Then you just need to select the UDF file to add and everything is done for you automatically.  Full instructions on using the ''User Call Tip Manager'' are found in the ''SciTE4AutoIt3'' Help file under ''<Extra Utilities>''.


But if you want to do it manually (which is '''not''' recommended):
But if you want to do it manually (which is '''not''' recommended):

Latest revision as of 09:59, 24 February 2015

The ability to download UDFs created by other users is one of the major advantages of AutoIt, but are you one of the many coders who just add these UDFs to the existing "Include" folder which contains the standard UDFS distributed with AutoIt? If so then there is much better way to do it - one which will prevent you from losing all of these additional UDFs when you upgrade. Just use a user-defined folder to store all your UDFs - AutoIt makes this very easy to do.

Creating a Personal Include Folder

Begin by creating a new folder to hold the additional UDFs - it is recommended that you do NOT put this folder in the AutoIt install folder (or it will get overwritten when you upgrade). Then tell AutoIt about this folder.

- If you have SciTE4AutoIt3 you can use SciTEConfig - look for the User Include Dir input about 2/3 way down the dialog.

- If not (and why not? You can download it from here[1]) you need to modify the registry directly as explained on the "Include" page of the Help file:

 There is a special registry value that can be created at "HKEY_CURRENT_USER\Software\AutoIt v3\AutoIt" called "Include".
 It should be a REG_SZ (string) value.

CYA Note: Normal precautions are advised if modifying the registry.

You now have a folder to store modified, downloaded or personal UDFs which are available to use with no need to specify the path and which will not be lost on upgrade.

Adding CallTips and AutoComplete

But to make coding with these UDFs even easier you can also add CallTips and AutoComplete for them.

As you might expect, the full SciTE4AutoIt3 package makes it easy - have you downloaded and installed it yet? If you have then just open SciTEConfig on the Other Tools tab and press Run User Call Tip Manager. Then you just need to select the UDF file to add and everything is done for you automatically. Full instructions on using the User Call Tip Manager are found in the SciTE4AutoIt3 Help file under <Extra Utilities>.

But if you want to do it manually (which is not recommended):

Calltips first. These are stored in <Your_User_Profile>\au3.user.calltips.api. If you are doing this for the first time then this file will not exist and you will have to create it. Then add a line like this to the file for each function you wish to have a calltip:

 _Function($param1, $param2, $param3) Explanation of function (Requires: #Include UDF.au3)

Of course you need to change the Function, $param and UDF words to the correct values for the UDF function you want to include.

Now AutoComplete. Again a special file is used <Your_User_Profile>\au3.userudfs.properties - again you will have to create it initially - which should read as follows:

 au3.keywords.user.udfs=_function1 _function2 _function3 _function4 \
        _function5 _function6 _function7

Note that the entries are all in lowercase and all lines other than the first begin with a @TAB character.

Then save all files, close and restart SciTE. You will have AutoComplete when you start typing the UDF function name in a script and a syntax CallTip as you enter the parameters. These files are not overwritten when you update SciTE so all your hard work to set this up should be a once-only event.

One final thing. If you want the "Tools - Open Include" menu item in SciTE to work on the files within this new folder you need to add the following lines to your "SciTEUser.properties" file - you open it by using the <Options - Open User Options File> menu item:

 openpath.$(au3)=$(autoit3dir)\include;Your_Folder_Path
 openpath.beta.$(au3)=$(autoit3dir)\beta\include;Your_Folder_Path

Now you are all set - your personal include files are as accessible as the standard set.