Skip to content

Instantly share code, notes, and snippets.

@dustyfresh
Last active April 20, 2016 16:23
Show Gist options
  • Save dustyfresh/2b836ff3a207fc02f50105f5902db2f4 to your computer and use it in GitHub Desktop.
Save dustyfresh/2b836ff3a207fc02f50105f5902db2f4 to your computer and use it in GitHub Desktop.
Run this when you find an unlocked OS X workstation
#!/usr/bin/python
# This is a friendly reminder that you should lock your computer.
#
# Moves mouse cursor to random location and taunts the unsuspecting user
#
#
# Run like ninja:
# python <(curl -s https://gist.githubusercontent.com/dustyfresh/2b836ff3a207fc02f50105f5902db2f4/raw/91354fcb70b63fbd6eebf92da9dcd1608560729e/unlockedws.py) &
#
# <@dustyfresh>
import os
import random
try:
import objc
except:
os.system("pip install objc &>/dev/null")
import objc
class mouse():
def position(self, x, y):
bndl = objc.loadBundle('CoreGraphics', globals(),
'/System/Library/Frameworks/ApplicationServices.framework')
objc.loadBundleFunctions(bndl, globals(),
[('CGWarpMouseCursorPosition', 'v{CGPoint=ff}')])
CGWarpMouseCursorPosition((x, y))
if __name__ == '__main__':
mouse = mouse()
while True:
numx = random.randrange(100, 1000)
numy = random.randrange(100, 1000)
mouse.position(numx, numy)
os.system("/usr/bin/say -r 200 L.O.L. Lock your computer")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment