2

I've been successfully using an AHK script for almost a year which maps Ctrl-C and Alt-E-S-V (an Excel shortcut) to Win-key combinations, and maps Ctrl-Del to Ctrl-Space, Ctrl-- (delete row).

However, occasionally (and more and more frequently), the computer thinks that the Win or Ctrl key is still held down. I've spent a long time looking for a fix and nothing has worked for me, including various script rewrites and uninstalling and reinstalling AHK.

Here's my script:

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;map ctrl-c, ctrl-v, and ctrl-e-s-v (paste values) to win-key combos
#a::Send ^c
#s::Send ^v
#q::Send !e,{s},{v}{Enter}

*CapsLock::Send {Media_Play_Pause}
Return  ;disable CapsLock permanently

;map win-x to ctrl-alt-/ - shortcut to open 'everything.exe', then close it automatically when it's not in focus
#x::
Send ^!/
Sleep, 1000
WinWaitNotActive, ahk_class EVERYTHING
WinClose, ahk_class EVERYTHING
return

;win-z to prt scn
#z::Send {PrintScreen}

;map ctrl-del to select whole line and delete it
~^Del::
Send +{space}
Send ^-
Send {Left}
return

Edit: this person had the same problem as me, though none of the fixes suggested in that thread helped me.

1 Answer 1

4

No telling if this will fix the problem, but you can try this script.

; Always run your script as admin
if not A_IsAdmin
{
   Run *RunAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
SetKeyDelay, 50

;There's a command for disabling CapsLock permanently
SetCapsLockState, AlwaysOff 

return

$#a::^c
$#s::^v
$#z::PrintScreen
$#q::SendEvent, ^!v!v{Enter}
$#x::
    Send ^!/
    Sleep, 1000
    WinWaitNotActive, ahk_class EVERYTHING
    WinClose, ahk_class EVERYTHING
return

$~^Del::SendEvent, +{space}^-{Left}

Tested all the rempas (except win+x) and they seem to be working just fine. I haven't been able to duplicate the modifier problem you're having.

Let me know if this solved hte problem. If not, we can try to adjust fire.

3
  • 2
    Thank you - above and beyond what I was looking for! I've applied your changes and run as admin, and so far the bug isn't re-occurring. Still curious as to what specific change causes the bug, something for a rainy day I guess. Jun 12, 2017 at 12:01
  • 1
    No clue what was causing the bug, but you're definitely not the first person I've seen post that problem. I'm usually over on the AHK subreddit answering questions like this. If this didn't work, next step would've been forcing the up state of whatever keys were acting up. ¯\_(ツ)_/¯ I'm just glad to hear everything is working like you intended. Jun 13, 2017 at 7:42
  • @GroggyOtter – maybe if you can lose a word on which part of the code can possibly make the difference and why.
    – miroxlav
    Feb 23, 2019 at 21:54

You must log in to answer this question.

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