r/AutoHotkey • • 20h ago

Meta / Discussion Shift + Numpad hotkeys - why is it so much agony?!?

5 Upvotes

A question and a rant ๐Ÿคฃ

The question: WHY does Windows behave the way it does regarding Shift and the Numpad? Why does it strip away/suppress/hide the shift modifier? If I have a keyboard with a numpad, I'm most likely also going to have a nice separate set of arrow keys and a bunch of home/end/pgup/pgdown keys. Why on earth would I want to press shift plus the numpad keys to get these actions?!?

Background: Recently learned about box-drawing characters (https://en.wikipedia.org/wiki/Box-drawing_characters) and figured it would be neat to write a script so I can easily enter them using the numpad keys (so 7 is a top-left corner, 9 is a top-right and so on). If you haven't seen the characters before, they are:

โ”Œ โ•ญ โ”ฌ โ•ฎ โ”  โ” โ”ณ โ”“  โ•” โ•ฆ โ•—

โ”œ   โ”ผ   โ”ค  โ”ฃ โ•‹ โ”ซ  โ•  โ•ฌ โ•ฃ

โ”” โ•ฐ โ”ด โ•ฏ โ”˜  โ”— โ”ป โ”›  โ•š โ•ฉ โ•
โ”€ โ”‚ โ•ฑ โ•ฒ โ•ณ  โ” โ”ƒ    โ• โ•‘

โ–‘ โ–’ โ–“ โ–ˆ

(assuming you're viewing this in a font which supports them)

I finally decided on using ctrl, shift, ctrl+shift and ctrl+alt modifier keys. And of course all hell broke loose when I came to handling the shift modifier, thanks to Windows' behavior of stripping the shift modifier away!

Like others have described, the solution was to handle both key names (e.g. NumpadHome and Numpad7) and then actually check the states of the NumLock and Shift keys using GetKeyState(). For example, here's what I have to handle the "7" key with both the ctrl and ctrl+shift modifiers:

<^$NumpadHome::
<^$Numpad7::
{
  if GetKeyState("NumLock","T")
  {
    if GetKeyState("Shift","P")
    {
      Send "โ•”"
    } else {
      Send "โ”Œ"
    }
    } else {
      Send "{LControl}{NumpadHome}"
  }
}

I now have a functioning script which lets me enter all the characters I want, plus I did another script in v1 (for a WinXP machine). This threw up a few more weird quirks which I won't go in to but they took up some time to fix as well ๐Ÿคฃ

All of that faff when a simple <^$Numpad7:: Send"โ”Œ" would've worked if Windows treated shift + numpad like every other modifier!


r/AutoHotkey • • 17h ago

v2 Script Help Having some weird issues with a script

0 Upvotes

I wrote a script for a game (Brawlhalla) to start a custom match and start another when its finished, and to loop until i end it.

The script works on my other older pc running Win10, but for some reason it doesn't work properly on both of my newer machines (two 5060s). On my first 5060 it would bug out after working for a few moments, but now on my primary 5060 it practically doesn't work at all.

Here's the script, Iโ€™ll explain its function;

#Requires AutoHotkey v2.0

F1::
{
Loop
{
Loop(12)
{
Send("C") ;selects character
Sleep(200)
Send("C") ;spams to account for lag
Sleep(200)
Send("C")
Sleep(200)
Send("C")
Sleep(200)
Send("C")
Sleep(200)
Send("C")
Sleep(200)
Send("C")
Sleep(200)
Send("C")
Sleep(16000) ;waits for round start
Send("{Escape}") ;pauses game
Sleep(1000)
Send("W") ;moves up in pause menu
Sleep(1500)
Send("C") ;selects exit game
Sleep(8000) ;waits for delay
Send("C") ;selects rejoin
Sleep(1510000) ;waits for game end
}
Sleep(3600000) ;waits 1 hour for xp cooldown
}
}

F4:: Pause

^F4:: Pause(0)
return

So, this selects the character with some spammed inputs to account for lag and menus, does some stuff pertinent to the game menu, then waits for a 25 minute timer to loop everything all over again, and it repeats this 12 times before taking an hour break due to xp fatigue.

The issue im having now is it will just not register the "Send" commands consistently. Sometimes it registers them, but then once in the game it stops registering inputs. Or most times it doesn't even register the first "Send(C)" or the following ones, or it registers the first one then doesn't register any other code afterwards.

The code itself works, because again this worked flawlessly on my other machine and the code hasn't been touched, but that machine isnt working at the moment for me to use. And the code registers within a notepad, but the inputs for some reason do not translate into this game on both of my Win11 machines but worked on my Win10 machine.

Anyone know whats going on here?