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

Control the AutoHotkey Bitness with RunWith()

Some Objects, Functions, & Libraries need to be run with a specific Bitness of AutoHotkey (32 or 64 bit).   RunWith() is a simple way to control the bitness being used in your AutoHotkey script.

Creating a function to choose which bitness to run your AHK script

Creating a function to choose which bitness to run your AHK script

The video discusses the differences between 64-bit and 32-bit scripts, simplifying code with functions, and improving code management with variable changes in AutoHotkey, along with tips on running multiple scripts with different versions and automatically launching the appropriate version based on the system’s pointer size.

  • 00:00 📈 Joe and Isaiah compared 64-bit and 32-bit scripts, simplified code with functions, and plan to improve code management with variable changes.
    • Joe and Isaiah compared the speed of 64-bit and 32-bit scripts and discussed using different functions at the beginning of scripts.
    • The speaker explains how to create a function by identifying the differences between two similar codes and using them to simplify the code.
    • The speaker plans to change the script variables to define a function name, script path, and version to run, allowing for easier code management.
  • 04:28 💻 Verify autohotkey installation input for correct version and run script with provided path.
    • The speaker discusses verifying input for valid versions of autohotkey installation and suggests either implementing a check or relying on the error message for incorrect input.
    • Run the correct script using the path provided.
  • 07:14 💻 The speaker shares tips on running two scripts with different versions using autohotkey and message boxes.
    • The speaker attempts to run a script with two different paths and encounters a hard drive problem.
    • The speaker runs two scripts with the same function, specifies the version of each, and verifies that everything is being passed correctly.
    • The speaker explains how to use autohotkey to open two scripts in their respective versions using message boxes instead of output debug.
  • 12:14 💻 Automatically launch the appropriate version of a script based on the system’s pointer size.
    • The speaker wants to create a function in a script that always launches in either 64-bit or 32-bit.
    • The speaker suggests a quicker way to update by grabbing instead of using the other method.
    • Automatically determine the pointer size and launch the appropriate version of the script based on the version variable.
  • 16:06 📝 A function can be created to run with specific parameters, but it will only work if the script is not compiled and the version is passed correctly.
    • Use a variable as a function input to run code with specific parameters.
    • A function is created to run as 64-bit, but it will only work if the script is not compiled and the version is passed correctly.
    • The speaker tests a script and adds an if statement to prevent a loop.
    • Check if pointer size equals 4 or 8 based on version and return if equal, otherwise compare to pointer size.
  • 22:22 💻 Added if statement to avoid rerunning script if pointer size is already in expected location after trouble stopping script.
    • The speaker had trouble stopping a script and had to log out the program to stop it.
    • The speaker added an if statement to check for pointer size and compared it to the version variable to avoid rerunning the script if the pointer size is already in the expected location.
  • 24:58 💻 Fixed version comparison issue in script by adding parentheses and allowing user to specify which version to run, no auto hotkey due to move towards Unicode and obsolescence of 32-bit versions.
    • The speaker fixed a version comparison issue by adding parentheses to ensure the correct comparison and reloading the script.
    • The script launched is running on 64-bit and is honoring the relaunch on a specific version.
    • The function allows the user to specify which version to run by changing one number.
    • The reason for not having an auto hotkey built-in auto is because they are moving towards Unicode and eventually 32-bit versions will become obsolete.
  • 30:26 📝 The function created in the lecture allows for a more general approach to running specific scripts in any script.
    • The function created in the lecture allows for a more general approach to running specific scripts in any script.



hey everyone joe and Isaias’s here from the-Automator andwe were just working on this script it was the the comparison and speed benchmarking betweena 64-bit and 32-bit script and i was telling those as hey i have i have a couple functions that i use at the beginning of my scripts depending which one i wanted and then i think both of us like at the same kind of time we’re like why is that two separate functions it should it should be all right let’s make one function go ahead and share your screen here and
it’s so easy you see them side by side that’s where you’re like well duhyeah it’s really the same code twice with some minor changes and this is the great thing about functions yeah that’s right so basically this code here you have a difference inthe pointer size right and you have a few other things let me go ahead and show you let me annotate it so that we could whenever i’m working on something especially when when the code is very similar then i just go ahead and take a look at the things that
differ between them and i just try to create a function out of it or you know any other kind of thing so the first thing that i’m noticing is that the pointer size changes and that is because if it is 4 is 32-bit 8 would be 64-bitwe are changing the executable here that’s one of the things that change and the other thing might be you know the message box that you display right here after that everything else is basically the same thing okay so what i’m thinking about here one of the things that we will have
to change is these a script their variables the reason for that is because these two pieces of code grab your current script and reloads it in the correct v1 of the things that we’re gonna do is just grab the code oh see come on
my screen should be shared during that so as the code is basically the same i could just delete part of it just stay with the one that i needlet’s just call this run with that that’s going to be my function name and one of the things that i want to do is what is the script path that i want to run so that’s the path or script path that i want to run and which v1 toa script there
so i just have that those two here now script path which i know that is the same as a script there i could just put it there that’s it you know so i don’t have to that’s it that is changed already now what we’re going to do is this is the part where i decide whether it’s 32-bit or not so what i would do is just if version equals 32 right and i don’t care about anything shouldn’t that be in quotes yes it shouldthe things that i’m kind of like thinking about this part here whether i
need this part in here so ifthis is not about the script so i don’t care about that and it is never gonna be compiled because i’m actually passing yeah for now let’s just say see so right now i’m just passing a script path so that’s okay now here what i was grabbing is the location of the AutoHotkeyinstallation of the active one running yeah so and that’s okay i still want the installation forthe AutoHotkey right now and in any case if the file does not exist that would be right the
version now this part here changes to my version whatever you pass i think i will not need this whole thing right i don’t know i don’t need the if statement any longer right so so just to slow down a bit because you know instead of saying hey if it’s this do that we’re just to we’re going to be piping in exactly replacing it so this right this u32 is going to show up right here and basically if that file does not exist that means if you pass something that is wrong and i could just make a test which is what i would do
ifv1 way that i could do like just verify that you input the valid what i consider valid i just want to run 32 or 64 versionsbut in if you do not put it here if you don’t put it correctly thenyou still gonna get an error
because the the file is not going to be found so i could do the check or i could just simply not have the check in the end you’re going to get an error and it’s going to tell you what you put wrong so i could keep it like that for now in any case i’m going to run the correct script location for what is that the name no i do not want the script name what i want is this path right here this is the one that i got this is what i want to do and i want to run it right that’s okay let me just leave it like that that’s it i just run the
correct v1 should be run
with windows 32 and the other one which is this one let me copy this path and i’m gonna run it with 64 there now before i actually go ahead and double check thatlet’s just make sure that i’m getting the correct information with a breaking here when it tries to run is it doing something what is it doing let’s see let’s just stop right here oh i think my my hard drive is gonna have a problem right now can you pause in there my hard drive just type okay so yeah in this case
uh what i’m gonna do is that i’m gonna run both scripts with the same function i just put the path to both of them and now i’m just going to specify the v1 now in this case before i actuallydo much i just want to verify that everything is being passed correctly so i just i’m gonna try to run the script and see it tells me that oh you cannot have a script there as the default parameter so what we’re going to do is that if
not right if [Music] if it is not like that then a script there right let me just remove this in the meantime so you’re gonna pass it as a default parameter right there i forgot about that but in any caseyou could just inside the script verify if it is empty if it is empty just set it up now we are going to have this is the path this is our AutoHotkey it should find the correct location so it says correct so it is going to have the path to add aHotkey and the path that i passed to it and that should run it with the correct version and i
think i did it the other way around i think this one which is the one fromyeah yeah so so this one that is geeks dude is u64 and this one is 32. that’s the reason why i like to kind of like do those kind of things so i just think about it and now this should open both of the scripts each in their own version right so this would open a new scriptbut let me go ahead and here instead of making an output debug maybe i should make it a message box so that we could see it and the same is going to be true for this guy instead of an output
debug we’re going to make it a message box for now and that’s the average right yeah i just forgot to do that yeah it’s okay so let’s run it and now thisshould bring two message boxes one of them is the csun timer right three jason timer the other one is the regex timer so let me see hold on yeah this is the other one right so as you can see now this function allows me to run different scripts with different versions of AutoHotkey automatically i just have to pass which version i want to run it with yeah
which is cool however that’s not what i want okay right i want one that i actually put in the script not to launch a different script when you say you put in the script that’s what i mean by this you’re putting that in one script to launch another script all right uh-huh but you want to i want my function in that script so it always launches in 64-bit or it always launches in 32-bit all right i get what you mean now so the the original information that you had is the one that whenever you run it it checks for
the current v1 i use it comes out
fairly frequent where so what i would do what i would do isjust to just to kind of like update this it would be even a little bit quicker becausewhat i would do is grab this part which is the one that decides what mypointer size is so whether it is 64 or or 32-bit and i would just make ahold on a variable that sayslet’s go ahead as and say versionequals is going to be 32 else 64.
right that already tells me what i need maybe let’s just remove the u i’m just gonna grab this part here and change it to version so i just have the version right there it’s gonna be automatic for me this part here i could also change it to version [Music] and our other thing would be the if statement so the if statement i just want to make sure that this in here so if the script is not compiled so i’m just dealing with athen i will just check the pointer size is equal to four or and obviously the unicode doesn’t
matter because i’m going to launch unicode by default so doesn’t matter what you do it’s going to launchunicode by default so by doing this you already have a script automatically it doesn’t matter which version you have it will check whether you are in 64-bit or 32-bit and it would launch automatically the version that you need buthow do you determine so howyou don’t want it to automatically determine the business isn’t it right okay so you are gonna actually tell it what business it is right
right then in that case we could just go ahead and use that as a variable and that’s it yeah i was just saying right right so you would just copy this off but i don’t want right i see this is going to go into my library i’m going to have a function that says run as and then i put in 32 or 64. well that’s what i thought this was doing because i just tell it what to run it but in general no because that that calls it from another script okay but in in it for example say say for example this code right here you copy it you put it
in here now you say that you would you will have you will want uh-huh so now you want a function in here that says run as 64-bit is that what you mean correct or okay so right so this is what you want okay now our function which could be included later on our function would be run ass or let’s put let’s call it run with because if you say run us it’s kind of like withwhich user is running itsorry i’m growing one does not need to be there i will not i just need version here i don’t need
it here and this will only work if we are running aan AutoHotkey script it will not run if the script is compiled is that okayi don’t know why you said that but okay so what happens is that i have an if statement right here that says if the script is not compiled right so now i’m saying i don’t understand why you would why you restrain constrain it for that because if the script is compiled are you going to run the script with anotherHotkeysexecutable the the script is already an excel file yeah so you cannot
run it yeah so that’s the reason why you would but i would never be passing something to it anyway it’s compiled anyway whatever yeah no no the reason why i was asking is because i could just go ahead and remove that from there yeah no problem right yep so now you just pass the version you just get the correct location for AutoHotkey and then you run it and in this case instead of this part what i want to run is yeah it’s the same screw that you’re running that’s okay right there we go yeah so now it’s okay
now let’s go ahead and test it we copy this up go to csun we go ahead and include it and i would just say here [Music] for example and that way it doesn’t matter how many times i run the script it’s gonna run in windows in AutoHotkey 64-bit that’s what i’m understanding that should happen now let’s test it so if i go ahead and run this i should get a stop right here my version is going to be 64.
this should verify and that should be correct and yeah that’s right so now it is just running it and now i should get the message boxes even though i’m not i’m not in the c and you can copy those two lines the include in that line and change it to 32 and put that in the other one hold on i think it is entering a loop because every time it starts it goes ahead and reloads and you know what i need an if statement right here yeah there it is you see that it is going crazy there i know what is going on[Music]
if it is already in the bit that i need then i don’t need to reopen it right so let’s just do this ifthat’s why they had that if in there okay right so ifa pointer size so let me see hold onequals so let me see the pointer size is gonna be whatever we need version is gonna beso let’s see we should shouldn’t we we should use version 2 i have to actually kind of likeequal 64 or 32 right and then i’m gonna sayif that is equal that that would be four or yeah eight and now hold on these are numbers it’s
okay and now i would just say this is one thing i want to compare it to a pointer size if a puncher size i just want to i understand where you’re going yeah right so if a pointer size equals then just return because you don’t need to do anything else right i don’t need to do anything else that’s all so if the pointer size is the same as four now that depends on the version so if the version is 64 it will bring eight now the four interface is the same as that then don’t do anything i don’t need you to do anything else
now let me try to rerun it because i think i have a single instance for us in here right so now it will try to do it and then catch on realizing what it was doing there that would have taken me a while to i’m really not what was going on no because i i i know i was expecting something like that at the beginning buti i kind of like didn’t want to to deal with it but i have to figure out how i’m gonna stop this guy now that’s the thingto stop it it is just [Music]no that’s i want to stop out of Hotkey
itself probably so let me go ahead and verify let me stop all the right on this guy cannot be completed because it was already closed right exactly it’s too fast by the time that i want to kind of like close it it’s not gonna right yeah it’s changing sowhat i could do is just log out the green again that’s the only way for me to kind of like stop it so if you can pause for a second let me go ahead and do that so we he had to restart his computer to get that one script yeah that’s right that’s right so uh
what we’re doing right now is thati’m just adding an if statement which i’m just checking for the pointer sizewhat i’m gonna do is that i’m grabbing the v1 that i’m expecting then there’s no point on doing anything down here and it would just return so
that way will not enter into the loop that we saw before and i just want to kind of like double check on that i run the script and i check my pointer size is eight so my version right now if it’s 64 it should also return an eight and this should return right here so it shouldn’t rerun the script again because the pointer size is already in the location that i needed we go out and now our script is running without issues so i know that now this is running fine even though if i change if i switch my version
to 32-bit let’s just make sure that it is 32-bit right now so that we can really test itlet’s seeinstead of 64 bit i would just remove that and just make it 32 just in case and now [Music] when i run my scriptdo i have that function already yeah so i have the break right there if i go ahead and run it so i’m running this with 32-bit so right now this should not go into the return so i see that my pointer is different right so my pointer that should not go to the return it instead should reopen the script and let me break oh
well i cannot break because after it’s reloaded i will not be able to follow it but if i go ahead and hit that come on what for version 64. that shouldn’t have happened why did it go to return there that makes absolutely no sense so let’s go ahead and make this a variable and verify that again let me check what happened there and you’re doing that so you can see that value right right i just want to see okay so in this case it got eight and this is four so what happened there hold on oh my god what so that’s what i was
expecting i was expecting it to jump the return but it didn’t let’s try it again maybe because i didn’t reload the script oh look at that oh because this should be in its own parenthesis right that’s right has to be the parenthesis there so now if it is in the parenthesis yeah it would jump becausethe equal sign was actually referring to the whole thing and that’s not what i wanted right so the parenthesis here is needed now we have the correct version comparison if it is pointer four it would just do that now in this case
the script is gonna reload it’s gonna go it is gonna be okay this time it’s not gonna go to the return and for that reason i should see two message boxespopping up in a few seconds because it should go yeah there’s one on them and here’s the Auto one now these these two message boxes are not running windows out of Hotkey 32-bit they are running on out ofHotkey 64-bit and i could double check that by going to the task manager and probably you will see thatthe AutoHotkey script i have a 32-bit here 32-bit here and the
unicode here 64-bit so all my other scripts are running 32-bits right those are scripts that i have running they’re running in 32-bit but the one that the script just launched is in 64-bit that’s the one that is running right now and if i close it it would that will go away so as you can see it is actually honoringthe the thing of yeah that it should just relaunch the script on a specificversion sowhat i notice here i understand now what you were trying to do at the beginning was you want a function in which you force
it to run in that particular version not to do it automatically because the the code that you have at the moment does it automatically it just checks what the pointer is and if it is not whatever you need it just goes ahead and launches the the specific version but with this you will be able to run this with the version that you want at any point right so you just specify what you want and it would just go ahead and right and in the example i gave you i have and because i just put it into ap i have it hey launch is in 32 or launch it in 64.
and i know which one to go get but why not just have that in the function that i just changed the number right exactly you just change one numberand that’s it this thing is going to go ahead and fetch the correct version for you right there it’s a shame that’s not built in AutoHotkey also just you know the thing that you can tell the script what control what fitness you want but anyway yeah now well the the main idea i think the reason why they haven’t done that is because they’re going away from uh
certain things like for example all the v1 is
cool as well right to be able to launch a script because you know me i have it in my main script i launch other scripts so that one i could use the one you’re doing right so this function right here the this run with function the one that i created firstyou could inside your script call other scripts with a specificfitness to them which might be you know good for in certain situations but what you have right here is kind of like a more general approach that you can just slap this function into any script and
you force it to run in a specific business yeah that’s right excellent all right thank you okay oh everyone if you get confused the-Automator.
com and we offer consulting services where we will help educate you and work with you to level you up to me it’s best ways that you can start learning AutoHotkey and make really significant jumps is having someone assess where you are and then kind of nudge you a little bit higher and higher and get your code worked on by someone who’s been doing it for a long time

Comments are closed.