Learn to code with AutoHotkey - Create and setup a script

Learn to code with AutoHotkey – Create and setup a script

Views:13666|Rating:4.33|View Time:4:35Minutes|Likes:52|Dislikes:8
Organize your script–use the same syntax
{Bracket structure} to group in notepad++
Hotkeys to create:
Windows Spy

At the risk of giving a man a fish, here is what I use to activate Windows Spy, that comes with your ahk install.
^Capslock:: ;Windows Spy
sendinput {capslock up}
ifwinexist ahk_class AU3Reveal
SetCapsLockState Off
run AU3_Spy.exe

welcome to another episode of learning to code with autohotkey I'm Tyler Dalton in this lesson we are going to learn how to organize your script and some things that will really help you when you're developing your script we're gonna learn about the following commands reload pause suspend and windows Spy so let's get started the nice thing about autohotkey is that you can fire a hotkey to make it reload your script and then fire whatever key you've been working on so what I chose as my hotkey is all two backslash and the alt as you will see in the list of modifiers is exclamation point so I'm going to put a exclamation point backslash double colon to make it a command and then tab over and the command is just reload simple and then I'm gonna put a return just so it kind of starts the script over you know just so it works so that's that so I press save I can also come down here and right click on my command and say reload this script essentially this hotkey just covers that so I have to do is save and then I'll back slash and it reloads as you saw it down in the corner so reload it just goes away and comes right back and then I'm ready to go so whatever changes I've made to my script are now ready to fire ok the next command is pause pause essentially pauses your script so that if you have a loop or something running you can pause it before it continues this is very helpful especially when we get into the loop section but pause there is a pause key on your keyboard and it's simply assigning pause to pause to the script so that's all the code you need it's paused two colons and pause we're just gonna keep it like that the next one is suspend so what's the spin does is kind of gets rid of your hotkeys so they don't work so if you are in a program that has a native hotkey function but you've already written something in your your hockey program to override that you can just suspend your script so if you come down here and say you know right-click suspend hotkeys it makes us so your hockey's don't work temporarily and then you can unsuspended work so I'm gonna set that up as a hotkey and I chose to do pause and scroll lock so pause ampersand scroll lock so the ampersand makes it so I press pause and scroll lock both together and then that will pause it so one singularly won't do it I put the ampersand to make it do two so and then just : it's a spin make sure you spell it right okay in the next is Windows spy instead of going through this whole code because I chose to do control caps lock I had to do an extra line that said make sure that caps lock is off you know when you finish and then it's going to run this is the executable for the windows spy in the system so I can show you how this works so I just save and reload and then if you see down here in my tray I can press pause so when it turns red is paused so I just press the pause key and then I press pause scroll lock and when I pissed those two down it suspends my hotkeys like I programmed so it works out quite nicely they're right there together if I ever need to turn them on or off and then my windows spy control caps lock that brings up this so the windows spy if you click on another window you can then see the information about the window and a whole bunch of other jazz that we will use later but the control caps lock keeps my caps lock off but also lets me access that you can also right-click on here if you window spy from there so but this makes it a lot quicker so ctrl s alt backslash save and reload your script if you get these going and something that works really well that is going to help your programming move much quicker that's essentially all I had except for these squirrely brackets these aren't necessarily used for the script I mean this I could do without them but the reason I put them in there so an opening and a closing is that I can squish that section or group it it's it's a notepad plus plus function but that's it's really helpful when you have a lot of hotkeys programmed all to zero will squish all your groups which makes it really nice to be able to read them okay that's all I had for that lesson I will see you in the next lesson happy coding

18 Replies to “Learn to code with AutoHotkey – Create and setup a script”

  1. Sinoyun Siyaba

    hello sir can u help me make a script for games i want to change my keyboard button control to be letter D and another one Sir to make my left click mouse equivalent to number 123 thank you.

  2. Antoniou

    I want a script that presses Space down 0 delay space up 40ms delay,Space down 0 delay space up 40ms delay, My problem is that I want it when I press space bar but it screw things up because it count my press

  3. rami maayha

    can anyone helpme ??
    I need to write a script in AutoHotkey to open file in "C:UsersramiDesktop"
    by press ( ctrl+q ) ????

  4. Wayne Aimable

    can some one help me?….am trying to right a script so every time I press "shift+W" it is equal to double tapping W….can someone write this for me?

  5. TheNinjaTail

    Hi, can anyone help me i need a autokey with something like this:
    Press 1 for infinite time with time periodos of 5 secunds please help,thanks!

  6. Toms Matisons

    Hi, I already found so far this, try and check result:

    Gui, Add, Edit, r30 w450 vMyEdit, POWERLINE CONDITION:
    Gui, Show, w500 h300, Power lines commentary text box nr1

    Gui, Submit, NoHide

    FileDelete, data.txt
    FileAppend, %MyEdit%, data.txt

    BUT!!!  – as I told I still can not:

    1. Save text boxes (as *.txt files)
    2. simultaneously lauch, for example, ten buttons with name A
    to have 10 separate text boxes of A type.

    Can you help me out?

  7. Toms Matisons

    Hi, thank`s for answer.

    But how can I save these opened text boxes and where are they saved? I can not find them anywere…?

    And can you please write me the script for my needs, I already spent whole day trying to make this and I have to fly tomorrow, it is 1:10 am here in Europe… Pleasee help buddy, if it is not too complicated for you.

    Second option – I will contiue to dig tomorrow..

  8. Toms Matisons

    Also two more questions:
    1. how I can manage these *.txt file saving location?
    2. can I open simultaneously more than 1 text window to make my notes at the same time?

  9. Toms Matisons

    Hi, thank`s for video.

    I have question for you – I want to make few touchscreen buttons on my W7 OS tablet
    for which I can give name as I want and each this "push button" creates .txt row to the one .txt file

    When I need these buttons, I can decide content of every row (buttonpush) before using them.
    After mission is done,  I just name and save created .txt files to hard disc.

    Is it possible?

    And how I can manage these *.txt file saving location?
    And can I open simultaneously more than 1 text window to make my notes at the same time?

    Can you assist me with the script or write it, please..

    Thank`s in advance!

    with very kind regards,


Leave a Reply

Your email address will not be published. Required fields are marked *