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

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

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!

    1. Stephen Wille
      December 28th, 2013 at 13:25 | #1

      Thanks for the post.
      I love AHK too, and am also on a corporate win8 machine running VS2012….ugh! If you have any ideas on how to customize VS2012’s code completion, formatting, and hot keys, please post them. This has become a huge pain point.

    2. December 28th, 2013 at 16:09 | #2

      @Stephen Wille
      Hey Stephen, I’m not sure what you mean. If you are running VS as admin, then the trick I mention in this post should allow AHK to interact with VS. If you are not running VS as admin, then everything should just work without doing this trick.

      Are you asking how to customize VS 2012’s code completion, formatting, and shortcut keys natively in VS? or how to implement your own with AHK? You can customize all of the VS shortcut keys in the Tools->Options->General->Keyboard menu, and specify a few rules around code completion and formatting too in the Tools->Options menus, but not too many. If you really want to customize the code completion and formatting rules, tools like ReSharper give you much more control.

    3. Stephen Wille
      December 28th, 2013 at 16:36 | #3

      @deadlydog

      No prob running AHK, and so far, that’s my main tool for making VS easier to use.
      I really like ReSharper, and the folks who make it also make my preferred IDE, IntelliJ IDEA. Unfortunately, corporate rules prevent me from running it on my laptop. I would like to implement ReSharper like functionality natively, or though open source plugins or AHK. So far, I haven’t found VS to have much flexibility when it comes to customization, and online resources haven’t been directly on point either. So any help into how to wrest fully control of these things from VS is appreciated.

    4. Ryan
      April 30th, 2015 at 09:27 | #4

      Thanks so much for this article, and hosting the fix!

    5. Carl Scarlett
      August 19th, 2015 at 00:13 | #5

      This is awesome. Now I’m able to use my scripts in PowerShell ISE running as admin.

    6. Matteo Sacco
      October 12th, 2016 at 10:53 | #6

      thank you so much you, I use CapsLock to launch task view in Win10 just about all the time, since i’m also a mac user and I constantly use mission control. And not being able to use it in Virtual Studio was really frustrating.

    7. HaveSpacesuit
      August 18th, 2017 at 09:50 | #7

      Amazing! Half of my apps are always in Admin mode, so it was a pain to have to click out of them to use my scripts. Thanks to those who put time into it.

    1. No trackbacks yet.