Archive

Posts Tagged ‘AutoHotkey’

If You Like Using Macros or AutoHotkey, You Might Want To Try The Enterpad AHK Keyboard

February 12th, 2014 No comments

If you follow my blog then you already know I’m a huge fan of AutoHotkey (AHK), and that I created the AHK Command Picker to allow me to have a limitless number of AHK macros quickly and easily accessible from my keyboard, without having a bunch of hotkeys (i.e. keyboard shortcuts) to remember.  The team over at CEDEQ saw my blog posts and were kind enough to send me an Enterpad AHK Keyboard for free 🙂

 

What is the Enterpad AHK Keyboard?

The Enterpad AHK keyboard is a physical device with 120 different touch spots on it, each of which can be used to trigger a different AHK macro/script.  Here’s a picture of it:

While macro keyboards/controllers are nothing new, there are a number of things that separate the Enterpad AHK keyboard from your typical macro keyboard:

  1. The touch spots are not physical buttons; instead it uses a simple flat surface with 120 different positions that respond to touch.  Think of it almost as a touch screen, but instead of having a screen to touch, you just touch a piece of paper.
  2. This leads to my next point, which is that you can use any overlay you want on the surface of Enterpad AHK keyboard; the overlay is just a piece of paper.  The default overlay (piece of paper) that it ships with just has 120 squares on it, each labeled with their number (as shown in the picture above).  Because the overlay is just a piece of paper, you can write (or draw) on it, allowing you to create custom labels for each of your 120 buttons; something that you can’t do with physical buttons.  So what if you add or remap your macros after a month or a year? Just erase and re-write your labels (if you wrote them in pencil), or simply print off a new overlay.  Also, you don’t need to have 120 different buttons; if you only require 12, then you could map 10 buttons to each one of the 12 commands you have, allowing for a larger touch spot to launch a specific script.
  3. It integrates directly with AHK.  This means that you can easily write your macros/scripts in an awesome language that you (probably) already know.  While you could technically have any old macro keyboard launch AHK scripts, it would mean mapping a keyboard shortcut for each script that you want to launch, which means cluttering up your keyboard shortcuts and potentially running them unintentionally.  With the Enterpad AHK keyboard, AHK simply sees the 120 touch spots as an additional 120 keys on your keyboard, so you don’t have to clutter up your real keyboard’s hotkeys.  Here is an example of a macro that displays a message box when the first touch spot is pressed:
    001:
    MsgBox, "You pressed touch spot #1."
    Return
    

What do you mean when you say use it to launch a macro or script?

A macro or script is just a series of operations; basically they can be used to do ANYTHING that you can manually do on your computer.  So some examples of things you can do are:

  • Open an application or file.
  • Type specific text (such as your home address).
  • Click on specific buttons or areas of a window.

For example, you could have a script that opens Notepad, types “This text was written by an AHK script.”, saves the file to the desktop, and then closes Notepad.  Macros are useful for automating things that you do repeatedly, such as visiting specific websites, entering usernames and passwords, typing out canned responses to emails, and much more.

The AHK community is very large and very active.  You can find a script to do almost anything you want, and when you can’t (or if you need to customize an existing script) you are very likely to get answers to any questions that you post online.  The Enterpad team also has a bunch of general purpose scripts/examples available for you to use, such having 10 custom clipboards, where button 1 copies to a custom clipboard, and button 11 pastes from it, button 2 copies to a different custom clipboard, and button 12 pastes from it, etc..

 

Why would I want the Enterpad AHK Keyboard?

If you are a fan of AutoHotkey and would like a separate physical device to launch your macros/scripts, the Enterpad AHK Keyboard is definitely a great choice.  If you don’t want a separate physical device, be sure to check out AHK Command Picker, as it provides many of the same benefits without requiring a new piece of hardware.

Some reasons you might want an Enterpad AHK Keyboard:

  • You use (or want to learn) AutoHotkey and prefer a separate physical device to launch your scripts.
  • You want to be able to launch your scripts with a single button.
  • You don’t want to clutter up your keyboard shortcuts.
  • You want to be able to label all of your hotkeys.

Some reasons you may want a different macro keyboard:

  • It does not use physical buttons.  This is great for some situations, but not for others.  For example, if you are a gamer looking for a macro keyboard then you might prefer one with physical buttons so that you do not have to look away from the screen to be sure about which button you are pressing.  Since the overlay is just a piece of paper though, you could perhaps do something like use little pieces of sticky-tac to mark certain buttons, so you could know which button your finger is on simply by feeling it.
  • The price. At nearly $300 US, the Enterpad AHK keyboard is more expensive than many other macro keyboards.  That said, those keyboards also don’t provide all of the benefits that the Enterpad AHK keyboard does.

Even if you don’t want to use the Enterpad AHK keyboard yourself, you may want to get it for a friend or relative; especially if you have a very non-technical one.  For example, you could hook it up to your grandma’s computer and write a AHK script that calls your computer via Skype, and then label a button (or 10 buttons to make it nice and big) on the Enterpad AHK keyboard so it is clear which button to press in order to call you.

One market that I think the Enterpad AHK keyboard could really be useful for is the corporate world, where you have many people doing the same job, and who all follow a set of instructions to do some processing.  For example, at a call center where you have tens or hundreds of employees using the same software and performing the same job.  One of their duties might be for placing new orders of a product for a caller, and this may involve clicking through 10 different menus or screens in order to get to the correct place to enter the customers information.  This whole process could be automated to a single button press on the Enterpad AHK keyboard.  You are probably thinking that the software should be redesigned to make the process of submitting orders less cumbersome, and you are right, but most companies don’t develop the software that they use, so they are at the mercy of the 3rd party software provider.  In these cases, AHK can be a real time-saver, by a company deploying an Enterpad AHK keyboard to all of its staff with a custom labeled overlay, and the IT department writing the AHK scripts that the employees use with their Enterpad AHK keyboards, all of the staff can benefit from it without needing to know anything about AHK.

 

Conclusion

So should you go buy an Enterpad AHK Keyboard?  That is really up to you.  I have one, but find that I don’t use it very often because I tend to prefer to use the AHK Command Picker software so that my fingers never leave my keyboard.  Some of my co-workers have tried it out though and really love it, so if you prefer to have a separate physical device for launching your macros then the Enterpad AHK Keyboard might be perfect for you.

Categories: AutoHotkey Tags: , , ,

Get AutoHotkey To Interact With Admin Windows Without Running AHK Script As Admin

November 21st, 2013 7 comments

A while back I posted about AutoHotkey not being able to interact with Windows 8 windows and other applications that were Ran As Admin.  My solution was to run your AutoHotkey (AHK) script as admin as well, and I also showed how to have your AHK script start automatically with Windows, but not as an admin.  Afterwards I followed that up with a post about how to get your AHK script to run as admin on startup, so life was much better, but still not perfect.UAC Never Notify

 

Problems with running your AHK script as admin

  1. You may have to deal with the annoying UAC prompt every time you launch your script.
  2. Any programs the script launches also receive administrative privileges.

#1 is only a problem if you haven’t set your AHK script to run as admin on startup as I showed in my other blog post (i.e. you are still manually launching your script) or you haven’t changed your UAC settings to never prompt you with notifications (which some companies restrict) (see screenshot to the right).

#2 was a problem for me. I use AHK Command Picker every day. A lot. I’m a developer and in order for Visual Studio to interact with IIS it requires admin privileges, which meant that if I wanted to be able to use AHK Command Picker in Visual Studio, I had to run it as admin as well.  The problem for me was that I use AHK Command Picker to launch almost all of my applications, which meant that most of my apps were now also running as an administrator.  For the most part this was fine, but there were a couple programs that gave me problems running as admin. E.g. With PowerShell ISE when I double clicked on a PowerShell file to edit it, instead of opening in the current (admin) ISE instance, it would open a new ISE instance.

    There is a solution

    Today I stumbled across this post on the AHK community forums.  Lexikos has provided an AHK script that will digitally sign the AutoHotkey executable, allowing it to interact with applications running as admin, even when your AHK script isn’t.

    Running his script is pretty straight forward:

    1. Download and unzip his EnableUIAccess.zip file.
    2. Double-click the EnableUIAccess.ahk script to run it, and it will automatically prompt you.
    3. Read the disclaimer and click OK.
    4. On the Select Source File prompt choose the C:\Program Files\AutoHotkey\AutoHotkey.exe file.  This was already selected by default for me. (Might be Program Files (x86) if you have 32-bit AHK installed on 64-bit Windows)
    5. On the Select Destination File prompt choose the same C:\Program Files\AutoHotkey\AutoHotkey.exe file again.  Again, this was already selected by default for me.
    6. Click Yes to replace the existing file.
    7. Click Yes when prompted to Run With UI Access.

    That’s it.  (Re)Start your AHK scripts and they should now be able to interact with Windows 8 windows and applications running as admin 🙂

    This is a great solution if you want your AHK script to interact with admin windows, but don’t want to run your script as an admin.

     

    Did you know

    If you do want to launch an application as admin, but don’t want to run your AHK script as admin, you can use the RunAs command.

     

    I hope you found this article useful.  Feel free to leave a comment.

    Happy coding!

    Too Many AutoHotkey Shortcuts To Remember? There’s An App For That!

    January 19th, 2013 2 comments

    I love AutoHotkey (AHK). Ever since I discovered it a little over a year ago I am constantly surprised and pleased with what I am able to accomplish with it.  And there in lied my problem.  Out of the box, AHK allows you to trigger your own scripts using hotkeys.  My problem was that I had so many of these little (and some large) scripts to do so many things, that i quickly ran out of hotkeys to use that wouldn’t interfere with other application’s shortcut keys (Visual Studio anyone); also even if I had more hotkeys available, trying to remember which ones did what was a nightmare. To remedy this, I created AHK Command Picker.

    AHK Command Picker is really just a little UI that allows you to quickly run your scripts; so instead of using a hotkey, you just hit the Caps Lock key to bring up the UI, and then start typing for the script that you want to run.  It provides Camel Case filtering to still make launching scripts super fast, and also shows your scripts in a list, allowing you to browse through them. It also allows to you easily pass parameters into your scripts, which can be used to change a script’s behaviour.  Here’s a screenshot showing the UI and some of the many scripts that I have:

    AHKCommandPicker-AllCommands

    And here’s a screenshot showing it filter the list as you type:

    AHKCommandPicker-FilteredCommands

    One of my favourite things about AHK is the community. There are so many scripts out there that before you write your own code, you should just do a quick Google search and chances are you’ll find someone who has already written the script for you, or one that is close to your needs and can be quickly modified.  I assumed this would be the case for the type of tool I was looking for.  So I searched and came across HotKeyIt and Keyword Launcher, both of which were interesting and neat, but neither provided a GUI to quickly see your list of scripts so that you could launch it quickly.  They still relied on you to remember your specific hotkeys; I wanted a list that I could browse my scripts from to easily launch them.

    I love programming and learning new languages, so I thought I’d give creating the type of picker that I wanted a shot. It’s still not perfect, and I have many ideas for new features that could make it better, but using it as it is today has improved my productivity so much.  I’ve shown it to some people at my work and many of them started using it and agree.

    If all you are looking for is a program to quickly launch applications or open files, then I would recommend KeyBreeze.  It’s a great little free app written in C# and is very polished (and much better than Launchy in my opinion because you can add ANY file/app to it via the context menu). But if you use AHK and want to be able to quickly launch your own scripts, definitely check out AHK Command Picker. Like myself you will probably find that you go from using AHK to launch 10 – 20 scripts, to using it to launch hundreds or even thousands of scripts, saving you time and effort constantly throughout your day.  Those things that you maybe only do once or twice a month and didn’t want to dedicate a hotkey to will start showing up in your scripts list.

    So go ahead and give AHK Command Picker a try, and be sure to let me know what you think of it and what improvements you would like to see by logging it on the Codeplex site.

    Get AutoHotkey Script To Run As Admin At Startup

    November 6th, 2012 4 comments

    <Update>Before you go running your script as an admin, see if this less obtrusive fix will solve your problems.</Update>

    A few weeks back I posted some problems with running AutoHotkey (AHK) in Windows 8, and that the solution was to run your AHK script as admin.  I also showed how to have the script start automatically when you logged into Windows.  What I didn’t realize at the time though was that the method only worked for launching my AHK script as an admin because I had disabled UAC in the registry (which prevents most Metro apps from working in Windows 8, and likely isn’t acceptable for most people).

    So here is a Windows 8, UAC-friendly method to automatically launch your AHK scripts as admin at startup (also works in previous versions of Windows).  The trick is to use the Task Scheduler:

    1. Open the Task Scheduler (also known as “Schedule tasks” in Windows 8 Settings).

    Open Task Scheduler

    2. Create a new Basic Task.

    3. Give it a name and description (something like “launch AutoHotkey script at login”), and then specify to have it run “When I log on”.  Then specify that you want it to “Start a program”, and then point it towards your AutoHotkey script.  Before you finish the wizard, check off “Open the Properties dialog for this task when I click Finish”.

    Create Basic Task in Task Scheduler

    4. When that Properties dialog opens up, go to the Conditions tab and make sure none of the checkboxes under the Power category are checked off; this will ensure the script still launches if you are on a laptop and not plugged into AC power.

    Basic Task Conditions

    5. Now here is the important part; To have your script “Run as admin”, on the General tab check off “Run with highest privileges”.

    Run Scheduled Task as Admin_thumb[3]

    Now your AHK script should start automatically as soon as you log into Windows; even when UAC is enabled Smile

    6. If your AHK script uses an #Include statement to include other files, you may get an error similar to this one when your task runs:

    “#Include file … cannot be opened. The program will exit.”

    AHK Cannot Open Include File

    The solution to this is to tell your AHK script to start in the same directory as the file that you want to include.  So you will need to edit your scheduled task’s Action to specify the Start In directory.

    Task Scheduler Start In Directory

    Happy coding!

    ==< EDIT >==

    What I failed to realize earlier was that by default the Task Scheduler runs it’s programs in non-interactive mode, so they may run as the correct user, but in a different user session.  Since most AHK scripts are interactive (i.e. they respond to user input), this means that your script may not work exactly as it should all of the time.  For example, my AHK scripts were not able to launch ClickOnce applications.

    The fix is to create your Scheduled Task in interactive mode.  Unfortunately you cannot do this through the GUI; it must be done through the command line.  So if you open up a command prompt you can use the following command to create a new interactive scheduled task:

    schtasks /Create /RU "[Domain][Username]" /SC ONLOGON /TN "[Task Name]" /TR "[Path to program to run]" /IT /V1

    for example:

    schtasks /Create /RU "Dan Schroeder" /SC ONLOGON /TN "Launch AHK Command Picker" /TR "D:AHKStuffAHKCommandPicker.ahk" /IT /V1

    The /IT switch is what tells it to create the task in Interactive mode.  The /V1 switch actually specifies to create the task as a Windows XP/2000/Server 2003 compatible task, and has the added benefit of making the task run as admin by default with the Start In directory specified as the directory holding the file to run (i.e. steps 5 and 6 above; you will still need to do step 4 though).

    If you already have your Scheduled Task created, you can simply make it interactive with the command:

    schtasks /Change /TN “[Task Name]” /IT

    I hope you find this as helpful as I did!

    ==</ EDIT >==

    AutoHotkey cannot interact with Windows 8 Windows…or can it!

    September 10th, 2012 No comments

    <Update>Before you go running your script as an admin, see if this less obtrusive fix will solve your problems.</Update>

    If you’ve installed Windows 8 and are trying to use AutoHotkey (AHK) to interact with some of the Winodws 8 Windows (such as the Control Panel for example), or with apps that need to be Ran As Administrator, then you’ve likely become very frustrated as I did to discover that AHK can not send any commands (keyboard or mouse input) to these windows.  This was a huge concern as I often need to run Visual Studio as an administrator and wanted my hotkeys and hotstrings to work in Visual Studio.  After a day of fighting I finally realized the answer (and it’s pretty obvious once you think about it).  If you want AHK to be able to interact with Windows 8 Windows or apps running as administrator, then you also need to have your AHK script Run As Administrator.

    If you are like me then you probably have your AHK scripts set to run automatically at login, which means you don’t have the opportunity to right-click on the script and manually tell it to Run As Administrator.  Luckily the work around is simple.

    First, if you want to have your AHK script (or any program for that matter) run when you log in, create a shortcut to the application and place the shortcut in:

    C:\Users\[User Name]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

    Note that you will need to replace “[User Name]” with your username, and that “AppData” is a hidden folder so you’ll need to turn on viewing hidden folders to see it (you can also type “shell:startup” in the Windows Explorer path to jump directly to this folder).  So by placing that shortcut there Windows will automatically run your script when you log on.  Now, to get it to run as an administrator by default, right-click on the shortcut and go to Properties.  Under the Shortcut tab, click on the “Advanced…” button and check off “Run as administrator”.  That’s it.  Now when you log onto Windows your script will automatically start up, running as an administrator; allowing it to interact with any application and window like you had expected it to in the first place.

    ==< EDIT >==

    This method works for running AHK scripts that don’t require admin privileges at startup.  It only works for running AHK scripts as admin at Windows startup if you have disabled UAC in the registry in Windows 8, which you likely do not want to do (and I had done at the time of writing this article, but have since switched it back on).  For a better, UAC-friendly solution to running your AHK scripts as admin at startup, see my newer post to actually get your AHK script to run as admin at startup.

    If you do need your AHK script to run as admin and plan on manually double-clicking your AHK script to launch it though, then you can still use this trick of create a shortcut and setting it to Run As Admin in order to avoid having to right-click the AHK script and choose Run As Admin.

    ==</ EDIT >==

    image

    Happy coding!

    Setting up keyboard shortcuts to build solutions in MSBuild

    June 1st, 2011 No comments

    One of the greatest benefits of building your solution flies in MSBuild (vs in Visual Studio directly) is that it doesn’t lock up the Visual Studio UI, which can be a huge pain if you have a large solution that takes several minutes (or longer) to build.  Building your solution in MSBuild leaves you free to inspect code in Visual Studio while your solution is building.  The only problem is that to do this you have to open a command prompt and type the command + path every time to build.

    If you want to be able to right-click on a solution file and build it in MSBuild from the Windows Explorer context menu, check out MSBuildShellExtension (it’s free).  Being able to build right from Windows Explorer (without having to even open Visual Studio) is cool and may be enough to passify you, but I wanted to be able to build my solution file at anytime from anywhere on my PC with a keyboard shortcut.

    Below I outline how I’ve setup my system to build my solution files in MSBuild with a quick keystroke.  Setup only takes a few minutes and requires AutoHotkey to be installed (it’s free and awesome).

    Step 1 – Install AutoHotkey.

    Step 2 – Create a shortcut to the Visual Studio Command Prompt (2010), move it directly to the C: drive, and make sure it is called “Visual Studio Command Prompt (2010)” (it is referenced at this location with this name by the AutoHotkey script in the following steps, but can be changed if needed).

    VS2010CommandPrompt

    CDrive

    Step 3 – Create your AutoHotkey script……luckily, you don’t have to create it from scratch; you can use mine as your template and just adjust it to your liking . So copy and paste the script in the textbox below into a new text file, and then save it with the extension ".ahk", which is the AutoHotkey script extension (so you can just call it "AutoHotkeyScript.ahk" for example).  You will need to modify the code directory paths and solution file names in the script to match yours to build your solutions, but I’ve commented the script fairly thoroughly so it’s easy to see what it’s doing.

    In my office we have both a Client solution and a Server solution, so I have the script setup to build the client solution with WindowsKey+C and the server solution with WindowsKey+S. We also work in multiple branches, so I have global variables near the top of the script that I can set to true to quickly switch between Development, QA, and Release branches.  I also have WindowsKey+U configured to open the code directory and WindowsKey+Q to open the database directory.  Obviously you can change the keyboard mappings to your liking; these are just the ones that I prefer.  As a side note here, just be aware that these will override the default windows key shortcuts; so in my case WindowsKey+U no longer opens up the Windows Ease of Access Center window.

    ; IMPORTANT INFO ABOUT GETTING STARTED: Lines that start with a
    ; semicolon, such as this one, are comments.  They are not executed.
     
    ; This script has a special filename and path because it is automatically
    ; launched when you run the program directly.  Also, any text file whose
    ; name ends in .ahk is associated with the program, which means that it
    ; can be launched simply by double-clicking it.  You can have as many .ahk
    ; files as you want, located in any folder.  You can also run more than
    ; one ahk file simultaneously and each will get its own tray icon.
     
    ; Make it so only one instance of this script can run at a time (and reload the script if another instance of it tries to run)
    #SingleInstance force
     
    ;==========================================================
    ; Global Variables - Path settings, customization, etc.
    ;==========================================================
     
    ; Set one of these to &quot;true&quot; to build from the Staging or Release branches, otherwise we'll use the development branch.
    _UsingTFSStagingBranch := false
    _UsingTFSReleaseCandidate := false
     
    ; Specify the Code Folder containing the Solution files to build
    if (_UsingTFSReleaseCandidate == true)
    {
        ; The directory of the current build's Code folder
        _CodeFolder := &quot;C:\dev\TFS\RQ4TeamProject\Release\RQ4\4.2.0\&quot;
    }
    else if (_UsingTFSStagingBranch == true)
    {
        ; The directory of the current build's Code folder
        _CodeFolder := &quot;C:\dev\TFS\RQ4TeamProject\Staging\RQ4\&quot;
    }
    else
    {
        ; The directory of the current build's Code folder
        _CodeFolder := &quot;C:\dev\TFS\RQ4TeamProject\Dev\RQ4\Core\&quot;
    }
     
    ; Path to the database folder
    _DatabaseFolder := &quot;C:\dev&quot;
     
    ; The path to the Visual Studio Command Prompt link
    _VSCommandPromptPath := &quot;C:\Visual Studio Command Prompt (2010).lnk&quot;
    _VSCommandPromptWindowName := &quot;Administrator: Visual Studio Command Prompt (2010)&quot;
     
    ; The position I want the MS Build window to move to when opened
    _MSBuildWindowPositionX := 400
    _MSBuildWindowPositionY := 270
     
    ; The MSBuild command to use
    _MSBuildCommand := &quot;msbuild&quot; ; /verbosity:minimal&quot;
     
     
    ;==========================================================
    ; WindowsKey+C - Build the Client.sln
    ;==========================================================
    #c UP::
     
    ; Make sure the keys have been released before continuing to avoid accidental commands
    KeyWait LWin
    ;KeyWait c
     
    ;BuildSolution(_CodeFolder . &quot;RQ4.Client.sln&quot;)
    BuildSolution(&quot;RQ4.Client.sln&quot;)
     
    return
     
    ;==========================================================
    ; WindowsKey+S - Build the Server.sln
    ;==========================================================
    #s UP::
     
    ; Make sure the keys have been released before continuing to avoid accidental commands
    KeyWait LWin
    ;KeyWait s
     
    BuildSolution(&quot;RQ4.Server.sln&quot;)
     
    return
     
    ;==========================================================
    ; WindowsKey+B - Build the Server.sln then Client.sln
    ;==========================================================
    #b UP::
     
    ; Make sure the keys have been released before continuing to avoid accidental commands
    KeyWait LWin
    ;KeyWait b
     
    BuildSolution(&quot;RQ4.Server.sln&quot;)
    BuildSolution(&quot;RQ4.Client.sln&quot;)
     
    return
     
    ;==========================================================
    ; WindowsKey+U - Open the Code folder
    ;==========================================================
    #u UP::Run %_CodeFolder%
     
    ;==========================================================
    ; WindowsKey+Q - Open the Database folder
    ;==========================================================
    #q UP::Run %_DatabaseFolder%
     
     
    ;==========================================================
    ; Functions
    ;==========================================================
    BuildSolution(solutionPath)
    {
        ; Let this function know that all variables except the passed in parameters are global variables.
        global
     
        ; If the Visual Studio Command Prompt is already open
        if WinExist(_VSCommandPromptWindowName)
        {
            ; Put it in focus
            WinActivate
        }
        ; Else the VS Command Prompt is not already open
        else
        {
            ; So open the Visual Studio 2008 Command Prompt
            Run %_VSCommandPromptPath%
             
            ; Make sure this window is in focus before sending commands
            WinWaitActive, %_VSCommandPromptWindowName%
             
            ; If the window wasn't opened for some reason
            if Not WinExist(_VSCommandPromptWindowName)
            {
                ; Display an error message that the VS Command Prompt couldn't be opened
                MsgBox, There was a problem opening %_VSCommandPromptPath%
             
                ; Exit, returning failure
                return false
            }
        }
     
        ; Make sure this window is in focus before sending commands
        WinWaitActive, %_VSCommandPromptWindowName%
     
        ; Move the window to the position I like it to be
        WinMove, _MSBuildWindowPositionX, _MSBuildWindowPositionY
     
        ; Set it to the correct directory
        SendInput cd %_CodeFolder% {Enter}
     
        ;MsgBox %solutionPath%  ; Message box to display the Solution Path for debugging purposes
         
        ; Build the solution file
        SendInput %_MSBuildCommand% %solutionPath% {Enter}
         
        ; Return success
        return true
    }
    

    Step 4 – Have your AutoHotkey script automatically start when you login to Windows, so that you don’t have to manually launch it all the time.

    Method 1:

    This method is the easiest, but I discovered it after Method 2 (below).  Simply open up the Windows Start Menu, navigate to the Startup folder within All Programs, right-click on it and choose Open All Users.  Then simply paste a shortcut to your AutoHotkey script in this folder.  That’s it; the script will now launch whenever any user logs into Windows.  If you only want the script to run when you log into Windows (no other users), then just choose Open instead of Open All Users when right-clicking on the Startup folder.

     indexindex2

    Method 2:

    Open the Windows Task Scheduler and create a new Basic Task.  Give it a name and description (something like “launch AutoHotkey script at login”), and then specify to have it run “When I log on”.  Then specify that you want it to “Start a program”, and then point it towards the AutoHotkey script you created in Step 3.  Before you finish the wizard, check off “Open the Properties dialog for this task when I click Finish”.  When that Properties dialog opens up, go to the Conditions tab and make sure none of the checkboxes under the Power category are checked off; this will ensure the script still launches if you are on a laptop and not plugged into AC power.  If you need your script to “Run as admin”, then on the General tab check off “Run with highest privileges”; this may be required for your script to perform certain actions the require admin privileges, so you can check it off just to be safe.

    Open Task Scheduler(1)

     Create Basic Task in Task Scheduler

     

    Basic Task Conditions

    Run Scheduled Task as Admin_2

    And that’s it.  Now you can build your solution file in MSBuild with a quick keystroke from anywhere on your computer.  I have chosen to use the Windows Key for my shortcut keys, but you don’t have to; you can use whatever keyboard shortcut you want.  And feel free to modify the script I provided to do whatever else you want; AutoHotkey is very powerful and can be used for so many things, so be sure to checkout their website for more examples of scripts and what it can do.  For example lots of people use it to automatically spell-correct as they type, or to automatically expand abbreviations (so I could type DS and hit tab, and have it expand to Daniel Schroeder, or type MyAddress and have it put my address in).

    Happy Coding!