12

I have a series of keyboard shortcuts defined in my autohotkey script. Currently, none of them work whenever notepad++ has focus.

The script is loaded as usual. The keyboard shortcuts (mostly stuff for moving windows around) work perfectly with any other window, they just don't do anything if the notepad++ window has focus. At the same time, all regular windows shortcuts work fine, even while notepad++ has focus. So it is a specific issue between notepad++ and autohotkey.

The shortcuts I've defined in my script don't conflict with any of notepad's standard keyboard shortcuts. Does anyone know what's happening?

Using Windows 7, notepad++ v5.8.1, autohotkey v1.0.48.03

6 Answers 6

9

For me, it was enough to restart Notepad++, so try that first.

5

I think autohotkey will fail to load the keyboard hook unless you run it as admin. If this is the case your keys won't work when another app (notepad++ or otherwise) has focus.

(I've experienced this behaviour (albeit intermittently) on autohotkey and winamp)

2
  • 1
    autohotkey doesn't have to run with admin rights to work properly. It seems rather that some applications need to be restarted to take into account the changes made into autohotkey.
    – Nicolas
    Commented Jul 8, 2014 at 20:44
  • 2
    Because I started running Notepad++ always as an admin, AHK wasn't working in Notepad++ without having admin priviliges. Thanks for the tip, this is the only thing that worked for me.
    – Rav
    Commented Feb 5, 2019 at 11:59
4

Embarrassingly enough, I restarted my PC and now it's back to normal. I have to learn to do that before asking here...

4

When running autohotkey with normal user rights while running another application (notepad++) with elevated rights, autohotkey seems to be unable to handle the keyboard input. This makes sense from a rights management perspective…

The solution is to run autohotkey with admin rights -> then the script will be able to handle all input.

1
  • This was my problem and worked for me.
    – bugybunny
    Commented Jan 8, 2019 at 10:44
0

I set my Notepad++ to always run as administrator, and this seemed to be interfering with AHK while NP++ had the focus.

Adding this to the top of my script fixed the problem. It allows you to load the script however you like, and then will restart it as an administrator if it's not already.

#SingleInstance, Force
SetWorkingDir %A_ScriptDir%
if (not A_IsAdmin) {
    Run *RunAs "%A_ScriptFullPath%"
}

Edit: With a normal #SingleInstance, Force script, you can override it by just opening it again.

With this script, to reload, you have to right-click and run it as an administrator.

  1. Script Loads as non-admin
  2. Script restarts as Admin
  3. User double-clicks script to reload
  4. The script attempts to load as non-admin, but it can't kill the Admin-privileged script, so it can't start.

Other methods of reloading the script should work fine.

0

Following an implication here, I just unchecked "run as administrator" from Notepad++ shortcut (under "Advanced"). When I relaunched Notepad++ AHK worked again. Amazing.

2
  • Please, don't add "thank you comment"
    – Toto
    Commented Aug 2, 2022 at 13:24
  • Welcome to Super User! Before answering an old question having an accepted answer (look for green ✓) as well as other answers ensure your answer adds something new or is otherwise helpful in relation to them. Here is a guide on How to Answer. There is also a site tour and a help center. Commented Aug 2, 2022 at 13:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .