Skip to content

Instantly share code, notes, and snippets.

@dy
Last active December 31, 2025 04:20
Show Gist options
  • Select an option

  • Save dy/044c5af2a134f73f24530bcf58838cab to your computer and use it in GitHub Desktop.

Select an option

Save dy/044c5af2a134f73f24530bcf58838cab to your computer and use it in GitHub Desktop.
Teensy jiggler
#include <Keyboard.h>
#include <Mouse.h>
// ===== Advanced Randomization =====
unsigned int minDelay = 700; // More frequent but irregular
unsigned int maxDelay = 15000; // Much wider range
unsigned int minKeyHold = 30;
unsigned int maxKeyHold = 250;
// Movement patterns
const int movementPatterns[4][2] = {
{1,1}, {-1,1}, {1,-1}, {-1,-1} // Diagonal variations
};
void setup() {
Keyboard.begin();
Mouse.begin();
randomSeed(analogRead(0) + micros()); // Double-random seed
}
void loop() {
// Randomized delay with non-linear distribution
delay(pow(random(1, 10), 2.5) * 100);
// === Anti-Pattern Mouse Movements ===
if (random(0, 100) > 15) { // 85% chance
organicMouseMovement();
}
// === Randomized Scrolling ===
if (random(0, 100) > 60) { // 40% chance
irregularScroll();
}
// === Stealth Keystrokes ===
if (random(0, 100) > 70) { // 30% chance
pressCommandTab();
}
// === Organic Movement (90% chance) ===
if (random(0, 100) > 10) {
humanMouseMovement();
}
// === Random Click (20% chance) ===
if (random(0, 100) > 80) {
// naturalClick();
}
// === VS Code-Safe Keystrokes (35% chance) ===
if (random(0, 100) > 65) {
safeKeystroke();
}
}
// ===== Organic Diagonal Mouse Algorithm =====
void organicMouseMovement() {
int pattern = random(0, 4);
int steps = random(3, 12);
int baseSpeed = random(2, 5);
// Vary speed during movement
for (int i = 0; i < steps; i++) {
int variance = random(-1, 2);
int speed = baseSpeed + variance;
Mouse.move(
movementPatterns[pattern][0] * speed,
movementPatterns[pattern][1] * speed,
0
);
// Irregular pauses
if (random(0, 10) > 6) {
delay(random(15, 45));
// Random micro-adjustment
Mouse.move(random(-1, 2), random(-1, 2), 0);
}
delay(random(10, 30));
}
// Post-movement drift
if (random(0, 10) > 3) {
for (int j = 0; j < random(1, 4); j++) {
Mouse.move(random(-2, 3), random(-2, 3), 0);
delay(random(20, 60));
}
}
}
// ===== Irregular Scrolling =====
void irregularScroll() {
int direction = random(0, 2) ? 1 : -1;
int bursts = random(1, 4);
for (int b = 0; b < bursts; b++) {
int steps = random(1, 5);
for (int s = 0; s < steps; s++) {
Mouse.move(0, 0, direction * random(1, 3));
delay(random(15, 40) * (s + 1)); // Increasing delay
}
if (bursts > 1) delay(random(50, 200));
}
}
// ===== Human Mouse Algorithm =====
void humanMouseMovement() {
int moveType = random(0, 5);
int duration = random(3, 15);
switch(moveType) {
case 0: // Slight jitter
for (int i = 0; i < duration; i++) {
Mouse.move(random(-2, 3), random(-2, 3), 0);
delay(random(15, 45));
}
break;
case 1: // Diagonal sweep
{
int dirX = random(0, 2) ? 1 : -1;
int dirY = random(0, 2) ? 1 : -1;
for (int i = 0; i < duration; i++) {
Mouse.move(dirX * random(1, 4), dirY * random(1, 4), 0);
delay(random(20, 60));
if (random(0, 10) > 7) break; // Random early exit
}
}
break;
case 2: // Circular motion
{
int radius = random(5, 20);
int steps = random(5, 20);
for (int i = 0; i < steps; i++) {
float angle = 2 * PI * i / steps;
Mouse.move(radius * cos(angle)/steps, radius * sin(angle)/steps, 0);
delay(random(15, 40));
}
}
break;
case 3: // Micro-adjustments
for (int i = 0; i < random(3, 8); i++) {
Mouse.move(random(-1, 2), random(-1, 2), 0);
delay(random(30, 100));
}
break;
case 4: // Drag-like movement
// Mouse.press(MOUSE_LEFT);
// delay(random(50, 150));
// for (int i = 0; i < random(3, 10); i++) {
// Mouse.move(random(-5, 6), random(-5, 6), 0);
// delay(random(30, 80));
// }
// Mouse.release(MOUSE_LEFT);
break;
}
// Post-movement settling
if (random(0, 10) > 4) {
delay(random(50, 200));
Mouse.move(random(-1, 2), random(-1, 2), 0);
}
}
// ===== Command+Tab with Randomization (Mac App Switcher) =====
void pressCommandTab() {
Keyboard.press(KEY_LEFT_GUI); // Command key on Mac
delay(random(minKeyHold, maxKeyHold));
Keyboard.press(KEY_TAB);
delay(random(20, 80));
Keyboard.release(KEY_TAB);
delay(random(minKeyHold, maxKeyHold));
if (random(0, 10) > 4) { // 50% chance to tab again
Keyboard.press(KEY_TAB);
delay(random(20, 80));
Keyboard.release(KEY_TAB);
delay(random(minKeyHold, maxKeyHold));
}
Keyboard.release(KEY_LEFT_GUI);
}
// ===== Natural Click =====
void naturalClick() {
// Pre-click micro-movement
for (int i = 0; i < random(1, 4); i++) {
Mouse.move(random(-1, 2), random(-1, 2), 0);
delay(random(15, 40));
}
// Press and release with human-like timing
Mouse.press(MOUSE_LEFT);
delay(random(50, 150));
Mouse.release(MOUSE_LEFT);
// Post-click delay variance
delay(random(30, 150));
// Sometimes double-click
if (random(0, 100) > 85) {
delay(random(50, 120));
Mouse.click(MOUSE_LEFT);
}
// Sometimes move after clicking
if (random(0, 100) > 60) {
delay(random(50, 150));
Mouse.move(random(-2, 2), random(-2, 2), 0);
}
}
// ===== VS Code-Safe Keystrokes =====
void safeKeystroke() {
int action = random(0, 6); // 8 different safe actions
switch(action) {
case 0: // ESC
Keyboard.press(KEY_ESC);
delay(random(minKeyHold, maxKeyHold));
Keyboard.release(KEY_ESC);
break;
case 1: // Cmd+Tab (1-3 times)
{
int tabs = random(1, 4);
Keyboard.press(KEY_LEFT_GUI);
delay(random(40, 120));
for (int i = 0; i < tabs; i++) {
Keyboard.press(KEY_TAB);
delay(random(30, 100));
Keyboard.release(KEY_TAB);
delay(random(50, 150));
}
Keyboard.release(KEY_LEFT_GUI);
}
break;
case 2: // Cmd+Up (go to beginning of file)
Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_UP_ARROW);
delay(random(40, 120));
Keyboard.releaseAll();
break;
case 3: // Switch editor tabs (Cmd+Shift+[ or ])
Keyboard.press(KEY_LEFT_GUI);
delay(random(40, 120));
Keyboard.press(KEY_LEFT_SHIFT);
delay(random(40, 120));
Keyboard.press(random(0, 2) ? '[' : ']');
delay(random(40, 120));
Keyboard.releaseAll();
break;
case 4: // Single modifier key
{
byte mod = random(0, 4);
switch(mod) {
case 0: Keyboard.press(KEY_LEFT_CTRL); break;
case 1: Keyboard.press(KEY_LEFT_SHIFT); break;
case 2: Keyboard.press(KEY_LEFT_ALT); break;
case 3: Keyboard.press(KEY_LEFT_GUI); break;
}
delay(random(30, 150));
Keyboard.releaseAll();
}
break;
case 5: // Arrow keys
{
byte arrow = random(0, 4);
switch(arrow) {
case 0: Keyboard.press(KEY_UP_ARROW); break;
case 1: Keyboard.press(KEY_DOWN_ARROW); break;
case 2: Keyboard.press(KEY_LEFT_ARROW); break;
case 3: Keyboard.press(KEY_RIGHT_ARROW); break;
}
delay(random(30, 120));
Keyboard.releaseAll();
}
break;
}
// Post-action delay with randomness
delay(random(100, 300) + random(0, 200));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment