5

I'd like to get the last key that was pressed by the user. I'm not talking about a hotkey; just a normal keypress.

If possible, I'd also like to have keys that AHK typed using SendInput be included. So if AHK just did SendInput for some keys, and I'm asking for the last key that was pressed, then I'd be given the last key that AHK emitted or the last key that the user typed, depending on who typed last.

I tried A_PriorKey, but it's problematic because when I tried it, it showed one of the keys that triggered the script, rather than the keys that came before the hotkeys, which is what I want.

Is what I want possible?

Ram Rachum
  • 84,019
  • 84
  • 236
  • 374

1 Answers1

2

Have you tried a loop with Input, LastKey, L1 V ?

Robert Ilbrink
  • 7,738
  • 2
  • 22
  • 32
  • 1
    And have that running at all times? Sounds kinda wasteful, isn't it? – Ram Rachum May 30 '13 at 15:35
  • The loop will be waiting (and not looping) most of the time, only when you press a key will the (single line) loop be triggered. This should not be a problem for AutoHotKey or the resources on your system. – Robert Ilbrink May 30 '13 at 21:03
  • Anything before the FIRST Return in the script will be executed on startup. Wow, where did your comment go.... – Robert Ilbrink May 31 '13 at 18:01