Background Keystroke counter

Ask gaming related questions (AHK v1.1 and older)
Yukie
Posts: 3
Joined: 20 Apr 2018, 12:52

Background Keystroke counter

Post by Yukie » 29 Sep 2020, 10:00

Hi,

I'm using AHK for a few years for basics things like rebind, automation and such but this time i'm looking for something more specifique and couldn't find an answer myself nor by searching.

I'm looking for a script that would count the number of time i press the "space" key.
It would have to work in background.
(The objective is to know how often i press the "Space" key in a video game)

I've found this :

Code: Select all

Gui, Add, Text, vCount w100, Space pressed 0 times.
Gui, Show

Count := 0

~Space::   ;Default behavior is to block keystroke, ~ allows it to pass through
  Count := Count + 1
  GuiControl,,Count, H pressed %Count% times.
  KeyWait, Space  ;Wait for h to be released
return

GuiClose:
  ExitApp
return
But unfortunately it doesnt work on background.

Any help ? :D

Best regards,
Yukie
Last edited by BoBo on 29 Sep 2020, 10:06, edited 2 times in total.
Reason: Changed [c][/c] to [code][/code]-tags. Moved thread to Gaming section.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Background Keystroke counter

Post by BoBo » 29 Sep 2020, 10:11

Code: Select all

cnt:=0
~Space::ToolTip % cnt++    ; press Space to count
!Space::ExitApp    ; press Alt+Space to exit script & reset the tooltip

Yukie
Posts: 3
Joined: 20 Apr 2018, 12:52

Re: Background Keystroke counter

Post by Yukie » 29 Sep 2020, 10:21

Works, thx.
Not ideal tho since it follows the mouse. (And in a video game, u move the mouse fast, so it creats an angry flying tooltip moving everywhere)

Anyway to make it still work in background BUT showing in a fix place ? Or even only showing in a background GUI.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Background Keystroke counter

Post by BoBo » 29 Sep 2020, 10:25

Well, the easiest thing to sort this out is to check AHK's command reference (for even lazier geeks out there, clicking on a command within the forums code box ... :yawn:) to find things like this: https://www.autohotkey.com/docs/commands/ToolTip.htm

Yukie
Posts: 3
Joined: 20 Apr 2018, 12:52

Re: Background Keystroke counter

Post by Yukie » 29 Sep 2020, 10:30

Yeah sorry... got lazy on this one.

Managed to make it work the way i wanted in a few minutes.
Thanks for the help.

benbrown
Posts: 5
Joined: 05 Jun 2019, 04:25

Re: Background Keystroke counter

Post by benbrown » 23 Dec 2022, 08:24

Managed to make it work the way i wanted in a few minutes
Would you mind sharing your solution?

Post Reply

Return to “Gaming Help (v1)”