We are going to use the AutoIt scripting language, its free, easy and requires no additional runtimes to run the programs.
So first, head over to the AutoIt website and download the AutoIt package as well as the ScITE script editor.
Once we have these installed we can start writing our script.
Note: You will need to have a bit of programming knowledge or at least be willing to learn, otherwise this will be a long and boring article. You can simply skip to the end of the article to download a zip of all the associated files for downloading and modifying.
Create our Script file
To start off we need to create the file we will use to write our script. This is extremely easy, and can be done a couple of ways. Either right click in your desired location and go to New > AutoIt v3 Script.Or create a .txt file and rename the file extension to .au3 (more advanced users).
After that the file should automatically open in ScITE script editor.
Designing the Main Menu screen
Ok, so first we will design our 'Main Menu' screen. This is the GUI we will be seeing when the script is booted. To make this process a little more streamlined (also for beginners) we can use the Koda (FormDesigner) tool included in the full version of ScITE (we download and installed earlier). Note: if you are using the Lite version of ScITE (installed with the AutoIt library) this will not work.So, we locate Koda in the Tools menu of ScITE (shown Below).
I'm not going to get into the details of creating a form using Koda. You can go nuts and create it however you would like it to look. For this tutorial, I have simply gone for the classic HBCD menu look (with a couple of small changes).
The main element you will need for this tutorial to work is a Main Menu object with an item named 'Programs' (or whatever you name it.)
Once you have had fun designing your marvelous Main Menu form, select Tools > Generate Form Code... This will give you your forms AutoIt code, so copy it and paste it into your AutoIt script. This is the beginning of our new HBCDMenu.
So once you have finished you will have something like this...
#include <GUIConstantsEx.au3> #include <GUIMenu.au3> MainMenu() Func MainMenu() ;Create and show our main GUI Global $Form1 $Form1 = GUICreate("anarcist's USB Menu", 300, 200, 195, 123) ;This is the menu that will hold all of our User-Defined menus Global $MenuItem1 = GUICtrlCreateMenu("Programs") ;Create our About Menu $AboutMenu = GUICtrlCreateMenu("About") $Blog = GUICtrlCreateMenuItem("anarcist's Blog", $AboutMenu) $AboutItem = GUICtrlCreateMenuItem("About", $AboutMenu) ;Now create our 'Browse' button $Folder = GUICtrlCreateButton("Browse USB...", 80, 65, 140, 50) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Folder Run("C:\WINDOWS\explorer.exe /n /e, .\Programs") Case $Blog ShellExecute("http://anarcist69.blogspot.com/") Case $AboutItem ;This come later... ;GUISetState(@SW_HIDE) ;AboutMenu() EndSwitch WEnd EndFunc ;==>MainMenuTo explain this code a bit better there a a few things to explain:
- I have wrapped the menu form in a function name MainMenu(), this allows us to easy hide it and call it again later if we need to. This also means that we don't need to have this as our boot screen (Notice the call to the MainMenu function at the beginning of the script.)
- I have renamed a few items (i.e. $AboutMenu and $Blog), this makes them a bit easier to ID later in the script.
- There is a 'While' loop at the end of the function, this handles all of our 'Click' events. We will modify this later for our 'Programs' menu once we populate it with our .csv file.
- At the very top of our script we have a couple of include files, this contain our functions for creating the GUI and knowing what to do with it. We will be adding more later.
I was wondering if you will ever finish this tutorial. I would really like to create my own HBCD. Thanks
ReplyDeleteHello @Shjinta, I appreciate your enthusiasm, that's what is needed for me to continue blogging. Unfortunately, because of Full-Time work and a young family may blogging time has been cut down drastically. Although, you would be glad to know that I am approximately half way through the second half of this tutorial.
DeleteThanks for responding to my comment. Take all the time you need. I'm just really glad you have decided to continue on with the tutorial. I am anxiously looking forward to it.
DeleteTake care and good luck with the young family!
@Shijinta Just letting you know that i have posted the second part of this tutorial.
DeleteHello sir! just wanted to let you know that there are many (my entire crew and myself) who're eagerly looking forward to the second part of this tutorial! Keep up the good work, we appreciate all you do!
ReplyDeleteThank You @Shackridge, I like to here feedback and I am here to let you know that i am slowly working on the second half of the tutorial and it should be coming in the next couple of weeks.
Delete@Shackridge Just letting you know that i have posted the second part of this tutorial.
Delete