So, I have been having this problem since I started using AHK a month ago. My hotkeys stops working with specific programs, such as Firefox and Figma, for a few moments, and then come back alive again. It's maddening not knowing what is causing this. I've added multiple headers in the hopes that this could stop, but no progress was made.
I structured my file as most important actions first, then app specific actions and global shorcuts, the ones I want to use across the board, on all the windows of Windows. The global shortcuts have the directionals keys, that are activated with an F13 modifier key (in the same location of the ISO key, rewired through SharpKeys), and these are the most essential for me (they emulate WASD and VIM-ish commands, making it so much easier to navigate everywhere), and they stop working after a while and I don't know why!!!
Refreshing, suspending shortcuts, pausing, restarting Explorer, persistent mode, different SendMode, using SC/VK values instead of normal characters, compiling, running AHK and the Script with admin rights. I've tried it all. Nothing seems to fix my problem.
Can you help me debug this script?
Hotkeys stops to work after a while
-
- Posts: 8
- Joined: 30 Jul 2021, 15:12
- Contact:
Hotkeys stops to work after a while
- Attachments
-
- Shortcuts.ahk
- My ahk file with the shorcuts I use across the PC
- (16.92 KiB) Downloaded 70 times
Re: Hotkeys stops to work after a while
Hallo,
I took a quick look at your script.
This is very unusual: Almost each macro ends with Exit instead of Return.
E.g.:Usually one writes:or shorter with implicit Returns:
All the exits shouldn't actually be harmful, but try replacing all the Exits with Returns.
A common cause of non working Hotkeys are sticking modifiers. For unsticking I use:
I took a quick look at your script.
This is very unusual: Almost each macro ends with Exit instead of Return.
E.g.:
Code: Select all
;Windows (janelas) control
;Send window to the other monitor
#!a::
#!h::
Send #+{Left}
Exit
#!d::
#!l::
Send #+{Right}
Exit
Code: Select all
;Windows (janelas) control
;Send window to the other monitor
#!a::
#!h::
Send #+{Left}
Return
#!d::
#!l::
Send #+{Right}
Return
Code: Select all
;Windows (janelas) control
;Send window to the other monitor
#!a::
#!h::Send #+{Left}
#!d::
#!l::Send #+{Right}
A common cause of non working Hotkeys are sticking modifiers. For unsticking I use:
Code: Select all
ModifierUp:
Send, {Alt Up}{Ctrl Up}{Shift Up}
Send, {LCtrl up}{RCtrl up}{LWin up}{RWin up}{LAlt up}{RAlt up}
Send, {LShift up}{RShift up}{Numlock Up}{CapsLock Up}
SetCapsLockState, Off
SetNumLockState, On
SetScrollLockState, Off
Return
Re: Hotkeys stops to work after a while
Edit: I posted before seeing Rohwedder's wise reply!
This is fairly easy to debug: first, disable your antivirus software. Second, pare down the script to the essential #If... directive that applies to your program. Test just that. If it works, expand your script little by little, testing carefully along the way. When it breaks, you will then know exactly why.
Remember that the #If directive applies to everything below it, until the next such directive, and that if there are multiple matches, the first one usually wins; see documentation regarding exceptions.
Note that when your script Exits, it might no longer be running, in which case the hotkeys will not work. Return is most commonly used to end a subroutine. (In your script, Exit is probably OK where you have it.)
Some Web browsers have their own hotkeys or may use keyboard hooks, etc. that could conflict with AHK.
This is fairly easy to debug: first, disable your antivirus software. Second, pare down the script to the essential #If... directive that applies to your program. Test just that. If it works, expand your script little by little, testing carefully along the way. When it breaks, you will then know exactly why.
Remember that the #If directive applies to everything below it, until the next such directive, and that if there are multiple matches, the first one usually wins; see documentation regarding exceptions.
Note that when your script Exits, it might no longer be running, in which case the hotkeys will not work. Return is most commonly used to end a subroutine. (In your script, Exit is probably OK where you have it.)
Some Web browsers have their own hotkeys or may use keyboard hooks, etc. that could conflict with AHK.
-
- Posts: 8
- Joined: 30 Jul 2021, 15:12
- Contact:
Re: Hotkeys stops to work after a while
So, I think my problem is distilled to this quote. How do I circumvent this? Because it makes sense that have shortcuts apps such as Firefox and Figma would conflict with my custom shortcuts, but how do I enforce AHK over these?
Re: Hotkeys stops to work after a while
suspend and unsuspend the script. keep doing this every time the hooks get overridden...
-
- Posts: 8
- Joined: 30 Jul 2021, 15:12
- Contact:
Re: Hotkeys stops to work after a while
get rid of #InstallKeybdHook otherwise Suspend wont touch the hook
Who is online
Users browsing this forum: Google [Bot] and 352 guests