1
votes

I recently broke my keyboard, and wrote some very makeshift, inefficient programs in autohotkey to fix them

here are the outputs of my current laptop keyboard: y = ry h = fh n = {enter}+n 6 = 46

I currently have 4 autohotkey files running for each broken key. Below is the file for h

hadjust.ahk

#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.

while true {

KeyWait, h,D
Sleep 20
Send {BS}
Send {BS}
Send {h}


}

how can I combine the four .ahk files into 1? And is there a better way to do this?

** edit I found a way to do it in one file, but I cant get the n/enter key to work.

Here is the code...

stackadjust.ahk

:?*:fh::h
:?*:hf::h
:?*:ry::y
:?*:yr::y
:?*:46::6
:?*:64::6
:?*:n{Enter}::n
:?*:{Enter}n::n
2

2 Answers

2
votes

For your last two entries you could use the following code:

:*:n`n::n
:*:`nn::n

;Comment: `n = {Enter}
1
votes

If your keyboard sends the double key at roughly the same time, it's possible to make them a double hotkey.

This way you could still type words like "fury"...

y & r::send, {blind}r
$y::send, {blind}y
$+y::send, {blind}Y
4 & 6::send, {blind}6
$4::send, {blind}4
$+4::send, {blind}$
f & h::send, {blind}h
$f::send, {blind}f
$+f::send, {blind}F
n & Enter::send, {blind}n
$n::send, {blind}n
$+n::send, {blind}N
$Enter::
if (A_PriorHotkey = "n") and (A_TimeSincePriorHotkey < 500)
{
  Soundbeep, 500, 200
  return
}
Send, {Enter}
return

Sending "blind" (against the shift, alt and ctrl status) is probably not necessary, but doesn't hurt. Update: As Enter seems to be more stuck, I will remove Enter up to 500ms after the last n. In this case I'm beeping to give a notetice.