• Become a Power user Intro to AutoHotkey Intermediate AutoHotkey Intermediate Objects GUIs are Easy w/AutoHotkey Painlessly switch from V1 to V2

Easily add the #Requires directive to your files with: Append2Files

V2 will be the default version for AutoHotkey soon! We wrote this simple tool to easily update your scripts with the #Requires directive

Catastrophe ahead❓ Not if you use this AutoHotkey script today❗
 Catastrophe ahead❓ Not if you use this AutoHotkey script today❗

This video provides a way to quickly review AutoHotkey files and convert them to AHK Version 2, with the option to add more features.

  • 00:00 AutoHotkey Version 2 has improved features, but can be slow when detecting Version 1.
    • AutoHotkey Version 2 has cool features for detecting version 1 and running accordingly, but can be slow when detecting.
  • 01:03 Adding the #Requires directive to scripts ensures AutoHotkey compatibility.
    • Adding the requires directive to scripts ensures that the correct version of AutoHotkey is used, avoiding potential errors and the need for debugging.
  • 02:16 Scanned a folder for .ahk files and added a line to the beginning of each if it didn’t meet a requirement.
    • Created a simple tool to scan.
    • This script searches a folder for .ahk files and appends a line to the beginning of each file if it does not contain a specified requirement.
  • 04:01 Script will check files and skip already run, but only run files that meet version requirement.
    • The AutoHotkey script will check the files and skip any that have already been run, but it will only run files that meet the version requirement specified in the script.
  • 05:34 This script provides a way to quickly review ahk files, with the option to add more features.
    • This script allows for flexibility and can be used to look over ahk files, with the option to add more features like selecting what kind of files to look over.
  • 06:40 Select the folder and use the URL to get the script and converter for v1 to v2.
  • 07:14 Isaias is close to releasing Autohotkey with the ability to detect .ahk extensions without needing to switch them.
    • Isaias has been making major commits to the beta version of Autohotkey, and it looks like it will soon be released with the ability to detect .ahk extensions without needing to switch them.
  • 08:29 Add v2 code and like the video to help get more views.
    • Add version two code to downloads and like the video to help get more views.

Transcripts to adding #Requires directive to AutoHotkey scripts

hey everyone it’s Joe & Isaias here from the-Automator and in this video we’re going to show you how to avoid a coming disaster and i’m talking disaster so maybe i’m exaggerating a little but stick around at the end because you i really think everyone at this point in time should use this cool tool we wrote we kind of came upon it of we were discussing something and realizing wait a minute we we should use this and not only should we use it but basically almost everybody out there right now
should use this cool tool so whatwhat are we talking about is this particular disaster is the fact that at some point and it seems to me that it’s approaching faster and faster our AutoHotkey v1 or
v2 if you’ve started using ahk v2 yeah the odds are you haven’t right or you’ve maybe played
slightly with it like me you know as i just worked with a lot i’ve played with a little a couple of my scripts are this is why it’s so critical because if you haven’t really done a lot with v2 this tool you want to add this requires to all of your scripts right yes before you have an intermixing of the two which would make it really terrible to try to go back and do right so mainly one of the issues is that if the script is not for v2 and you don’t have any requirement or anything when you try to
run it it’s going to give you an error it’s going to say like you know cannot execute line whatever and you’re going to think that there is something wrong with the script and you might start debugging something that you cannot really debug now if you add the requirement what happens is that when you try to run the script it’s going to tell you this script requires AutoHotkey v1 so it will automatically remove the need for debug so what we created was a little tool and it is a very simple tool that goes ahead and
scans a lot of you give it a folder so you you’re going to use select the path that you’re going to search probably is going to be a path to any place where you have a bunch of script and in our case we have a lot of scripts going on in there right and that we didn’t want to do this manually so you’re going to give it a path to a folder it which contains many ahk files and it will skip any file that contains this line here and will append either at the beginning of the file or if you remove that at the
end of the file you can choose where to append and whatever line you want to add so we defaulted to this but you can switch this to whatever you want basically this script if you’re looking for all the files that contain the word gui and you want to append at the end and a gui control a gui close close exit or something whatever you want you can just do so just go ahead and append something to all files but in our case what we’re going to do is that i’m just going to add the requirement for version 1.1.33 or more that’s it
once you do this now let me show you here this particular file does not have the requirement but i know that this must be run with AutoHotkey v1 because guys in AutoHotkey v2 look way different so what i want my script is to go through all the folders and checks if it has it if it doesn’t have it then append it at the beginning that’s what it does so as soon as i click ok it will check this the files and depending on the amount of files that you might have it might be faster or slower but in our case i think
now that i’m sharing my screen is a little bit slower when i was showing you this a little bit earlier it was a little bit faster but in the end it justit was 2,000 something files skipped because i already run the the script on those files and only one fixed and i see if you can tell now here at the top of my script i have my requirement so yeah well i was gonna say was one thing that might confuse people because for me this was it like well wait a minute v2 is greater than version 1.
1.33 however it stays within silos on that first thing right so it is just gonna oh everything that is up in this particular section if this number right here changes to two then that doesn’t that doesn’t actually fit the the description so yes this plus here is just within that particularversion point right and you’re you’re saying that just because i don’t AutoHotkey1 is kind of weird but that v1 makes you think it would say v2 there but it’s it’s really when you say requires it’s still requiring version
one at this level not you know v1 with this within this level must be at least 33 or more but it is regarding that level everything else should stay exactly the same we have a video on semantic versioning if you haven’t gone through that it’s a really good thing
now the other thing after depending on if you have worked with v2 because yes exactly you want to get this in there and then of course build it into your default template which i have a video out there somewhere showing how to set your default AutoHotkey script right because you probably want to have that in there yeah that is right so in general i thinkright now the script is really simple
again as i mentioned it does allow you to do it is a little bit flexible but later on maybe we would add a little bit more features like selecting what kind of files you want to look over because right now it just defaults to hk files but in general it it does the job it makes it very quick you don’t have to spend much time just select the folder where all your AutoHotkey v1 scripts are and you’re good to go yeah soto finish this off you canyou can get i had the url over me here earlier i’ll try to
remember to put it up again the to get this add required script that we created but also if you are interested in the v1 to v2 there’s a pretty decent converter out there unless your script has really complicated gooeys or maybe just a gooey at all right because it gets very complicated you can take a look at that url over me here the other thing i’d love to hear from you is when do you think if you’re going to guess when do you think version 2 is going to be the default official version for AutoHotkey because that’s right it’s
coming you know and Isaias and i were talking we’re like you might be sooner than you think yeah actually remember it was in alpha stage for 10 years right but then now it switched to beta and he has been making a lot of updates as of recent now we’re in beta seven so he has made sevendifferent changes major commits to the to the beta version so it looks like he’s really working on that andat some point it looks like it’s gonna be say he’s gonna say like heythis is this is
let’s go ahead and [Music] put this thing out there and he might he has been working a lot on trying to make it so that if you’re still working v1 like your .ahk extensions doesn’t need to be switched to another extension but that is something that then will create a few little problems that just adding the requirement out here will solve that for you because it automatically will detect it and say like yeah we’re good and if you’re ever sharing your code on the forum or reddit or wherever right
like have that in there and we’ve been bad about it we haven’t been necessarily i think when we do ahk v1 stuff we weren’t adding it well we were about at it because now i’ve created a tool that has its own problem so yeah and we get to go back and update all of our downloads to have it in there right because right yeah it’s gonna be and i i was learning python when they were switching between v2 and version three and it was so painful in that community it’s so
confusing now their theirs didn’t even break that much between the two but it still was problematic now ours there’s going to be a lot of changes there’s a lot of things that do not work not even similarly sojust just to mention one you see this coma that you put right next to your command like message box coma okay great yeah that just that one like that that one little detail is gonna make it so that it doesn’t work as you expect soyeah we do have a lot of videos and webinars on v2 which you can
get at the url over my head here but also if you liked this video please actually like the video it really helps us out and get more views and if you’re not a subscriber please subscribe appreciate it there you go cheers

Comments are closed.