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.
Problems with running your AHK script as admin
- You may have to deal with the annoying UAC prompt every time you launch your script.
- 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).
#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:
- Download and unzip his EnableUIAccess.zip file; you can also get it here.
- Double-click the EnableUIAccess.ahk script to run it, and it will automatically prompt you.
- Read the disclaimer and click OK.
- 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)
- 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.
- Click Yes to replace the existing file.
- 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.
Leave a Comment
Your email address will not be published. Required fields are marked *