示例#1
0
#Author: Krystal Kwan
#Date: 11/23/20
#Description: Autoclicker for my Zombie Experience Farm in Minecraft

import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode

delay = 1
button = Button.left
start_stop_key = KeyCode(char='j')
exit_key = KeyCode(char='k')


class ClickMouse(threading.Thread):
    def __init__(self, delay, button):
        super(ClickMouse, self).__init__()
        self.delay = delay
        self.button = button
        self.running = False
        self.program_running = True

    def start_clicking(self):
        self.running = True

    def stop_clicking(self):
        self.running = False

    def exit(self):
        self.stop_clicking()
示例#2
0
        print(msg)


def bp(i):
    """ Color positions, based on 'black' """
    return 1015 + 30 * i


combination_to_function = {
    # Create a mapping of keys to function (use frozenset
    # as sets/lists are not hashable - so they can't be
    # used as keys)

    # INK COLORS
    # based on 'bp', ie, the position of black color
    frozenset([KeyCode(vk=114)]): [  # R
        single_menu, [bp(6), 'ink_red']
    ],
    frozenset([KeyCode(vk=103)]): [  # G
        single_menu, [bp(1), 'ink_green']
    ],
    frozenset([KeyCode(vk=98)]): [  # B
        single_menu, [bp(4), 'ink_blue']
    ],

    frozenset([KeyCode(vk=107)]): [  # K
        single_menu, [bp(0), 'ink_black']
    ],
    frozenset([KeyCode(vk=108)]): [  # L
        single_menu, [bp(5), 'ink_grey']
    ],
示例#3
0
 def is_key_down(self, key: KeyType) -> bool:
     key = key if isinstance(key, KeyCode) or isinstance(key, Key) else KeyCode(char=key)
     return key in self._pressed_keys
示例#4
0
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode
import sys
import ui

print("At this point!1")
delay = 0.5
button = Button.right
start_stop_key = KeyCode(char='z')
exit_key = KeyCode(char='x')


class ClickMouse(threading.Thread):
    def __init__(self, delay, button):
        super(ClickMouse, self).__init__()
        self.delay = delay
        self.button = button
        self.running = False
        self.program_running = True

    def start_clicking(self):
        self.running = True

    def stop_clicking(self):
        self.running = False

    def exit(self):
        self.stop_clicking()
        self.program_running = False
示例#5
0
from pynput.keyboard import Controller, Key, KeyCode, Listener
import json
from tkinter import *
import time

#path to the json file storing the clipboard data:
JSON_PATH = './sample.json'

#max no of entries at any time in the clipboard(JSON_PATH):
MAX_ENTRIES = 10

# max no of characters that will appear in a single line of the dropdown menu
MAX_TEXT_LEN = 20

# The key combination to check::
PASTE_COMBINATIONS = [{Key.ctrl, Key.alt, KeyCode(char='v')},
                      {Key.ctrl_l, Key.alt_l,
                       KeyCode(char='v')},
                      {Key.ctrl_l, Key.alt_r,
                       KeyCode(char='v')},
                      {Key.ctrl_r, Key.alt_l,
                       KeyCode(char='v')},
                      {Key.ctrl_r, Key.alt_r,
                       KeyCode(char='v')}]

COPY_COMBINATIONS = [{Key.ctrl, KeyCode(char='c')},
                     {Key.ctrl_l, Key.alt_l,
                      KeyCode(char='c')},
                     {Key.ctrl_l, Key.alt_r,
                      KeyCode(char='c')},
                     {Key.ctrl_r, Key.alt_l,
示例#6
0
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode

delay = 0.01
button = Button.right
start_stop_key = KeyCode(char='f')
exit_key = KeyCode(char='f')


class ClickMouse(threading.Thread):
    def __init__(self, delay, button):
        super(ClickMouse, self).__init__()
        self.delay = delay
        self.button = button
        self.running = False
        self.program_running = True

    def start_clicking(self):
        self.running = True

    def stop_clicking(self):
        self.running = False

    def exit(self):
        self.stop_clicking()
        self.program_running = False

    def run(self):
        while self.program_running:
    def on_press(self, key):
        # publishing is need for refinement node
        if key == KeyCode(char='q'):
            self.keyboard.key.data = 'q'
        elif key == KeyCode(char='a'):
            self.keyboard.key.data = 'a'

        elif key == KeyCode(char='w'):
            self.keyboard.key.data = 'w'
        elif key == KeyCode(char='s'):
            self.keyboard.key.data = 's'

        elif key == KeyCode(char='e'):
            self.keyboard.key.data = 'e'
        elif key == KeyCode(char='d'):
            self.keyboard.key.data = 'd'
        elif key == KeyCode(char='r'):
            self.keyboard.key.data = 'r'
        elif key == KeyCode(char='f'):
            self.keyboard.key.data = 'f'
        elif key == KeyCode(char='t'):
            self.keyboard.key.data = 't'
        elif key == KeyCode(char='g'):
            self.keyboard.key.data = 'g'
        elif key == KeyCode(char='y'):
            self.keyboard.key.data = 'y'
        elif key == KeyCode(char='h'):
            self.keyboard.key.data = 'h'
        elif key == Key.space:
            self.keyboard.key.data = 'space'
        elif key == Key.enter:
            self.keyboard.key.data = 'enter'
示例#8
0
import time
from pynput.mouse import Controller
from pynput.keyboard import Listener, Key, KeyCode
 
store = set()
 
HOT_KEYS = {
    'print_hello': set([ Key.alt_l, KeyCode(char='1')] )
}
 
def print_hello():
   while(True):
    print("Current position: " + str(Controller().position))
    time.sleep(0.1)
 
def handleKeyPress( key ):
    store.add( key )
 
    for action, trigger in HOT_KEYS.items():
        CHECK = all([ True if triggerKey in store else False for triggerKey in trigger ])
 
        if CHECK:
            try:
                func = eval( action )
                if callable( func ):
                   func()
            except NameError as err:
                print( err )
 
def handleKeyRelease( key ):
    if key in store:
示例#9
0
 def __init__(self, content=""):
     self.content = content
     self.start_stop_key = KeyCode(char='s')
     self.exit_key = KeyCode(char='e')
示例#10
0
import time
import threading
from pynput.mouse import Button, Controller
from pynput.keyboard import Listener, KeyCode


delay = 0.08
button = Button.left
start_stop_key = KeyCode(char='o')
exit_key = KeyCode(char='p')


class ClickMouse(threading.Thread):
    def __init__(self, delay, button):
        super(ClickMouse, self).__init__()
        self.delay = delay
        self.button = button
        self.running = False
        self.program_running = True

    def start_clicking(self):
        self.running = True

    def stop_clicking(self):
        self.running = False

    def exit(self):
        self.stop_clicking()
        self.program_running = False

    def run(self):
示例#11
0

def function_1():
    """ One of your functions to be executed by a combination """
    print('Executed function_1')


def function_2():
    """ Another one of your functions to be executed by a combination """
    print('Executed function_2')


# Create a mapping of keys to function (use frozenset as sets/lists are not hashable - so they can't be used as keys)
# Note the missing `()` after function_1 and function_2 as want to pass the function, not the return value of the function
combination_to_function = {
    frozenset([Key.shift, KeyCode(vk=65)]): function_1,  # shift + a
    frozenset([Key.shift, KeyCode(vk=66)]): function_2,  # shift + b
    frozenset([Key.alt_l, KeyCode(vk=71)]): function_2,  # left alt + g
}


# The currently pressed keys (initially empty)
pressed_vks = set()


def get_vk(key):
    """
    Get the virtual key code from a key.
    These are used so case/shift modifications are ignored.
    """
    return key.vk if hasattr(key, 'vk') else key.value.vk
示例#12
0
from pynput.keyboard import Key, Listener, KeyCode
import win32api

MY_HOTKEY = [{
    "function1": {Key.ctrl_l, Key.alt_l,
                  KeyCode(char="c")}
}, {
    "function2": {Key.shift, Key.ctrl_l,
                  KeyCode(char="n")}
}, {
    "function3": {Key.alt_l, Key.ctrl_l,
                  KeyCode(char="g")}
}]


def function1():
    print("function1 called")
    win32api.WinExec("calc.exe")


def function2():
    print("function2 called")
    win32api.WinExec("notepad.exe")


def function3():
    print("function3 called")
    win32api.WinExec(
        "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")

示例#13
0
def on_press(key):
    global key_already_pressed

    if not key_already_pressed:
        key_already_pressed = True
    else:
        return

    frequency = ''
    if key == Key.esc:
        # Stop listener
        return False
    elif key == Key.f1:
        frequency = b"0\n"
    elif key == Key.f2:
        frequency = b"31\n"
    elif key == Key.f3:
        frequency = b"33\n"
    elif key == Key.f4:
        frequency = b"35\n"
    elif key == Key.f5:
        frequency = b"37\n"
    elif key == Key.f6:
        frequency = b"39\n"
    elif key == Key.f7:
        frequency = b"41\n"
    elif key == Key.f8:
        frequency = b"44\n"
    elif key == Key.f9:
        frequency = b"46\n"
    elif key == Key.f10:
        frequency = b"49\n"
    elif key == Key.f11:
        frequency = b"52\n"
    elif key == Key.f12:
        frequency = b"55\n"
    elif key == Key.print_screen:
        frequency = b"8\n"
    elif key == Key.scroll_lock:
        frequency = b'62\n'
    elif key == Key.pause:
        frequency = b'65\n'
    elif key == KeyCode(char='`'):
        frequency = b'69\n'
    elif key == KeyCode(char='1'):
        frequency = b'73\n'
    elif key == KeyCode(char='2'):
        frequency = b'78\n'
    elif key == KeyCode(char='3'):
        frequency = b'82\n'
    elif key == KeyCode(char='4'):
        frequency = b'87\n'
    elif key == KeyCode(char='5'):
        frequency = b'93\n'
    elif key == KeyCode(char='6'):
        frequency = b'98\n'
    elif key == KeyCode(char='7'):
        frequency = b'104\n'
    elif key == KeyCode(char='8'):
        frequency = b'110\n'
    elif key == KeyCode(char='9'):
        frequency = b'117\n'
    elif key == KeyCode(char='0'):
        frequency = b'123\n'
    elif key == KeyCode(char='-'):
        frequency = b'131\n'
    elif key == key == KeyCode(char='='):
        frequency = b'139\n'
    elif key == Key.backspace:
        frequency = b'147\n'
    elif key == Key.insert:
        frequency = b'156\n'
    elif key == Key.home:
        frequency = b'165\n'
    elif key == Key.page_up:
        frequency = b'175\n'
    elif key == Key.tab:
        frequency = b'185\n'
    elif key == KeyCode(char='q'):
        frequency = b'196\n'
    elif key == KeyCode(char='w'):
        frequency = b'208\n'
    elif key == KeyCode(char='e'):
        frequency = b'220\n'
    elif key == KeyCode(char='r'):
        frequency = b'233\n'
    elif key == KeyCode(char='t'):
        frequency = b'247\n'
    elif key == KeyCode(char='y'):
        frequency = b'262\n'
    elif key == KeyCode(char='u'):
        frequency = b'277\n'
    elif key == KeyCode(char='i'):
        frequency = b'294\n'
    elif key == KeyCode(char='o'):
        frequency = b'311\n'
    elif key == KeyCode(char='p'):
        frequency = b'330\n'
    elif key == KeyCode(char='['):
        frequency = b'349\n'
    elif key == KeyCode(char=']'):
        frequency = b'370\n'
    elif key == Key.enter:
        frequency = b'392\n'
    elif key == Key.delete:
        frequency = b'415\n'
    elif key == Key.end:
        frequency = b'440\n'
    elif key == Key.page_down:
        frequency = b'466\n'
    elif key == KeyCode(char='+'):
        frequency = b'494\n'
    elif key == Key.caps_lock:
        frequency = b'523\n'
    elif key == KeyCode(char='a'):
        frequency = b'554\n'
    elif key == KeyCode(char='s'):
        frequency = b'587\n'
    elif key == KeyCode(char='d'):
        frequency = b'622\n'
    elif key == KeyCode(char='f'):
        frequency = b'659\n'
    elif key == KeyCode(char='g'):
        frequency = b'698\n'
    elif key == KeyCode(char='h'):
        frequency = b'740\n'
    elif key == KeyCode(char='j'):
        frequency = b'784\n'
    elif key == KeyCode(char='k'):
        frequency = b'831\n'
    elif key == KeyCode(char='l'):
        frequency = b'880\n'
    elif key == KeyCode(char=';'):
        frequency = b'932\n'
    elif key == KeyCode(char="'"):
        frequency = b'988\n'
    elif key == KeyCode(char='\\'):
        frequency = b'1047\n'
    elif key == Key.shift_l:
        frequency = b'1109\n'
    elif key == KeyCode(char='z'):
        frequency = b'1175\n'
    elif key == KeyCode(char='x'):
        frequency = b'1245\n'
    elif key == KeyCode(char='c'):
        frequency = b'1319\n'
    elif key == KeyCode(char='v'):
        frequency = b'1397\n'
    elif key == KeyCode(char='b'):
        frequency = b'1480\n'
    elif key == KeyCode(char='n'):
        frequency = b'1568\n'
    elif key == KeyCode(char='m'):
        frequency = b'1661\n'
    elif key == KeyCode(char=','):
        frequency = b'1760\n'
    elif key == KeyCode(char='.'):
        frequency = b'1865\n'
    elif key == KeyCode(char='/'):
        frequency = b'1976\n'
    elif key == Key.shift_r:
        frequency = b'2093\n'
    elif key == Key.ctrl_l:
        frequency = b'2217\n'
    elif key == Key.cmd_l:
        frequency = b'2349\n'
    elif key == Key.alt_l:
        frequency = b'2489\n'
    elif key == Key.space:
        frequency = b'2637\n'
    elif key == Key.alt_r:
        frequency = b'2794\n'
    elif key == Key.cmd_r:
        frequency = b'2960\n'
    elif key == Key.menu:
        frequency = b'3136\n'
    elif key == Key.ctrl_r:
        frequency = b'3322\n'
    elif key == Key.up:
        frequency = b'3520\n'
    elif key == Key.left:
        frequency = b'3729\n'
    elif key == Key.down:
        frequency = b'3951\n'
    elif key == Key.right:
        frequency = b'4186\n'
    # elif key.char == *: frequency = b'4435\n'
    # elif key.char == *: frequency = b'4699\n'
    # elif key.char == *: frequency = b'4978\n'
    try:
        arduino_serial.write(frequency)
    except SerialException:
        return False
    def on_release(self, key):
        if key == KeyCode(char='q'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='a'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='d'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='s'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='w'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='e'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='r'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='f'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='t'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='g'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='y'):
            self.keyboard.key.data = ''
        elif key == KeyCode(char='h'):
            self.keyboard.key.data = ''
        elif key == Key.space:
            self.keyboard.key.data = 'space_released'
        elif key == Key.enter:
            self.keyboard.key.data = ''

        elif key == Key.ctrl_r:
            # kill node when esc is pressed
            os.system('kill %d' % os.getpid())
            raise pynput.keyboard.Listener.StopException
    ctypes.windll.user32.MessageBoxW(
        0,
        "First of all don't use Enter to close this window. Left Shift + H = will open this windows again. If you have any problem with the program contact me via: instagram.com/berat.cmn or bit.ly/BeratCimen. ",
        "Berat Cimen - Fake Hotkeys Usage ", 0)


def function_exit():
    print('Executed function_exit')
    ctypes.windll.user32.MessageBoxW(0, "HIT OKAY AND PROGRAM WILL CLOSE.",
                                     "EXIT", 0)
    sys.exit()


# Map of the keys , you can add more with your own combinations.
combination_to_function = {
    frozenset([Key.shift, KeyCode(char='a')]):
    function_1,  # No `()` after function_1 because we want to pass the function, not the value of the function
    frozenset([Key.shift, KeyCode(char='A')]): function_1,
    frozenset([Key.shift, KeyCode(char='b')]): function_2,
    frozenset([Key.shift, KeyCode(char='B')]): function_2,
    frozenset([Key.shift, KeyCode(char='c')]): function_3,
    frozenset([Key.shift, KeyCode(char='C')]): function_3,
    frozenset([Key.shift, KeyCode(char='d')]): function_4,
    frozenset([Key.shift, KeyCode(char='D')]): function_4,
    frozenset([Key.shift, KeyCode(char='h')]): function_help,
    frozenset([Key.shift, KeyCode(char='H')]): function_help,
    frozenset([Key.shift, KeyCode(char='z')]): function_exit,
    frozenset([Key.shift, KeyCode(char='Z')]): function_exit,
}

current_keys = set()
示例#16
0
# 나만의 단축키 만들기

from pynput.keyboard import Key, Listener, KeyCode
import win32api

#딕셔너리 {Key1:Value1, Key2:Value2, Key3:Value3, ...}
MY_HOT_KEYS = [{"function1": {Key.ctrl_l, Key.alt_l, KeyCode(char="p")}}]

#현재 누르고 있는 키보드를 저장하기 위한 집합
current_keys = set()  #집합으로 표시하면 중복이 사라진다.


def function1():  #계산기 프로그램 실행
    print("함수 1 호출")
    win32api.WinExec("calc.exe")


def key_pressed(key):
    print("Pressed {}".format(key))
    for data in MY_HOT_KEYS:
        FUNCTION = list(data.keys())[0]  #function1
        KEYS = list(
            data.values())[0]  #{Key.ctrl_l, Key.alt_l, KeyCode(char="p")}

        if key in KEYS:
            current_keys.add(key)

            if all(k in current_keys for k in KEYS):
                # checker = True
                # for k  in KEYS :
                #     if k not in current_key : #모든 키가 눌리지 않았다면,
示例#17
0
    "██████╔╝░╚████╔╝░░░░███████║██║░░░██║░░░██║░░░██║░░██║██║░░╚═╝██║░░░░░██║██║░░╚═╝█████═╝░█████╗░░██████╔╝"
)
print(
    "██╔═══╝░░░╚██╔╝░░░░░██╔══██║██║░░░██║░░░██║░░░██║░░██║██║░░██╗██║░░░░░██║██║░░██╗██╔═██╗░██╔══╝░░██╔══██╗"
)
print(
    "██║░░░░░░░░██║░░░██╗██║░░██║╚██████╔╝░░░██║░░░╚█████╔╝╚█████╔╝███████╗██║╚█████╔╝██║░╚██╗███████╗██║░░██║"
)
print(
    "╚═╝░░░░░░░░╚═╝░░░╚═╝╚═╝░░╚═╝░╚═════╝░░░░╚═╝░░░░╚════╝░░╚════╝░╚══════╝╚═╝░╚════╝░╚═╝░░╚═╝╚══════╝╚═╝░░╚═╝"
)
print("")

delay = float(input("Set delay (ms): "))
button = Button.left
start_stop_key = KeyCode(char='s')
exit_key = KeyCode(char='e')


class ClickMouse(threading.Thread):
    def __init__(self, delay, button):
        super(ClickMouse, self).__init__()
        self.delay = delay
        self.button = button
        self.running = False
        self.program_running = True

    def start_clicking(self):
        self.running = True

    def stop_clicking(self):
示例#18
0
from pynput import keyboard, mouse
from pynput.keyboard import Key, KeyCode
from photkey_script_funcs import *
import ctypes

ctypes.windll.kernel32.SetConsoleTitleW("Photekey_script")  # change cmd name


def test():
    print("test")


current_keys = set()

hotkeys_to_funcs = {  # list of hotkey and its particular function
    frozenset([KeyCode(char="`"), KeyCode(char="x")]):
    [delete_key_once, close_current_window],
    frozenset([KeyCode(char="`"), KeyCode(char="p")]):
    [delete_key_once, pycharm.open],
    frozenset([KeyCode(char="`"), KeyCode(char="g")]): [select_and_search],
    frozenset([KeyCode(char="`"), KeyCode(char="a")]):
    [delete_key_once, anki.open],
    frozenset([KeyCode(char="`"), KeyCode(char="v")]):
    [delete_key_once, vscode.open],
    frozenset([KeyCode(char="`"), KeyCode(char="n")]):
    [delete_key_once, netflix.open],
    frozenset([KeyCode(char="`"), KeyCode(char="c")]):
    [delete_key_once, chrome.open],
    frozenset([KeyCode(char="`"), KeyCode(char="o")]):
    [delete_key_once, teams.open],
    frozenset([KeyCode(char="`"), KeyCode(char="k")]):
示例#19
0
        'some packages are required, install them doing: `pip3 install --user termcolor SpeechRecognition PyAudio Pynput` to run this script.\nIf you are on linux do: `sudo apt-get install flac portaudio19-dev python-all-dev python3-all-dev && sudo pip3 install Pynput pyaudio`'
    )

from . import voice_commands

###### VARS ######
version = "Version 0.6.8"
title = "Cozmo-Voice-Commands (CvC) - " + version
author = " - Riccardo Sallusti (http://riccardosallusti.it)"
ja_author = "Erik McGuire (http://erikmcguire.github.io)"
log = False
wait_for_shift = True
lang = None
lang_data = None
mx = -1
combinations = [{Key.ctrl_l, KeyCode(char='c')},
                {Key.ctrl_r, KeyCode(char='c')}]
current = set()
commands_activate = [
    "コズモ", "コスモ", "コスモス", "ロボット", "cozmo", "robot", "cosmo", "cosimo", "cosma",
    "cosima", "kosmos", "cosmos", "cosmic", "osmo", "kosovo", "peau", "kosmo",
    "kozmo", "gizmo"
]
vc = None
languages = []


##### MAIN ######
def main():
    parse_arguments()
    clearScreen = os.system('cls' if os.name == 'nt' else 'clear')
示例#20
0
    def on_press(self, key):
        if key == KeyCode(char = 'q'):
            self.keyboard.key.data = 'q'
        elif key == KeyCode(char = 'a'):
            self.keyboard.key.data = 'a' 

        elif key == KeyCode(char = 'w'):
            self.keyboard.key.data = 'w'     
        elif key == KeyCode(char = 's'):
            self.keyboard.key.data = 's'  

        elif key == KeyCode(char = 'e'):
            self.keyboard.key.data = 'e'     
        elif key == KeyCode(char = 'd'):
            self.keyboard.key.data = 'd'     
        elif key == KeyCode(char = 'r'):
            self.keyboard.key.data = 'r'     
        elif key == KeyCode(char = 'f'):
            self.keyboard.key.data = 'f'     
        elif key == KeyCode(char = 't'):
            self.keyboard.key.data = 't'     
        elif key == KeyCode(char = 'g'):
            self.keyboard.key.data = 'g'     
        elif key == KeyCode(char = 'y'):
            self.keyboard.key.data = 'y'     
        elif key == KeyCode(char = 'h'):
            self.keyboard.key.data = 'h'   
        elif key == Key.space:
            self.keyboard.key.data = 'space'
        elif key == Key.enter:
            self.keyboard.key.data = 'enter'
        elif key == Key.left:
            self.keyboard.key.data = 'left'
        elif key == Key.right:
            self.keyboard.key.data = 'right'