Skip to content

Instantly share code, notes, and snippets.

@earthbound19
Created October 3, 2013 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save earthbound19/6804990 to your computer and use it in GitHub Desktop.
Save earthbound19/6804990 to your computer and use it in GitHub Desktop.
AutoHotkey script, which provides a shortcut key combination to generate and send random "laughter" strings. You may decide, O user, whether the laughter is evil or not by context. HAHA HAHAHAHA HAHAHAHAhahahahaha HAHAHAHAHAHAHAHAHAhahahahahahahaHAHAHAHAHAHAHAHAHAHAHAHA!
;Hotkey (via AutoHotkey) to send random "laughter" strings via simulated keystrokes. Sample output: hahaha haha HAHAHA HAHAHAhahahahaha HAHAHAHAHAHAHAHAHAHAHAHA hahaha hahaha haha hahahahahahaha ha hahahahahahahahaHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAHAhahahahaha HAHAHAHAHAHAHAHAHAHAHAHAHAHAhahahahahahahahaha HAHAHAHAHAHAHAHAHAHAHAHAHAHAhahahahahahahahahahahaha haha hahaha ha haha HAHAHA HAHAHAha hahahaha haha hahaha HAHAHAHAHAHAHAHA HAHAHAHAHAHAHAHAha!
^+h:: ;CTRL+SHIFT+h
sendRandomLaughter()
return
;GENERAL NOTES: the comments in this repeatedly refer to "1 in x" "dice rolls." The "x" in that, or the highest number on the "die" is configurable in each of the "Random" function calls releated to each comment. For example:
;
; Random, val, 1, 6
;
; -- means "a 1 in 6 dice roll." Also, note that a "dice roll" between 0 and 5 is equivalent to 1 and 6 (because the computer "counts" zero as _one_ of the numbers which it could generate).
sendRandomLaughter()
{
SetKeyDelay, 0
keepLaughing = 1 ;By setting keepLaughing to 1 here, we guarantee that at least one word will be generated and sent, via the "while" loop soon to follow. Near the end of that "while" loop, keepLaughing is randomly assigned a value between 0 and x). Any time that keepLaughing is assigned the value 0, the laughter will stop.
while (keepLaughing != 0) {
strLaughter%A_Index% := "" ;We want the following loop to start its work on a null variable; this line accompishes that, for the variable strLaughter.
stopWord = 2
while (stopWord != 1) { ; . . . after the first "ha," whether the word stops is a 1 in x dice roll, as determined at the end of this control block.
strLaughter = %strLaughter%ha ;Because I set stopWord to 2 before starting this loop, we're guaranteed to get at least one "ha" sequence in this word; and thereafter, whether we *stop* repeatedly appending the string "ha" to that is a 1 in x dice roll:
Random, stopWord, 1, 3
}
Random, whetherCAPS, 1, 4 ;1 in x chance that the following loop will change the completed word to ALL CAPS.
If (whetherCAPS == 1) { ;This code block gratefully horked and adapted from: http://www.autohotkey.com/board/topic/13175-new-caps-lock-functionality/#entry89948
string = %strLaughter%
StringLen, length, string
Loop, %length%
{
StringLeft, char, string, 1
If char Is Lower
StringUpper, char, char
StringTrimLeft, string, string, 1
string = %string%%char%
}
strLaughter = %string%
}
Send %strLaughter% ;Render the completed word, either in ALL CAPS or regular caps.
Random, keepLaughing, 0, 1 ;See notes just before the start of this "while" loop.
Random, whetherConjoin, 1, 5 ;Usually (depending on how you set this "dice roll"), we want to send a space after a word, but sometimes, let's mix it up and *not* do that, which, if more words are generated, will have the effect of slight random alternation between ALL CAPS and standard caps within one word. If no next word is generated (as the following logic will decide), this will be overidden (it won't matter whether we want to conjoin: we won't make any more words).
If (whetherConjoin != 1) && (keepLaughing == 1) {
Send %A_Space% ;If the laughter will continue *and* we've decided *not* to conjoin the next "laugh" (word) with that most recently generated, send a space. Otherwise, this control block will not be run (and no space will be sent).
}
}
Send %A_Space% ;I decide, on behalf of the user, to always end a sent string of a laugh or laughs with a space. Personally I'll want that space more often than not; it means I can repeatedly invoke this hotkey to send repeated long strings of "laughter."
}
@Steii3
Copy link

Steii3 commented Jun 10, 2018

beautiful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment