Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This is my attempt at a program that will allow you to type randomly on the keyboard and have pre-determined text entered instead. This can be useful when performing live demonstrations or when you want to impress someone (ha!). Started as a response to a question on SuperUser: http://superuser.com/questions/642041/hacker-typer-style-application…
#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.
SetWorkingDir %A_ScriptDir%
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment