Keystroke recorder Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Oakenlix
Posts: 5
Joined: 13 May 2018, 04:29

Keystroke recorder

04 Jun 2018, 07:22

Hello!

I just need some help with a simple key-recorder that would allow me to reproduce the same keystrokes with the same timing.

This is what I came up with so far:
#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.
#MaxHotkeysPerInterval 100
Process, Priority,, High

F11::
SoundBeep
FileDelete, keylog.txt
Reload
return

~LAlt::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {LAlt down}`n, keylog.txt
KeyWait, LAlt
FileAppend, sleep %A_TimeSinceThisHotkey%`n, keylog.txt
FileAppend, Sendinput {LAlt up}`n, keylog.txt
return

~vk41 down::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk41 down}`n, keylog.txt
KeyWait, vk41
return

~vk41 up::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk41 up}`n, keylog.txt
return

~vk44 down::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk44 down}`n, keylog.txt
KeyWait, vk44
return

~vk44 up::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk44 up}`n, keylog.txt
return

~vk53 down::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk53 down}`n, keylog.txt
KeyWait, vk53
return

~vk53 up::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk53 up}`n, keylog.txt
return

~vk57 down::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk57 down}`n, keylog.txt
KeyWait, vk57
return

~vk57 up::
FileAppend, sleep %A_TimeSincePriorHotkey%`n, keylog.txt
FileAppend, Sendinput {vk57 up}`n, keylog.txt
return
So then I copypaste the log into my script and bind it to a hotkey to repeat the same actions.

The problem is that there seems to be some sort of delay with the recording, which in result is not very accurate, especially if the keystrokes are done fast enough.
Here's an example:
Image

So is there a way to make it work more reliably, without skipping any keystrokes so that it would accurately record everything?

Thanks in advance!
Oakenlix
Posts: 5
Joined: 13 May 2018, 04:29

Re: Keystroke recorder

04 Jun 2018, 11:27

I thought the issue could be that Fileappend can't write the strings into a file quickly enough, but I just tried doing it by adding strings to a variable and then appending the whole sequence in a file.
Like that:

~LAlt::
MY_SEQ := MY_SEQ . "sleep" A_Space A_TimeSincePriorHotkey "`n"
MY_SEQ := MY_SEQ . "Sendinput {LAlt down}`n"
KeyWait, LAlt
MY_SEQ := MY_SEQ . "sleep" A_Space A_TimeSinceThisHotkey "`n"
MY_SEQ := MY_SEQ . "Sendinput {LAlt up}`n"
return

~vk41 down::
MY_SEQ := MY_SEQ . "sleep" A_Space A_TimeSincePriorHotkey "`n"
MY_SEQ := MY_SEQ . "Sendinput {vk41 down}`n"
KeyWait, vk41
return

But the result is the same, still skips some keystrokes.
geek
Posts: 1052
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: Keystroke recorder  Topic is solved

04 Jun 2018, 18:10

AutoHotkey is only accurate to 15ms at best, which is a whole frame at 60fps. That being said, there are a number of tools available to help
you record and play back your actions. As far as I remember, Pulover's Macro Creator offers record and playback, but I haven't used it myself.

One tool I have used, though a very long time ago, is the AutoScriptWriter that used to ship with AutoHotkey v1.0.
You can still grab a copy if you download a zip of the last version here https://autohotkey.com/download/1.0/.

Once you have the script writer open, click the red "Record" button on the top left to start recording your actions, then hit "Stop" when you're done to finish recording.
I'm not sure how well this will work, if it all, when you're in a full-screen application though.

Image
Oakenlix
Posts: 5
Joined: 13 May 2018, 04:29

Re: Keystroke recorder

05 Jun 2018, 01:39

GeekDude wrote:AutoHotkey is only accurate to 15ms at best, which is a whole frame at 60fps. That being said, there are a number of tools available to help
you record and play back your actions. As far as I remember, Pulover's Macro Creator offers record and playback, but I haven't used it myself.

One tool I have used, though a very long time ago, is the AutoScriptWriter that used to ship with AutoHotkey v1.0.
You can still grab a copy if you download a zip of the last version here https://autohotkey.com/download/1.0/.

Once you have the script writer open, click the red "Record" button on the top left to start recording your actions, then hit "Stop" when you're done to finish recording.
I'm not sure how well this will work, if it all, when you're in a full-screen application though.
Thank you sir!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mankvl, OrangeCat, sanmaodo, zerox and 294 guests