Hacker Typer style application for Windows

4

1

I need to do a bunch of screencasts that demonstrate some programming techniques. I already know what I'm going to type for each of them, and I'd like to minimize all the delays and awkwardness from typos and trying to think what I was supposed to do next.

Is there a software that lets me paste a chunk of text into a buffer and then randomly mash at keys and have my buffer be output into the currently active window one character at a time? Kind of like a native customizable Hacker Typer. Could it be done with some kind of AutoHotkey script or something similar? Suggestions for applications for other platforms are welcome if none exist for the Windows platform.

Kaivosukeltaja

Posted 2013-09-06T20:45:24.283

Reputation: 235

Question was closed 2019-05-30T20:54:31.160

1Just to be clear, you want to have to mash the keyboard, right? You don't just want the chunks of text to instantly appear? – Dane – 2013-09-06T21:01:04.347

Yes, I want one character to appear each time I press any key. When I pause, the output should pause as well. – Kaivosukeltaja – 2013-09-07T05:33:00.330

Are you looking for someone to write the AutoHotKey script for you? – Dane – 2013-09-10T13:54:46.417

Answers

4

Yes, you can use AutoHotKey. I'm sure somebody else could whip this up in no time, but I can at least imagine a possible structure to the script:

  1. Define a Suspend hotkey and start suspended, so that you can use your keyboard when you don't want to be mashing. Alternatively, or in addition, use #IfWinActive to restrict the mashing-keys function to the one window within which you will be doing this.
  2. Read a plain-text file into memory.
  3. Stack multiple hotkey definitions for pretty much every key on the keyboard for your one script action.
  4. Use StringLeft and StringTrimLeft to retrieve a single character from your big variable and delete it from the variable.
  5. Use Send to send the character that you grabbed. You may need to do a little replacement or conditional to handle sending {Enter} and {Tab}, but maybe not.

Here's my script:

#UseHook        ; Avoid loops of the Send command triggering the hotkey again.
AutoTrim, Off   ; Don't auto-trim spaces and tabs from the beginning and end of the sourcetext.
SendMode InputThenPlay  ; Try to prevent the user from corrupting the buffer text.

Suspend, On     ; Start suspended

FileRead, MasherBuffer, magic-button-masher-text.txt
if ErrorLevel
    MasherBuffer = Type or paste text here. You can also drag-and-drop text files here.

Gui, +Resize +MinSize400x200
Gui, Add, Text,, When you are ready, un-suspend this script (Ctrl and `` together will toggle the suspension).`nType any character on the main QWERTY keyboard to send the characters from the buffer instead.
Gui, Add, Edit, vMasherBuffer, %MasherBuffer%
Gui, Show,, Magic Button Masher Buffer
Return

GuiSize:
if ErrorLevel = 1  ; The window has been minimized.  No action needed.
    return
; Otherwise, the window has been resized or maximized. Resize the MasherBuffer control to match.
NewWidth := A_GuiWidth - 20
NewHeight := A_GuiHeight - 50
GuiControl, Move, MasherBuffer, W%NewWidth% H%NewHeight%
return

GuiDropFiles:
Loop, parse, A_GuiEvent, `n
{
    FileRead, AddToBuffer, %A_LoopField%
    MasherBuffer = %MasherBuffer%`n`n%AddToBuffer%
}
GuiControl,, MasherBuffer, %MasherBuffer%
return

^`::Suspend

!`::Gui, Show,, Magic Button Masher Buffer

;   #IfWinActive ahk_class Notepad  ; This limits the button masher to Notepad.
`::
1::
2::
3::
4::
5::
6::
7::
8::
9::
0::
-::
=::
q::
w::
e::
r::
t::
y::
u::
i::
o::
p::
[::
]::
\::
a::
s::
d::
f::
g::
h::
j::
k::
l::
`;::
'::
z::
x::
c::
v::
b::
n::
m::
,::
.::
/::
Space::
GuiControlGet, MasherBuffer
StringLeft, outbound, MasherBuffer, 1
StringTrimLeft, MasherBuffer, MasherBuffer, 1
GuiControl,, MasherBuffer, %MasherBuffer%
if outbound = %A_Space%
    Send {Space}
else if outbound = %A_Tab%
    Send {Tab}
else
    Send {%outbound%}
return

You can make this only work in Notepad by uncommenting the #IfWinActive bit.

I have Ctrl+` defined as a hotkey to suspend the script.

Dane

Posted 2013-09-06T20:45:24.283

Reputation: 1 682

Awesome! That works perfectly, aside from the GUI fixes and some adjustments for my Scandinavian keyboard which I'll probably be able to tackle with the help of the online docs. A thousand thanks for the help! – Kaivosukeltaja – 2013-09-10T19:16:17.457

1Ooh, hey, @Kaivosukeltaja, I updated my script before I saw your comment and acceptance. The updated script has a GUI and a few improvements (especially the "SendMode InputThenPlay"). I have a line in the format of a:: for every key I want to remap. It may be as simple as adding a couple lines with the additional keys on your keyboard. – Dane – 2013-09-10T20:42:16.850

Righteous! I'd upvote again if I could. This is a great demonstration of AutoHotkey's power in the hands of someone who knows what he's doing. – Kaivosukeltaja – 2013-09-11T06:14:07.390

0

I wrote out what Dane described. This should do the trick. It reads in a text file, splits by line, then inputs the characters of that line one by one with a configurable delay.

FileRead, text, C:\test.txt
/* Alternatively:
text =
(ltrim
this is the first sentence.
sentence 2 here.
sentence 3 hello.
sentence 4 reporting in.
)
*/

pos := 1
StringSplit, lines, text, `n

^Space:: ; Ctrl + Space
    line := lines%pos%
    loop, Parse, line
    {
        SendInput % A_Loopfield
        Sleep 100 ; Adjust this for delay between keys
    }
    ++pos
Return

I wasn't too sure on the "mashing" of buttons, so I did not include anything in regards to that.

Elliot DeNolf

Posted 2013-09-06T20:45:24.283

Reputation: 843

This lets the user input one line at a time, which is part-way there. You could do basically the same script, but StringSplit by character (just don't specify a delimiter). I was afraid that might be an extreme number of variables, but it might be fine too. Also, I'm imagining that he wants newlines added as he types. – Dane – 2013-09-10T13:53:08.423