Reputation: 802
Im using autohotkey to fix my keyboard that is typing the character 'y' when I type the character 't'. That is , when I press 't' in my keyboard, 'ty' gets typed. Here is the code I came up with. Im new to autohotkey but I am familiar with a few programming languages.
timeout := 50 ;ms
t::
{
SetTimer, ResetMonitoring, % -timeout
monitor := true
}
return
#If monitor
y::
{
SendInput t
return
}
#If
ResetMonitoring:
{
monitor := false
return
}
But the 't' from SendInput never gets typed. So instead of 'ty', now, nothing gets typed when this script is running. I tried putting a message box there instead of SendInput, and it works so I know that the script reaches that line when y is detected after t.
I used this line for MessageBox
MsgBox, % "Your next press was: " . A_ThisHotkey
I receive a message box with message as "Your next press was: y".
What am I doing wrong?
Upvotes: 0
Views: 408
Reputation: 7953
Without having ran your code, I see one issue. y:: Sends t and will therefore trigger t::. To avoid triggering keys from within your code, add $ in front of the key.
$y::
$t::
Upvotes: 1