AutoIt v3 | AutoHotKey The Official Windows Automation and Development Repository There are times when creating a batch script are the easiest and most practical way of solving a problem. When things are getting complex however, you might benefit from switching language. Why two languages in one thread? AutoHotKey (AHK) was created from the last open source release of AutoIt v3 from 2003. Since then, a lot has happened with both languages. Make no mistake, these two languages are not the same or in any way compatible with each other. However, since both languages serve the same general purpose ("Windows automation") I find it appropriate to have them both in one thread. Despite the fact that both languages was originally intended automate the operation of the Windows operating system (navigating GUI's etc), they are fully capable scripting languages. A few examples is listed below in the "Hall of fame" section. The possibilities are endless when we take into consideration that both languages supports loading functions directly from DLL's. Please do ask questions and post examples in this thread. Conversion from batch to Au3/AHK could be relevant. I don't think I am experienced enough with AHK to give appropriate answers always (I'm an AutoIt guy), but I'm sure someone else is. 1. Setting up your environment To be able to write code in AutoIt or AHK you should consider installing some of the tools listed below. 1.2 AutoIt v3 Choose this language if you feel most comfortable with a BASIC-like syntax. Scripting engine Scripting environment Customized version of SciTE The scripting environment package contains a huge compilation of tools created by the AutoIt v3 community and are reccomended to install, though, not required. A GUI designer is included. 1.3 AutoHotKey Choose this language if you prefer a C-like syntax. Scripting engine Scripting environment Customized version of SciTE A GUI designer can be obtained here. 2. Hall of fame IR4 by timesurfer AutoHotKey Windows 7 OEM Recovery Partition Tools by AnarethoS AutoIt v3 3. The simplest of all examples Let's flash a message box! 3.1 AutoIt v3 Code: MsgBox(0, "Title", "Message") 3.2 AutoHotKey Code: MsgBox 0, "Title", "Text" 4. Writing a simple graphical user interface (GUI) I believe in learning by examples, and as such, the following demonstrates how to write a GUI-based application. You should copy all example code into the SciTe Editor that you installed earlier. Save it and press F5 to run it. If you didn't know from before, the semicolon ( ; ) is used to comment on the code. 4.1 AutoIt v3 Code: #NoTrayIcon ; The application will not have an icon in the Windows system tray #include <GuiConstantsEx.au3> ; We want to use variables defined in this file $h_window = GuiCreate("My Digital Script", 300, 150, -1, -1) ; Create a window and store the handle (hWnd) to it in the variable $h_window $h_button = GUICtrlCreateButton("Sherlock Holmes", 50, 50, 200, 50) ; Create a button on our new window GUISetState(@SW_SHOW, $h_window) ; All right, the GUI is finished, let's show it While 1 ; This is a loop, since 1 is always going to be 1, this loop will run forever, or untill something inside it makes it stop Local $msg = GUIGetMsg() ; This function checks if someone has tried to use our window, if yes, the action will be stored in the variable $msg Switch ($msg) ; Let's look closer at the $msn variable Case $GUI_EVENT_CLOSE ; Crap, someone tries to close the window Exit ; All right, let's quit Case $h_button ; Someone clicked our button MsgBox(64, "Yep", "You just clicked the button.", -1, $h_window) ; Let them know EndSwitch ; Done Sleep(20); We will do nothing for 20 milliseconds, this is to prevent 100% CPU usage WEnd ; All right! The loop has finished and will now start over again at "While 1" 4.2 AutoHotKey v3 Code: N/A I would appreciate if someone could contribute a similar example for AutoHotKey 5. Performing a copy operation Some people copy documents, others copy images. We copy certificates Following is my translation of MasterDisaster's solution on the following quoted problem in the batch thread. 5.1 AutoIt v3 Code: #NoTrayIcon ; We don't want a tray icon Local $s_source = "<path to my folder>" Local $s_destination = @ScriptDir & "\" & @MON & "-" & @MDAY & "-" & @YEAR ; Show error and halt operation if we can't create the destination directory If Not (DirCreate($s_destination)) Then MsgBox(64, "Error", "Unable to complete copy operation"); Exit; EndIf ; Show error and halt operation if we can't copy files to the destination directory If Not (FileCopy($s_source & "\*.*", $s_destination, 9)) Then MsgBox(64, "Error", "Unable to complete copy operation"); Exit; EndIf 5.2 AutoHotKey Code: N/A All right, let's see where this leads us - if anywhere. Then I guess this post can be improved over time.