Hotkeys stops to work after a while

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
edu-hilario
Posts: 8
Joined: 30 Jul 2021, 15:12
Contact:

Hotkeys stops to work after a while

24 Aug 2021, 10:04

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?
Attachments
Shortcuts.ahk
My ahk file with the shorcuts I use across the PC
(16.92 KiB) Downloaded 71 times
Rohwedder
Posts: 7771
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Hotkeys stops to work after a while

24 Aug 2021, 11:24

Hallo,
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
Usually one writes:

Code: Select all

;Windows (janelas) control
;Send window to the other monitor
#!a::
#!h::
Send #+{Left}
Return
#!d::
#!l::
Send #+{Right}
Return
or shorter with implicit Returns:

Code: Select all

;Windows (janelas) control
;Send window to the other monitor
#!a::
#!h::Send #+{Left}
#!d::
#!l::Send #+{Right}
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:

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
User avatar
mikeyww
Posts: 27366
Joined: 09 Sep 2014, 18:38

Re: Hotkeys stops to work after a while

24 Aug 2021, 11:33

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.
edu-hilario
Posts: 8
Joined: 30 Jul 2021, 15:12
Contact:

Re: Hotkeys stops to work after a while

26 Aug 2021, 11:29

mikeyww wrote:
24 Aug 2021, 11:33
Some Web browsers have their own hotkeys or may use keyboard hooks, etc. that could conflict with AHK.
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?
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Hotkeys stops to work after a while

26 Aug 2021, 11:43

suspend and unsuspend the script. keep doing this every time the hooks get overridden...
edu-hilario
Posts: 8
Joined: 30 Jul 2021, 15:12
Contact:

Re: Hotkeys stops to work after a while

26 Aug 2021, 11:44

swagfag wrote:
26 Aug 2021, 11:43
suspend and unsuspend the script. keep doing this every time the hooks get overridden...
No, you're not understanding: I've tried it all.

This is what is maddening, refreshing the script doens't solve the problem.
swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Hotkeys stops to work after a while

26 Aug 2021, 12:10

get rid of #InstallKeybdHook otherwise Suspend wont touch the hook

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Rohwedder and 373 guests