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.
Script Compilation Script Compilation A major drawback of using other scripting languages other that Windows Batch is that they need their own interpreter to run. Have no fear though, these awesome languages can be compiled! (sort of) The 'compiler' packs your script inside a copy of the interpreter (which in itself is standalone). The result? You can run the compiled version on any computer you want without having to install anything prior. To execute your code, press F5 in the SciTE editor. To compile, press Ctrl+F7 in the SciTE editor.
I'm not sure if this is allowed, but it is cool. This is a program that can extract the script from a 'compiled' exe
Yeah I know about that one, I'm glad you mentioned it danyo1337. It's most deeply hated by the AutoIt community, and they ban everyone even daring to mention it. Consequence is that you should under no circumstances include passwords or usernames inside a compiled AutoIt script if you don't want them to leak out (some network admins does this to automate tasks etc). That's a general rule lol, but nonetheless important to remember. You'd be surprised to see how many people include sensitive information inside exposed files at large companies etc.
Dude ahk was very tolerant regarding my explicit communication regarding IR4 and it's GUI development and even they advised how to treat .bat files as variable's so IR4 could be one .ahk file to compile Wasup with AutoIt? Is .ahk cooler...lol ahh?
There are reasons Since AutoIt is such an easy language, a lot of script kiddies has been using it to create key loggers etc. So the whole language ended up being blacklisted by anti-virus companies - which pissed of the community. Then on top of that the forums was flooded with requests on "how to create a bot for WoW ololollollol" etc. So now all discussion about bots is prohibited. The guys over there also feels strongly about other peoples intellectual property so to speak, so even though they would give you the code if you asked, they will not tolerate decompilation from a moral standpoint. I'm not sure, but I think discussion about tools such as IR4 over there might earn you a ban lol tl;dr: they are cool as long as you stick to the rules
Maybe it's cause I was super polite ...lol .ahk site was really cool though. But now I got you...lol so lets put this in .ahk if you like Then if I figure out how to deal the notification problem we'll have GUI ready ...lol * Remember 2010 VL has to be in grace with atleast 1 rearm left or already activated for IORRT to work so far...lol
Nice thread...i always found these auto-tools interesting. Since my KMSA CMD has grown rather large i wonder if one of the two couldnt be used to control it via a GUI with buttons and tabs rather than console choices in menus and submenus...
I can help you get started with the GUI and some buttons but you'll have to see how the scripting works at .ahk or with calistogas help Then with your amazing PS skills you can create background that's awesome...lol
Well, lets start with some theory then, just to evaluate how much action this is going to be. 1) The app must auto-load a DLL immediately after it starts, and close it when it exits 2) The app must be able to do everything thats now done via choices via a button 3) The app must be able to display the console readout (success/error messages, infos, etc, everything thats now displayed in the console window) Is all of this generally possible, and if so, how much effort does it take?
.ahk is really capable and I think if done right could get output to be in real MS window vs. console kind like IR4 does with status button usage. What I can do is set up generic GUI of your size and specs with the buttons you want But first install .ahk
Took a look...GUI creation seems to be pretty straightforward. The make/break question: http://forums.mydigitallife.net/attachment.php?attachmentid=7540&d=1289228106
Yeah...this looks almost exactly like what i had in mind! Tabs, buttons, and a small dedicated area to display the console readout. Perhaps it would be better to take a look at VisualStudio? If only i had more time for this stuff... PS: Good job Cody, this looks real nice!
I sorta got a working windows one right now but keygen.exe won't close when I tell it to... But so far activation works but all it does is set local host then activates. I will eventually add installing the kms key as well. I'll pm you what I have now.
I have decided to drop the idea. I have already put so much effort into the console interface that i would hate to have done all that work for naught. Still thanks for the offer...maybe i will attempt such a conversion at a later time in case im ever getting bored and need a new challenge.
I wouldn't give up yet this coding forum is still new. Calistoga and others are talented but console is cool in it's own way fur sure The ahk site is so talented if you spend some time there. Their mission statement...lol "AutoHotkey Community Let's help each other out" You can't get much better than that...lol Well their close to MDL's aweomeness