class Handler(object):
    def __init__(self):
        self.d = Controller()

    def keycode(self, name, is_dead):
        """Resolves a key description to a value that can be passed to
        :meth:`pynput.keyboard.Controller.press` and
        :meth:`~pynput.keyboard.Controller.release`.

        :param str name: The name of the key. This should typically be the
            actual character requested. If it starts with ``'<'`` and ends with
            ``'>'``, the key value is looked up in
            :class:`pynput.keyboard.Key`, otherwise it is passed straight to
            :meth:`pynput.keyboard.Controller.press`.

        :return: a key value
        """
        if is_dead:
            return KeyCode.from_dead(name)
        elif name[0] == '<' and name[-1] == '>':
            return Key[name[1:-1]]
        else:
            return name

    def down(self, name, is_dead=False):
        """Triggers a key down event.

        :param str name: The name of the key. This is passed to
            :meth:`keycode`.

        :param bool is_dead: Whether a dead key press is requested. In that
            case, ``name`` must be a unicode character with a corresponding
            combining codepoint, and the key will be combined with the next
            character typed.
        """
        self.d.press(self.keycode(name, is_dead))

    def up(self, name, is_dead=False):
        """Triggers a key up event.

        :param str name: The name of the key. This is passed to
            :meth:`keycode`.

        :param bool is_dead: Whether a dead key press is requested. In that
            case, ``name`` must be a unicode character with a corresponding
            combining codepoint, and the key will be combined with the next
            character typed.
        """
        self.d.release(self.keycode(name, is_dead))
Beispiel #2
0
    def done_pressed(self):
        self.CRNs = [
            self.e1.get(), self.e2.get(), self.e3.get(), self.e4.get(), self.e5.get(),
            self.e6.get(), self.e7.get(), self.e8.get(), self.e9.get(), self.e10.get()
        ]

        if not self.listener_initialized:
            self.keyboard = Controller()

            listener = Listener(on_release=self.on_release, on_press=None)
            listener.start()

            self.listener_initialized = True
Beispiel #3
0
 def init_phrase_handlers(self):
     self.notifier.clear()
     phrases = self.db.all()
     keyboard = Controller()
     for phrase in phrases:
         self.notifier.add(PhraseHandler(phrase.get('key'), self.db, keyboard))
Beispiel #4
0
def describe(transcribedSongFile, song, waitPeriod=3):
    startTime = time.time()
    if not os.path.exists('transcribedSongs'):
        print(
            "Transcribed songs do not exist yet. Run transcribe before running describe"
        )
        exit(0)

    if not os.path.isfile(transcribedSongFile):
        print("[ERROR] Transcribed file does not exist")
        exit(0)

    keyboard = Controller()
    print("Describing song  " + transcribedSongFile)
    transcribedSong = open(transcribedSongFile)
    words = []
    times = []
    for line in transcribedSong:
        splitLine = line.split(' ')
        words.append(splitLine[0])
        times.append(float(splitLine[2][:len(splitLine[2]) - 1]))

    timeDifferentials = [times[0]]
    for i in range(1, len(times)):
        differential = times[i] - times[i - 1]
        timeDifferentials.append(differential)

    time.sleep(waitPeriod)
    playsound(song, 0)
    for i in range(0, len(words)):
        time.sleep(timeDifferentials[i])
        keyboard.press(Key.enter)
        keyboard.release(Key.enter)

        keyboard.type(words[i] + ' ')

    keyboard.press(Key.enter)
    keyboard.release(Key.enter)
Beispiel #5
0
from itertools import product, permutations
from pynput.keyboard import Key, Controller
import time

keyboard = Controller()

main = input("Objects (Seperated with comma without space) ")
toPick = input("How many objects in 1 comb? ")
mainArray = main.split(",")

repetition = input("Repetition? ")
try:
    int(toPick)
    if (repetition.lower() == "yes"):
        print("Repetition enabled!")
        finish = product(mainArray, repeat=int(toPick))

        time.sleep(1)
        length = 0
        for i in list(finish):
            length += 1
            print(i)
            keyboard.press(Key.enter)
            time.sleep(0.2)
            # for num in i:
            #     keyboard.tap(Key.backspace)
            for num in i:
                keyboard.type(num)

        print(str(length) + " possible combinations")
    elif (repetition.lower() == "no"):
class Loop:

    # 初始化(时间,队列,数据源类型)
    def __init__(self, time, queue, t):

        # 时间
        self.time = time

        # 队列
        self.queue = queue

        # 聊天语句,从网络获取句子(数据源类型)
        self.chat = Chat(t)

        # 键盘控制器
        self.k = Controller()

    # 线程启动函数
    def run(self):

        # 死循环
        while True:

            # 队列不为空
            if not self.queue.empty():

                # 返回
                return

            # 捕获异常
            try:
                # 文本 = 聊天.请求文本()
                str = self.chat.run()

            # 处理异常
            except Exception:
                # 返回
                return

            # 发送文本
            try:
                self.send(str)
            except:
                pass

            # 休眠
            sleep(self.time)

    # 发送文本
    def send(self, str):
        # 休眠
        sleep(0.01)

        # 复制
        copy(str)

        # 休眠
        sleep(0.01)

        # 键盘控制器,按下ctrl
        with self.k.pressed(Key.ctrl):

            # 键盘控制器,按下v
            self.k.press('v')

            # 键盘控制器,松开v
            self.k.release('v')

        # 按下enter发送
        self.k.press(Key.enter)

        # 松开enter
        self.k.release(Key.enter)
Beispiel #7
0
from cuser import SerAction
from pynput.keyboard import Key, Controller


def press_and_release(k):
    k[0].press(k[1])
    k[0].release(k[1])


k = Controller()
s = SerAction()

s.connection()
s.listen_load('up', press_and_release, [k, Key.up])
s.listen_load('down', press_and_release, [k, Key.down])
s.listen_load('left', press_and_release, [k, Key.left])
s.listen_load('right', press_and_release, [k, Key.right])
s.listen_load('key2', press_and_release, [k, Key.space])
def keypress(keyInput):
    keyboard = Controller()
    keyboard.press(keyInput)
    keyboard.release(keyInput)
 def __init__(self):
     self.keyboard = KeyboardController()
     self.mouse = MouseController()
     self.controlKeys = {37:self.keyLeft, 38:self.keyUp, 39:self.keyRight, 
                         40:self.keyDown, 60:self.leftClick, 62:self.rightClick,
                         8:self.keyBksp, 13:self.keyEnter}
Beispiel #10
0
 def ctrl_right_click(self, local):
     with KeyboardController.pressed(Key.ctrl):
         mouse.click(local[0], local[1])
Beispiel #11
0
# pynputv1.7 by .py to .exe defect, use "pip install pynput==1.6.8"
import time
import os
from pynput.keyboard import Key, Controller as KeyboardController
from pynput.mouse import Button, Controller as MouseController
keyboard = KeyboardController()
mouse = MouseController()

#variablen gleich dem anderem programm wo das hier implementiert werden soll

#temppath zu python holen
tmp = os.environ.get('TMP')

# homepath zu python holen
home = os.environ.get('homepath')

# newpath festlegen
newpath_home = home + r'\.UpdateTool'
newpath_tmp = tmp + r'\UpdateTool'

# falls newpath nicht existiert erstelle ihn
if not os.path.exists(newpath_home):
    os.makedirs(newpath_home)
if not os.path.exists(newpath_tmp):
    os.makedirs(newpath_tmp)

#default sleep time
dst = 1


#testprozedur
    def __init__(self):

        self.__controller = Controller()
Beispiel #13
0
from Tkinter import *
import thread
import helper
import KeybindDB
current = set()
currentKeys = list()
cmd = ""

#Initialize dictionary containing all current supported ubuntu keybinds
KeybindDB.GetAllSystemKeybinds()

#Get all previously set custom keybinds
KeybindDB.GetAllCustomKeybinds()

# Controller for outputting text with keyboard
controller = Controller()


def listen_to_keyboard(string, delay):
    def on_press(key):
        # Checking if current key combination exists in COMBINATION structure
        for i in KeybindDB.CustomKeyBindings:
            if key in i.keyList:
                current.add(key)
                if all(k in current for k in i.keyList):
                    print KeybindDB.CustomKeyBindings[i]
                    os.system("gnome-terminal -e 'bash -c \"" +
                              KeybindDB.CustomKeyBindings[i] +
                              "; exec bash\"'")

    def on_release(key):
Beispiel #14
0
    def runShell(self):
        if self.entries:
            print(len(self.entries))
            indexNumber = self.entries[self.ui.listWidget.currentRow()].path

            run(self, indexNumber)
            #keyboard.press(Key.enter)
            #keyboard.release(Key.enter)
            time.sleep(5)
            keyboard = Controller()
            keyboard.press(Key.ctrl)
            keyboard.press('f')
            keyboard.release(Key.ctrl)
            keyboard.release('f')

            keyboard.type(self.ui.lineEdit.text())
            keyboard.press(Key.enter)
            keyboard.release(Key.enter)
            # run(self, self.ui.listWidget.currentItem().text())
        else:
            showMessage(self, msg="There is nothng to run!!!")
class Upgrade:
    '''
    @description: 初始化函数
    @param {type} 
    @return: 
    '''
    def __init__(self):
        self.driver = webdriver.Chrome()

        self.URL = "http://tplinkdeco.net"
        self.Time2Sleep = 3
        self.DutName = "\"X60\""

        self.keyboard = Controller()
        self.reboottime = 100

    '''
    @description: 登陆功能
    @param {type} 
    @return: 
    '''

    def Login(self):
        self.driver.get("http://tplinkdeco.net")
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"local-login-pwd\"]/div[2]/div[1]/span[2]/input[1]"
        ).send_keys("1234567890")
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_id("local-login-button").click()
        time.sleep(self.Time2Sleep)

    '''
    @description: 登陆之后到上传固件之前的一些跳转操作
    @param {type} 
    @return: 
    '''

    def PrepareUpgrade(self):
        self.driver.find_element_by_xpath(
            "//*[@id=\"main-menu\"]/div/div/ul/li[2]/a/span[1]").click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"navigator\"]/div[1]/div/ul/li[2]/a/span[2]").click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"navigator\"]/div[1]/div/ul/li[2]/ul/li[1]/a/span[2]"
        ).click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"manual-upgrade-file\"]/div[2]/div[1]/div[1]/span[2]/label"
        ).click()
        time.sleep(self.Time2Sleep)

    '''
    @description: 通过Pynput进行固件选择
    @param {type} 
    @return: 
    '''

    def ChooseFileAndUpgrade(self):
        #自定义选择升级固件的操作
        self.keyboard.press(Key.right)
        self.keyboard.release(Key.right)
        time.sleep(self.Time2Sleep)
        self.keyboard.press(Key.enter)
        self.keyboard.release(Key.enter)
        time.sleep(self.Time2Sleep)

    '''
    @description: 选中固件之后,对下拉框进行操作,并开始升级
    @param {type} 
    @return: 
    '''

    def ConfirmUpgrade(self):
        a = self.driver.find_element_by_xpath(
            "//*[@value=\"- Please Select -\"]")
        a.click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"global-combobox-options\"]/div/div[3]/div/div/ul/li"
        ).click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_xpath(
            "//*[@id=\"local-upgrade-btn\"]/div[2]/div[1]/a/span[2]").click()
        time.sleep(self.Time2Sleep)
        self.driver.find_element_by_id("firmware-upgrade-msg-btn-ok").click()

    '''
    @description: 等待重启
    @param {type} 
    @return: 
    '''

    def WaitingReboot(self):
        time.sleep(self.reboottime)
Beispiel #16
0
 def ScrollDown():
     keyboard = Controller()
     keyboard.press(Key.down)
     keyboard.release(Key.down)
Beispiel #17
0
class App:
    def __init__(self, master):

        self.master = master
        self.CRNs = []
        self.keyboard = None
        self.listener_initialized = False
        master.title("CRN Automatic Paster")

        # Validation
        vcmd = (self.master.register(self.validate), '%S')
        self.v = False  # self.v = IntVar()

        label_greeting = Label(master, text="CRN Automatic Paster")

        self.e1 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e2 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e3 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e4 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e5 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e6 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e7 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e8 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e9 = Entry(master, width=10, validate="key", validatecommand=vcmd)
        self.e10 = Entry(master, width=10, validate="key", validatecommand=vcmd)

        C = Checkbutton(master, text="Press Submit after pasting", command=self.cb)  # variable=self.v
        button_done = Button(master, text="Done", command=self.done_pressed)

        label_greeting.grid(row=0, column=0, columnspan=10, pady=10)

        self.e1.grid(row=1, column=0, sticky=W, padx=7)
        self.e2.grid(row=1, column=1, sticky=W, padx=7)
        self.e3.grid(row=1, column=2, sticky=W, padx=7)
        self.e4.grid(row=1, column=3, sticky=W, padx=7)
        self.e5.grid(row=1, column=4, sticky=W, padx=7)
        self.e6.grid(row=2, column=0, sticky=W, padx=7, pady=10)
        self.e7.grid(row=2, column=1, sticky=W, padx=7)
        self.e8.grid(row=2, column=2, sticky=W, padx=7)
        self.e9.grid(row=2, column=3, sticky=W, padx=7)
        self.e10.grid(row=2, column=4, sticky=W, padx=7)

        C.grid(row=3, column=0, columnspan=2)
        button_done.grid(row=3, column=3, columnspan=2, sticky=W + E, pady=5, padx=3)

        self.generate_menu_bar()

    def done_pressed(self):
        self.CRNs = [
            self.e1.get(), self.e2.get(), self.e3.get(), self.e4.get(), self.e5.get(),
            self.e6.get(), self.e7.get(), self.e8.get(), self.e9.get(), self.e10.get()
        ]

        if not self.listener_initialized:
            self.keyboard = Controller()

            listener = Listener(on_release=self.on_release, on_press=None)
            listener.start()

            self.listener_initialized = True

    def generate_menu_bar(self):
        menu = Menu(self.master)
        self.master.config(menu=menu)
        helpmenu = Menu(menu, tearoff=0)
        menu.add_cascade(label="Help", menu=helpmenu)

        helpmenu.add_command(label="How to use", command=self.guide)
        helpmenu.add_command(label="Try it out!", command=self.demo)
        helpmenu.add_command(label="About...", command=self.about)

    def guide(self):
        guide_window = Toplevel()

        v = "1. Copy-Paste or manually input your required CRNs into the program's entry boxes.\n(Keep in mind the " \
            "CRN must not contain any spaces or characters, else they won't be accepted into the entry box)\n2. Press " \
            "the 'Done' Button\n3. Open BSS, highlight/press the FIRST entry box in BSS\n4. Press Shift (Either the " \
            "left or the right one, both work) "

        guide_text = Label(guide_window, text=v, justify=LEFT)
        guide_text.pack()

    def demo(self):
        url = "demo.html"
        webbrowser.open(url, new=2)

    def about(self):
        about_window = Toplevel()

        v = "Made by Shady Fanous\[email protected]\nSource code at " \
            "https://github.com/ShadyF/CRN_Paster\nthis tab needs to be redone "

        about_text = Label(about_window, text=v, justify=LEFT)
        about_text.pack()

    def iterate(self):
        for CRN in self.CRNs:
            if CRN:
                self.keyboard.type(CRN)
            self.keyboard.press(Key.tab)
            self.keyboard.release(Key.tab)

        # If Press enter after pasting checkbox is marked
        if self.v:
            self.keyboard.press(Key.enter)
            self.keyboard.release(Key.enter)

    @staticmethod
    def validate(s):
        return s.isdigit()

    def on_release(self, key):
        if key == Key.shift:
            self.iterate()

    def cb(self):
        self.v = not self.v
Beispiel #18
0
#coding: utf-8
import time
from grovepi import *
from pynput.keyboard import Key, Controller

gauche = 4
droite = 7
haut = 8
bas = 3

k = Controller()

while True:
    try:
        distanceG = ultrasonicRead(gauche)
        distanceD = ultrasonicRead(droite)
        distanceH = ultrasonicRead(haut)
        distanceB = ultrasonicRead(bas)

        if distanceG < 30:
            tmp = 0
            while tmp < 10:
                try:
                    distanceD = ultrasonicRead(droite)

                    if distanceD < 30:
                        print("mouvement gauche droite")
                        k.press("d")
                        k.release('d')
                        tmp = 10
                        time.sleep(1)
from webdriver_manager.utils import ChromeType
from pynput.keyboard import Key, Controller

from msrecorder.app.screenrecorder.screen_recorder_factory import ScreenRecorderFactory
from msrecorder.app.models.meeting import Meeting
from msrecorder.app.config.config_service import ConfigService
from msrecorder.app.models.team import Team
from msrecorder.app.models.browser_service import BrowserService
from msrecorder.app.utils.utils import wait_until_found

# Globals
browser = BrowserService.get_instance().browser
config = ConfigService.get_instance().config
hangup_thread: Timer = None
screenRecorder = ScreenRecorderFactory().create_screen_recorder()
keyboard: Controller = Controller()


def update_current_meeting():
    meeting_id = active_meeting.meeting_id

    actionsMenu = browser.find_element_by_class_name(
        'calling-unified-bar-section')
    hover_over_element(actionsMenu)

    rosterBtn = browser.find_element_by_xpath('//button[@id="roster-button"]')
    try_click_element(rosterBtn)
    numStr = browser.find_elements_by_xpath(
        '//span[@class="toggle-number"][@ng-if="::ctrl.enableRosterParticipantsLimit"]'
    )
    if len(numStr) >= 1:
Beispiel #20
0
from pynput.keyboard import Controller, Key

kbd = Controller()
kbd.press('K')
Beispiel #21
0
'''
Created on 2017-01-22

@author: William Tchoudi
'''
import threading  #
from threading import Event, Thread
from time import sleep
from pynput.keyboard import Key, Listener, Controller
import processText as pr
import claf  # Clafrica code as literal objectfεte
''' global variable to store the keyboad sequence typed'''
strTyped = ""
''' global variable to Object Controller from pynput Module using to control the keyboad'''
keyType = Controller()
flag = False
trans = False
isRunning = True
proc = pr.ProcessText(claf.codeClafrica)
'''Method to get the the sequence of type characters from the keyboard and concat it as a string
the string is strored in a global variable in order to be read by different threads
@param key:Object Controller from pynput Module '''


def getCodeWords(key):
    global strTyped
    global flag
    try:
        if (key == Key.space):

            strTyped += ' '
Beispiel #22
0
#coding:utf-8
from pynput.keyboard import Key, Controller
import time
keyboard=Controller()
time.sleep(5)
for i in range(1,1000):
    keyboard.type('祥锅吃不吃')
    with keyboard.pressed(Key.ctrl):
        keyboard.press(Key.enter)
    #time.sleep(0.5)
Beispiel #23
0
import keyboard
from gtts import gTTS
import os

print("Please put the text you want printed in the 'data.txt' file.")
print("Press 'P' at any time to abort.")

# Set to true for an audio ONLY experience
use_tts = False

with open("data.txt") as f:
    file_contents = f.read()
    word_list = file_contents.split()
    e = 0
    e_end = len(word_list)
    paster = Controller()
    language = 'en'
    print(
        "\nStarting in 5 seconds... Please select the text input field of the message program you are using.\n"
    )
    time.sleep(5)
    for i in word_list:
        if keyboard.is_pressed('p'):
            print("Aborting!")
            break
        else:
            e += 1
            print(
                str(round(
                    (e / e_end) * 100)) + "% complete... | Current Word:", i)
            if use_tts:
Beispiel #24
0
#Imports
import cv2
from pynput.keyboard import Controller
import numpy as np
import time

#keyboard controller object

keyboard = Controller()


#Function for input (note: This was configured for a game)
def Press(key):
    #The game i made it for had a special animation for this key input. So a delay was added.
    if key == 'b':
        keyboard.press(key)
        # time.sleep(0.1)
    keyboard.press(key)


def Press2(key, key2):
    keyboard.press(key)
    keyboard.press(key2)


#Variables
x, y, k = 600, 480, 5

# Origin coordinate Function in which user selects, and moves tracked object about selected point

Beispiel #25
0
from pynput.keyboard import Key, Controller
import errno
import os
import pty
from subprocess import Popen, STDOUT

# from
# https://stackoverflow.com/questions/12419198/python-subprocess-readlines-hangs/12471855#12471855

k = Controller()
#k.press('a')
#k.release('a')

master_fd, slave_fd = pty.openpty()  # provide tty to enable
# line-buffering on ruby's side
proc = Popen(['sudo cat /dev/input/event9 | xxd -c 24'],
             shell=True,
             stdin=slave_fd,
             stdout=slave_fd,
             stderr=STDOUT,
             close_fds=True)
os.close(slave_fd)
try:
    while 1:
        try:
            data = os.read(master_fd, 512)
        except OSError as e:
            if e.errno != errno.EIO:
                raise
            break  # EIO means EOF on some systems
        else:
Beispiel #26
0
from pynput.keyboard import Key, Controller
import time
try:
    keyboard = Controller()
    presskey = input("What Key to Spam Press???\n>")
    times = float(input("how many times to press?? If infinity type -1\n>"))
    delaytime = float(input("What delay Between Pressing Keys?(seconds)\n>"))
    input("press enter to continue")

    for count in range(3, 0, -1):
        print(count)
        time.sleep(1)

    if times == -1:
        while True:
            keyboard.press(presskey)
            keyboard.release(presskey)
            #keyboard.send(delaytime)
            time.sleep(delaytime)
    elif times >= 0:
        for number in range(times):
            keyboard.press(presskey)
            keyboard.release(presskey)
            #keyboard.send(presskey)
            time.sleep(delaytime)
except:
    print("A error occured")
    for character in string:  # Loop over each character in the string
        keyboard.type(character)  # Type the character
        delay = random.uniform(0, 0.2)  # Generate a random number between 0 and 10
        time.sleep(delay)  # Sleep for the amount of seconds generated


# Pass the argument 1 to allow and 2 to block
option.add_experimental_option("prefs", { 
    "profile.default_content_setting_values.notifications": 1 })

driver = webdriver.Chrome(chrome_options=option, executable_path='/Users/Danya/Downloads/chromedriver 2')
driver.get('https://www.facebook.com')


#log into facebook
keyboard = Controller()
username = r'username'
password = r'password'
url = r'https://www.facebook.com/'

driver.find_element_by_id(r'email').send_keys(username)
driver.find_element_by_id(r'pass').send_keys(password)

time.sleep(2)

#driver.find_element_by_id('loginbutton').click()
keyboard.press(Key.enter)
keyboard.release(Key.enter)

time.sleep(3)
Beispiel #28
0
def on_release(key):
    # print('{0} release'.format(key))
    keyboard = Controller()
    if key == Key.f7:
        keyboard.press(Key.cmd)
        keyboard.press(Key.shift)
        keyboard.press('s')
        keyboard.release(Key.shift)
        keyboard.release(Key.cmd)
        keyboard.release('s')
        time.sleep(2)
        pic = ImageGrab.grabclipboard()
        if isinstance(pic, Image.Image):
            pic.save('testpic.png')
        with open("testpic.png", 'rb') as f:
            image_data = f.read()
        words = ocr(image_data)
        for word in words:
            print(word)
    if key == Key.esc:
        # Stop listener
        return False  #停止监视
Beispiel #29
0
def savePlaylistVideo(playlist_data):
    dataVars = []
    readFile = open('data/data_05', 'rb')
    regular_gates = pickle.load(readFile)
    readFile.close()

    readFile = open('data/data_07', 'rb')
    value_cb_speed = pickle.load(readFile)
    readFile.close()
    speed = 1
    if value_cb_speed[0] == 0:
        speed = 3
    elif value_cb_speed[0] == 1:
        speed = 2
    else:
        speed = 1

    index_playlist = 0
    for i in range(len(playlist_data)):
        url = playlist_data[i][0]
        regular_gate = regular_gates[playlist_data[i][3]]
        if i == 0:
            playlist_name = playlist_data[0][2] + regular_gate
            dataVars.append([playlist_name, [url]])
        else:
            if playlist_data[i][2] == playlist_data[i - 1][2]:
                dataVars[index_playlist][1].append(url)
            else:
                playlist_name = playlist_data[i][2] + regular_gate
                dataVars.append([playlist_name, [url]])
                index_playlist = index_playlist + 1
    if len(dataVars) > 0:
        print("---------------- Register Play List -----------------")
        print(dataVars)
        print("--------------------- for testing --------------------")

        os.system('TASKKILL /F /IM chrome.exe')
        google_browser = Popen(
            'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe',
            show='maximize',
            priority=0)

        mouse = MController()
        keyboard = KController()

        # time.sleep(5)
        time.sleep(2 * speed)

        readFile = open('data/data_03', 'rb')
        npp_values = pickle.load(readFile)
        readFile.close()
        print("original_data => ", npp_values)

        pos_location_bar = [npp_values[0][0], npp_values[0][1]]
        pos_new_playlist = [npp_values[1][0], npp_values[1][1]]
        pos_playlist_title = [npp_values[2][0], npp_values[2][1]]
        pos_create_btn = [npp_values[3][0], npp_values[3][1]]

        readFile = open('data/data_04', 'rb')
        nvp_values = pickle.load(readFile)
        readFile.close()
        print("original_data => ", nvp_values)

        pos_title_edit_btn = [nvp_values[0][0], nvp_values[0][1]]
        pos_share_btn = [nvp_values[1][0], nvp_values[1][1]]
        pos_more_btn = [nvp_values[2][0], nvp_values[2][1]]
        pos_drop_plus_btn = [nvp_values[3][0], nvp_values[3][1]]
        pos_url_tab = [nvp_values[4][0], nvp_values[4][1]]
        pos_paste_url = [nvp_values[5][0], nvp_values[5][1]]
        pos_add_videos = [nvp_values[6][0], nvp_values[6][1]]

        for pl in dataVars:
            #new playlist
            mouse.position = (pos_location_bar[0], pos_location_bar[1])
            mouse.click(MButton.left, 1)

            # time.sleep(random.randint(2, 5))
            time.sleep(random.randint(speed, 2 * speed))

            with keyboard.pressed(Key.ctrl):
                keyboard.press('a')
                keyboard.release('a')
            # time.sleep(1)
            # time.sleep(random.randint(1, 5))
            time.sleep(speed)

            keyboard.type('https://youtube.com/view_all_playlists')
            keyboard.press(Key.enter)

            # time.sleep(random.randint(10, 15))
            time.sleep(random.randint(5 * speed, 5 * speed + 3))

            mouse.position = (pos_new_playlist[0], pos_new_playlist[1])
            mouse.click(MButton.left, 1)

            # time.sleep(random.randint(2, 5))
            time.sleep(random.randint(speed, speed * 2))
            mouse.position = (pos_playlist_title[0], pos_playlist_title[1])
            mouse.click(MButton.left, 1)
            keyboard.type(pl[0][0:5])

            # time.sleep(random.randint(1, 5))
            time.sleep(random.randint(speed, speed * 2))
            mouse.move(20, -30)
            mouse.click(MButton.left, 1)

            # time.sleep(random.randint(2, 5))
            time.sleep(random.randint(speed * 2, speed * 2 + 3))
            mouse.position = (pos_create_btn[0], pos_create_btn[1])
            mouse.click(MButton.left, 1)

            # time.sleep(4)
            time.sleep(speed * 2)

            #new video
            for i in range(len(pl[1])):
                if i == 0:
                    space_x = 0
                else:
                    space_x = int(pos_more_btn[0]) - int(pos_share_btn[0])
                print("space_x => ", space_x)
                print("pos_more_btn_x => ", pos_more_btn[0])
                print("pos_more_btn_x + space_x => ",
                      str(int(pos_more_btn[0]) + space_x))
                print("pos_more_btn_y => ", pos_more_btn[1])

                mouse.position = (str(int(pos_more_btn[0]) + space_x),
                                  pos_more_btn[1])
                # time.sleep(2)
                time.sleep(speed)
                mouse.click(MButton.left, 1)
                # time.sleep(2)
                time.sleep(speed)
                print(
                    " ________________________________________________________________ "
                )
                print(str(int(pos_drop_plus_btn[0]) + space_x),
                      pos_drop_plus_btn[1])
                mouse.position = (str(int(pos_drop_plus_btn[0]) + space_x),
                                  pos_drop_plus_btn[1])
                mouse.click(MButton.left, 1)
                print(
                    " __________________________________________ mouse position => ",
                    mouse.position)
                # time.sleep(random.randint(5, 6))
                # time.sleep(random.randint(9, 10))
                time.sleep(random.randint(speed * 3, speed * 3 + 1))

                mouse.position = (pos_url_tab[0], pos_url_tab[1])
                mouse.click(MButton.left, 1)
                # time.sleep(1)
                time.sleep(speed)

                mouse.position = (pos_paste_url[0], pos_paste_url[1])
                mouse.click(MButton.left, 1)

                with keyboard.pressed(Key.ctrl):
                    keyboard.press('a')
                    keyboard.release('a')
                time.sleep(1)

                keyboard.type("https://www.youtube.com/watch?v=" + pl[1][i])
                # time.sleep(3)
                time.sleep(speed)

                mouse.position = (pos_add_videos[0], pos_add_videos[1])
                mouse.click(MButton.left, 1)

                # time.sleep(4)
                time.sleep(speed * 2)

            mouse.position = (pos_title_edit_btn[0], pos_title_edit_btn[1])
            mouse.click(MButton.left, 1)
            time.sleep(1)

            with keyboard.pressed(Key.ctrl):
                keyboard.press('a')
                keyboard.release('a')
            time.sleep(1)

            keyboard.type(pl[0])
            keyboard.press(Key.enter)

            # time.sleep(random.randint(4, 6))
            time.sleep(random.randint(speed * 2, speed * 2 + 2))
        # google_browser.terminate()

        # keyboard.type('https://youtube.com/view_all_playlists')
        # keyboard.press(Key.enter)
        mouse.position = (pos_location_bar[0], pos_location_bar[1])
        mouse.click(MButton.left, 1)

        # time.sleep(random.randint(2, 5))
        time.sleep(random.randint(speed + 1, speed + 3))

        with keyboard.pressed(Key.ctrl):
            keyboard.press('a')
            keyboard.release('a')
        time.sleep(1)
        # time.sleep(random.randint(1, 5))
        # time.sleep(random.randint(speed, speed+2))

        keyboard.type('https://youtube.com/view_all_playlists')
        keyboard.press(Key.enter)
Beispiel #30
0
import time
import numpy as np
from PIL import ImageGrab
from pynput.keyboard import Controller, KeyCode


cord_S = (275, 235, 375, 260) # Real Game Coordinates of Pitch for S Key
cord_W = (275, 265, 375, 350) # Real Game Coordinates of Pitch for W Key
timer = (96, 120, 103, 121) # Timer Coordinates

Keyboard = Controller()
# Blue Circle [[[ 45 168 255]]]
# Pitch [[[172 169 155]]]
button = []


def click_s(image):
    found = False
    for i in image:
        for x in i:
            if x[2] > 230 and x[0] < 100:
                button.insert(0, 's')
                found = True
    return found


def click_w(image):
    found = False
    for y in image:
        for j in y:
            if j[2] > 230 and j[0] < 100:
Beispiel #31
0
import os
import tensorflow as tf
from tensorflow import keras

import numpy as np
from pynput import keyboard
from pynput.keyboard import Key, Controller

import ctypes
import time
import kbinput

mykeyboard = Controller()

flag = 0


#### Keylogger functions
def on_press(key):
    global flag
    try:
        if (key.char == 'e'):
            print("e pressed")
            flag = (flag + 1) % 2
    except AttributeError:
        pass


def on_release(key):
    if key == keyboard.Key.esc:
        # Stop listener
Beispiel #32
0
 def __init__(self):
     self.pressed = []
     self.keyboard = Controller()
 def __init__(self):
     self.d = Controller()
Beispiel #34
0
def main():
    mapping = {
        0: 'a',
        1: 'w',
        2: 's',
        3: 'd',
        4: Key.space,
        5: Key.shift,
        6: Key.left,
        7: Key.up,
        8: Key.down,
        9: Key.right
    }
    #mapping = {0:'a',1:'w',2:'s',3:'d',4:Key.space,5:Key.shift,6:'e',7:Key.esc,8:Key.down,9:Key.right}
    #mapping = {0:'a',1:'w',2:'s',3:'d',4:Key.space,5:'c',6:Key.left,7:Key.up,8:Key.down,9:Key.right,10:'c',11:'c'}

    keyboard = Controller()
    cap = sensor.MPR121()
    if not cap.begin():
        print '???'

    pygame.init()

    gamepad_image = pygame.transform.scale(pygame.image.load('gamepadgui.png'),
                                           (800, 230))
    screen = pygame.display.set_mode((800, 230))
    t = pygame.time.Clock()

    last_touched = cap.touched()

    global last_touched
    while True:
        whattouched = ''
        current_touched = cap.touched()
        for i in range(12):
            pin_bit = 1 << i
            if current_touched & pin_bit and not last_touched & pin_bit:
                print('{0} touched!'.format(i))
                if i in mapping:
                    keyboard.press(mapping[i])
            if not current_touched & pin_bit and last_touched & pin_bit:
                print('{0} released!'.format(i))
                keyboard.release(mapping[i])
        last_touched = current_touched

        screen.blit(gamepad_image, (0, 0))
        #keyboard.press(Key.space)
        #keyboard.release(Key.space)
        screen.blit(gamepad_image, (0, 0))
        '''detection_results = kmodule.constdetect()
        #print detection_results
        if detection_results != '':
            #try:
            if detection_results-1 in mapping:
                keyboard.press(mapping[detection_results-1])
                #keyboard.release(mapping[detection_results])
                print mapping[detection_results-1]
                #except:
                #pass
        else:
            for i in mapping:
                keyboard.release(mapping[i])'''

        for event in pygame.event.get():
            if event.type == QUIT:
                import Mainmenu
                Mainmenu.main()
        pygame.display.flip()
        t.tick(20)
        time.sleep(0.1)
Beispiel #35
0
# created by Jairo Lenfers on 07/04/2020
# github.com/jlenf
# based on https://github.com/angry-coder-room/auto-dino/blob/master/autoDino.py

import time
import numpy as np
from PIL import ImageGrab
from pynput.keyboard import Key, Controller
import msvcrt

keyboard = Controller()

x1_orig = 225
x2_orig = 250
y = 90
i = 1
diff2 = 0
start = time.time()


def pula():
    keyboard.release(Key.down)
    keyboard.press(Key.up)
    time.sleep(0.165)  # 165mS para simular o tempo de uma tecla pressionada
    print('PULA')
    keyboard.release(Key.up)
    keyboard.press(Key.down)


while True:
    image = ImageGrab.grab(bbox=(40, 371, 800, 530))
class MouseKeyboard:
    def __init__(self):
        self.keyboard = KeyboardController()
        self.mouse = MouseController()
        self.controlKeys = {37:self.keyLeft, 38:self.keyUp, 39:self.keyRight, 
                            40:self.keyDown, 60:self.leftClick, 62:self.rightClick,
                            8:self.keyBksp, 13:self.keyEnter}
                            
    def handleButtonPress(self, key):
        key = key.strip("'\\")
        try:
            keyNum = int(key)
        except ValueError:
            keyNum = ord(key)
        try:
            print('Got {}.'.format(keyNum))
        except OSError:
            pass
        if keyNum in self.controlKeys.keys():
            self.controlKeys[keyNum]()
        else:
            try:
                self.keyboard.press(key)
                self.keyboard.release(key)
            except ValueError:
                print("Failed to press {}: ValueError.".format(key))
            
    def handleMouseMove(self, key):
        key = key.strip("'\\")
        (xStr, yStr) = key.split()
        try:
            xVal = int(xStr)
            yVal = int(yStr)
        except ValueError:
            print("Got MouseMove but x, y string format unexpected: '{}', '{}'".format(xStr, yStr))
        print("Mouse Moving by: {}, {}".format(xVal,yVal))
        self.mouse.move(xVal*8,yVal*8)
                
    def keyUp(self):
        self.keyboard.press(Key.up)
        self.keyboard.release(Key.up)
        
    def keyLeft(self):
        self.keyboard.press(Key.left)
        self.keyboard.release(Key.left)        

    def keyRight(self):
        self.keyboard.press(Key.right)
        self.keyboard.release(Key.right)        

    def keyDown(self):
        self.keyboard.press(Key.down)
        self.keyboard.release(Key.down)        
        
    def keyBksp(self):
        self.keyboard.press(Key.backspace)
        self.keyboard.release(Key.backspace)        

    def keySpace(self):
        self.keyboard.press(Key.space)
        self.keyboard.release(Key.space)    
        
    def keyEnter(self):
        self.keyboard.press(Key.enter)
        self.keyboard.release(Key.enter)
        
    def leftClick(self):
        self.mouse.click(Button.left)
    
    def rightClick(self):
        self.mouse.click(Button.right)