From 00d24222b137b1588a563a1514785397616a1cca Mon Sep 17 00:00:00 2001 From: coolneng Date: Tue, 28 Jul 2020 12:42:19 +0200 Subject: [PATCH] Write script using pynput --- proarbeit.py | 25 ++++++++++++++++++++++++- shell.nix | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/proarbeit.py b/proarbeit.py index 5768829..1b0abc5 100644 --- a/proarbeit.py +++ b/proarbeit.py @@ -1 +1,24 @@ -from pynput.mouse import Listener +from pynput.mouse import Controller +from secrets import randbits +from time import sleep + + +def initialize_mouse(): + mouse = Controller() + return mouse + + +def erratic_movement(mouse): + x, y = mouse.position + mouse.move(x + randbits(2), y + randbits(2)) + sleep(randbits(2)) + + +def main(): + mouse = initialize_mouse() + while True: + erratic_movement(mouse) + + +if __name__ == "__main__": + main() diff --git a/shell.nix b/shell.nix index bf53233..56ce4b1 100644 --- a/shell.nix +++ b/shell.nix @@ -2,4 +2,4 @@ with pkgs; -mkShell { buildInputs = [ python38Packages.pynput ]; } +mkShell { buildInputs = [ python38 python38Packages.pynput ]; }