Пример #1
0
                speak("what should the content be?")
                content = takeCommand()
                to = "email here"
                sendEmail(to, content)
                speak("Email has been sent!")
            except Exception as e:
                print(e)
                speak("Sorry there might be some issue with the cloud")

        elif "h a c k" in query:
            speak('initiating kali destro')
            virtual_box = 'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\Oracle VM VirtualBox'
            vm = os.listdir(virtual_box)
            os.startfile(os.path.join(virtual_box, vm[1]))
            sleep(2)
            mouse = Controller()
            mouse.position = (818, 281)
            sleep(2)
            mouse.click(Button.left)

        elif "virtual" in query:
            speak("initiating hands free mode")
            speak("virtual environment calibrated")
            autoMouse()

        elif "fun" in query:
            speak("of course sir")
            handGesture()

        elif "thank you" in query:
            speak('my pleasure sir')
Пример #2
0
## Made by KanuX <3 ##

import pyscreeze as ps
from pynput.mouse import Button, Controller
import keyboard as kb
import pyautogui as py
import mouse
import time
import random

ms = Controller()
posX, posY = py.size()
x, y = 0, 0

safeCPU = False

wait = time.sleep
sec = 60

while True:
    x = x + 10
    if x > posX:
        x = 0
        y = y + 3
    if y > posY:
        y = 0
    colour = ps.pixelMatchesColor(x, y, (0, 230, 203))
    if colour == True:
        mouse.move(x, y, True, 0)
        ms.click(Button.left, 1)
        wait(5)
Пример #3
0
def controlMouse():
    Mouse = Controller()
    Mouse.position = (100, 200)
Пример #4
0
            easing = lambda n, *_, **__: n

        np_arr = np.array([
            cls.bezier(easing(t, *args, **kwargs), control_points)
            for t in np.linspace(0, 1, int(n_points))
        ])
        return np.concatenate(
            ([control_points[0]], np_arr, [control_points[-1]]))


if __name__ == '__main__':
    from time import sleep
    from pynput.mouse import Controller  # pip install pynput
    from easing import Easing

    mouse = Controller()  # pynput

    easing = Easing()
    easing = getattr(easing, np.random.choice(
        dir(easing)))  # randomly choose easing method
    print(f"chosen easing: {easing.__name__}")

    cur_x, cur_y = mouse.position  # pynput:  get mouse-pointer position
    points = np.array([[cur_x, cur_y], [800, 800], [200,
                                                    200]])  # control points

    for pos in Bezier.bezier_path(100, points, easing):
        mouse.position = pos  # pynput:  set mouse-pointer position
        sleep(0.0275)

    sleep(0.2)
Пример #5
0
import cv2
import numpy as np
from pynput.mouse import Button, Controller
import wx
mouse=Controller()

app=wx.App(False)
(sx,sy)=wx.GetDisplaySize()
(camx,camy)=(320,240)

lowerBound=np.array([33,80,40])
upperBound=np.array([102,255,255])

cam= cv2.VideoCapture(0)

kernelOpen=np.ones((5,5))
kernelClose=np.ones((20,20))
pinchFlag=0

while True:
    ret, img=cam.read()
    img=cv2.resize(img,(340,220))

    #convert BGR to HSV
    imgHSV= cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
    # create the Mask
    mask=cv2.inRange(imgHSV,lowerBound,upperBound)
    #morphology
    maskOpen=cv2.morphologyEx(mask,cv2.MORPH_OPEN,kernelOpen)
    maskClose=cv2.morphologyEx(maskOpen,cv2.MORPH_CLOSE,kernelClose)
Пример #6
0
import threading
from pynput.mouse import Button, Listener, Controller
from pynput import keyboard
import time
 
shoot = 0
scope = -1
status = 1

controller = Controller()

def mouse_click(x, y, button, pressed):
    global shoot
    global scope
    if pressed:
        if button == Button.right:
            scope = - scope
        if button == Button.left:
            shoot = 1
    if not pressed and button == Button.left:
        shoot = 0
 
def keyboard_release(key):
    global status

    if key == keyboard.Key.backspace:
        status = -status

def mouseListener():
    with Listener(on_click=mouse_click) as listener:
        listener.join()
Пример #7
0
 def __init__(self, sleep=0):
     self.mouse = Controller()
     self.sleep = sleep
Пример #8
0
from pynput.mouse import Controller

# 488
# 792
# 304
# 50.5

# 202
# 404
# 50.5

mouse = Controller()
# mouse.position = (488, 225)
# mouse.position = (1 * 50.5 + 463, 202)
mouse.position = (410, 190)
Пример #9
0
from sgtk_menu.tools import (get_locale_string, config_dirs, load_json, save_json, create_default_configs, data_dirs,
                             check_wm, display_geometry)

wm = check_wm()

if wm == "sway":
    var = subprocess.run(['swaymsg', 'for_window', '[title=\"~sgtk*\"]', 'floating', 'enable'],
                         stdout=subprocess.DEVNULL).returncode == 0
    var = subprocess.run(['swaymsg', 'for_window', '[title=\"~sgtk*\"]', 'border', 'none'],
                         stdout=subprocess.DEVNULL).returncode == 0

mouse_pointer = None
if not wm == "sway":
    try:
        from pynput.mouse import Controller
        mouse_pointer = Controller()
    except:
        pass

# List to hold AppButtons for favourites
all_favs = []
# Lists to hold AppBoxes for apps found in .desktop files
all_apps = []

localized_names_dictionary = {}  # name => translated name
locale = ''

win = None  # overlay window
args = None
all_items_list = []  # list of all DesktopMenuItem objects assigned to a .desktop entry
all_copies_list = []  # list of copies of above used while searching (not assigned to a submenu!)
from pynput.mouse import Button, Controller
import time
import serial


# portNo = '/dev/tty.usbmodem14101'
mouse = Controller()
xMax = 1280
yMax = 800
x = 0
y = 0
# ser = serial.Serial(portNo, 9600)

boolTrue = True

while (boolTrue):
    # readVal = int(ser.readline())
    mouse.position = (x, y)
    time.sleep(.005)
    if (x < xMax):
        x+=1
    else :
        boolTrue = False
    if (y < yMax):
        y+=1
    else :
        boolTrue = False
Пример #11
0
import speech_recognition as sr
from pynput.mouse import Button, Controller as MouseController
from pynput.keyboard import Key, Listener, Controller as KeyboardController
import the_H
import subprocess
from selenium import webdriver
from time import sleep

mouse = MouseController()
r = sr.Recognizer()
bro = ''
i = 0


def say(text):
    subprocess.call(['say', text])


while ('close' not in bro and 'shut up' not in bro and 'shut down' not in bro):
    with sr.Microphone() as src:
        a = r.adjust_for_ambient_noise(src)
        print("Say hey dude to start")
        while True:
            a = r.listen(src, phrase_time_limit=3)
            try:
                t = r.recognize_google(a)
            except:
                t = ""
            if (format(t) == 'hey dude'):
                break
Пример #12
0
class MouseUtil:
    """大话西游鼠标操作的工具类
    包含各种鼠标点击,任务领取,物品使用等功能
    1左键点击npc
    2截图
    3领取任务
    4打开物品栏
    5选择背包1还是背包2
    6移动到对应的物品栏位置,右键使用物品
    7确定(3领取任务)

    """
    mouse = Controller()

    def move_to(self, dx, dy):
        """鼠标移动到某一位置

        :param int dx: 水平位置.

        :param int dy: 垂直位置.
        """
        self.mouse.position = (dx, dy)

    def click_left(self):
        """点击鼠标左键(一次)
        """
        time.sleep(1)
        self.mouse.press(Button.left)
        self.mouse.release(Button.left)

    def click_right(self):
        """点击鼠标右键(一次)
        """
        time.sleep(1)
        self.mouse.press(Button.right)
        self.mouse.release(Button.right)

    def click_npc(self, dx, dy):
        """左键点击npc

        :param int dx: 水平位置.

        :param int dy: 垂直位置.
        """
        self.move_to(dx, dy)
        self.click_left()

    def receive_task(self):
        """领取任务
        """
        self.move_to(150, 290)
        self.click_left()

    def select_option(self, type, position):
        '''选择选项

        :param type:
        :param position:
        :return:
        '''
        y = 0
        if type == 0:
            y = 255
        elif type == 1:
            y = 290
        elif type == 2:
            y = 308
        self.move_to(150, y + ((position - 1) * 18))
        self.click_left()

    def open_inventory(self):
        """打开物品栏
        """
        self.move_to(527, 611)
        self.click_left()

    def select_inventory(self, position):
        """选择背包1还是背包2
        """
        if position == 1:
            self.move_to(760, 360)
        else:
            self.move_to(760, 360 + ((position - 1) * 51))
        self.click_left()

    def carry_store(self):
        """打开随身商店
        """
        # self.move_to(735, 555)
        self.move_to(650, 555)
        self.click_left()

    def carry_store_buy(self, gx, gy):
        """从随身商店购买商品
        """
        self.move_to(273, 175)
        self.click_left()
        horizontal_one = 273
        vertical_one = 175
        distance = 51
        horizontal_one = horizontal_one + ((gy - 1) * distance)
        vertical_one = vertical_one + ((gx - 1) * distance)
        self.move_to(horizontal_one, vertical_one)
        self.click_left()
        self.move_to(405, 500)
        self.click_left()
        self.move_to(563, 114)
        self.click_left()

    def select_goods(self, gx, gy):
        """选择指定位置的物品
        :param int gx: 水平位置(取值范围1-6).
        :param int gy: 垂直位置(取值范围1-4).
        """
        horizontal_one = 469
        vertical_one = 360
        distance = 51
        horizontal_one = horizontal_one + ((gy - 1) * distance)
        vertical_one = vertical_one + ((gx - 1) * distance)
        self.move_to(horizontal_one, vertical_one)
        self.click_right()

    def move_goods(self, gx, gy):
        """选择指定位置的物品
        :param int gx: 水平位置(取值范围1-6).
        :param int gy: 垂直位置(取值范围1-4).
        """
        horizontal_one = 469
        vertical_one = 360
        distance = 51
        horizontal_one = horizontal_one + ((gy - 1) * distance)
        vertical_one = vertical_one + ((gx - 1) * distance)
        self.move_to(horizontal_one, vertical_one)
        self.click_left()

    def submit_task(self, talk_type, position):
        '''提交任务

        :param self:
        :param int type: 根据对话长度点击不同的选线
        :param int position: 选择第几个个
        :return:
        '''
        if talk_type == 0:
            self.move_to(150, 255)
        elif talk_type == 1:
            self.move_to(150, 290 + ((position - 1) * 18))
        elif talk_type == 2:
            self.move_to(150, 308 + ((position - 1) * 18))
        self.click_left()
 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}
Пример #14
0
def Click(x, y):
    mouse = Controller()
    mouse.position = (x, y)
    mouse.press(Button.left)
    mouse.release(Button.left)
    return
Пример #15
0
# modified version
# 11/30/2019 ys895
import cv2
import numpy as np
import pyautogui
from pynput.mouse import Button, Controller
import time

cap = cv2.VideoCapture(1)
cap.set(3, 640)
cap.set(4, 640)

time.sleep(1.1)
_, img = cap.read()
alpha = 2
mouse = Controller()
gamma = 0.5
check = False
pts = [(0, 0), (0, 0), (0, 0), (0, 0)]
pointIndex = 0
# image size
AR = (740, 1280)
oppts = np.float32([[0, 0], [AR[1], 0], [0, AR[0]], [AR[1], AR[0]]])
a = 0
b = 0
# set the color upper bound&lower bound
# blue
#lower = (110, 50, 250)
#upper = (130,255,255)

# red
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)
Пример #17
0
from PIL import ImageGrab
from pynput.mouse import Button, Controller
from ctypes import windll
import time

mouse = Controller()
dc = windll.user32.GetDC(0)
gdi = windll.gdi32
print("Press Ctrl + C to terminate the program.")

screensize = windll.user32.GetSystemMetrics(0), windll.user32.GetSystemMetrics(
    1)
# avoids importing sys
supportedScreenRes = False
print(windll.gdi32.GetPixel(windll.user32.GetDC(0), 950, 460))

if (screensize[0] == 1920 and screensize[1] == 1080):
    mouse.position = (950, 460)
    supportedScreenRes = True
elif (screensize[0] == 2560 and screensize[1] == 1440):
    mouse.position = (950, 460)
    supportedScreenRes = True
else:
    print("Sorry, your resolution isn't supported.")

# click to start the test
mouse.click(Button.left, 1)

if (supportedScreenRes):
    # we do not specifiy a break condition to maximize performance, program has to be quit with Ctrl + C
    while True:
Пример #18
0
from pynput.mouse import Button, Controller
import time
import random

# https://nitratine.net/blog/post/simulate-mouse-events-in-python/

mouse = Controller()
print("Current position: " + str(mouse.position))
mouse.position = (10, 20)

# while True:
#     print(random.randrange(-20,20,1))

while True:
    mouse.move(random.randrange(-20, 20, 1), random.randrange(-20, 20, 1))
    time.sleep(100)
    mouse.move(random.randrange(-20, 20, 1), random.randrange(-20, 20, 1))
    time.sleep(100)
    mouse.move(random.randrange(-20, 20, 1), random.randrange(-20, 20, 1))
import tensorflow as tf
import numpy as np
import cv2
from global_variables import *
from preprocessing import *

# Code based on https://github.com/sankit1/cv-tricks.com/tree/master/Tensorflow-tutorials/tutorial-2-image-classifier
from pynput.mouse import Button, Controller
mouse = Controller()


def find_gesture(result):
    '''Given the output of the model, find the category with the highest probability. If it's less than 80%,
    we consider it to be none since it is not confident enough. Note: we used softmax so the probability adds up to 1.
    We also used the none category.'''
    result = result[0]
    max_val = 0.0
    max_ind = 0
    for i in range(len(result)):
        if result[i] > max_val:
            max_val = result[i]
            max_ind = i
    if max_val > 0.8:
        return max_ind
    else:
        return 6


## Let us restore the saved model
sess = tf.Session()
# Step-1: Recreate the network graph. At this step only graph is created.
Пример #20
0
import cv2
import numpy as np
from pynput.mouse import Button, Controller

mouse = Controller()
import tkinter as tk

root = tk.Tk()

sx = root.winfo_screenwidth()
sy = root.winfo_screenheight()
root.quit()
(camx, camy) = (320, 240)

#import time

#lower_red1 = np.array([0,50,50])
#upper_red1 = np.array([10,255,255])

#lower_red2 = np.array([160,100,100])
#upper_red2 = np.array([180,255,255])
lower_red1 = np.array([30, 150, 50])
upper_red1 = np.array([255, 255, 180])
#l = np.array([17, 15, 100])
#u = np.array([50, 56, 200])

cm = cv2.VideoCapture(0)
mouseLoc_1 = np.array((0, 0))
alpha = 0.85
press = 0
cd = c = 0
Пример #21
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/3/18 11:33
# @Author  : ZhangChaowei
from pynput.mouse import Controller, Button
mouse = Controller()
# 获取当前鼠标位置
print(f'当前鼠标的位置是:{mouse.position}')
# 设置鼠标位置
mouse.position = (10, 20)
print(f'鼠标移动到的位置是:{mouse.position}')
# 使用相对位置,移动当前鼠标
mouse.move(5, -5)
print(f'鼠标移动到的位置是:{mouse.position}')
# 按下鼠标左键,释放鼠标左键
mouse.press(Button.left)
mouse.release(Button.left)
# 向下滚动2格
mouse.scroll(0, 2)

Пример #22
0
def controlKeyboard():
    Keyboard = Controller()
    Keyboard.type("i am freeking awesome")
Пример #23
0
# Examples:
#    $ ./python/demos/demo_pyaudio.py
#    $ ./python/demos/demo_pyaudio.py /tmp/recording.wav

import pyaudio
import sys
import numpy as np
import aubio
from pynput.keyboard import Key, Controller
from pynput.mouse import Button, Controller as MouseController
import time
import keypress
import window

keyboard = Controller()
mouse = MouseController()

#pitches
rightClick = 45
leftClick = 50
A = 57
B = 59  #a
C = 60  #w
D = 62  #s
E = 64  #d
mmm = 72

F2 = 65
G2 = 67
A2 = 69
B2 = 71
Пример #24
0
import cv2
import numpy as np
from pynput.mouse import Button, Controller
import wx

mouse = Controller()

app = wx.App(False)
(sx, sy) = wx.GetDisplaySize()
(camx, camy) = (320, 240)
cap = cv2.VideoCapture(0)
cap.set(3, camx)
cap.set(4, camy)

#range for HSV (green color)
lower_g = np.array([33, 70, 30])
upper_g = np.array([102, 255, 255])

#Kerenel
kernelOpen = np.ones((5, 5))
kernelClose = np.ones((20, 20))

mLocOld = np.array([0, 0])
mouseLoc = np.array([0, 0])

DampingFactor = 2  #Damping factor must be greater than 1

isPressed = 0
openx, openy, openw, openh = (0, 0, 0, 0)

while True:
Пример #25
0
from logging import basicConfig, info, INFO
from random import randrange
from sys import stdout
from time import sleep

from pynput.mouse import Controller

MIN, MAX = -50, 50
MOUSE = Controller()


def flicka():
    runs = randrange(5, 50)
    info("Running '%d' times:" % runs)

    for i in range(runs):
        x, y = randrange(MIN, MAX), randrange(MIN, MAX)
        delay = randrange(0, 100) / 1000
        info("Position x='%d' y='%d'." % (x, y))
        info("Delay '%f' seconds." % delay)

        MOUSE.move(x, y)
        sleep(delay)


def service():
    basicConfig(stream=stdout, level=INFO)
    try:
        while True:
            flicka()
 def __init__(self):
     self.mouse = MouseController()
     msg = "Hello World"
     print(msg)
Пример #27
0
client_sock, address = server_sock.accept()
print "Accepted connection from ", address

while True:
    try:
        data = client_sock.recv(64)
        if data != "":
            # print(addr[0])
            time.sleep(0.0145)
            datas = []
            datas = data.split("/")

            # if mouse
            if (datas[0] == "mouse"):
                from pynput.mouse import Button, Controller
                mouse = Controller()
                if (datas[1] == "left"):
                    mouse.press(Button.left)
                    mouse.release(Button.left)
                elif (datas[1] == "right"):
                    mouse.press(Button.right)
                    mouse.release(Button.right)
                elif (datas[1] == "scroll"):
                    print(datas[2])
                    mouse.scroll(0, int(datas[2]))
                else:
                    mouseX, mouseY = (mouse.position)
                    mouse.position = (mouseX + (int(datas[1]) / 10),
                                      (mouseY + int(datas[2]) / 10))
            else:
                if (datas[0] == "keyboard"):
Пример #28
0
def autoMouse():
    mouse = Controller()

    app = wx.App(False)
    (sx, sy) = wx.GetDisplaySize()
    (camx, camy) = (250, 250)
    cam = cv2.VideoCapture(0)
    cam.set(3, camx)
    cam.set(4, camy)
    lowerBound = np.array([33, 80, 40])
    upperBound = np.array([102, 255, 255])
    kernelOpen = np.ones((5, 5))
    kernelClose = np.ones((20, 20))

    mLoc01d = np.array([0, 0])
    mouseLoc = np.array([0, 0])
    DampingFactor = 2  # should more than 1

    pinchFlag = 0
    openx, openy, openw, openh = (0, 0, 0, 0)

    # mouseLoc =mLoc01d+(targetLoc-mLoc01d)/DampingFactor

    while True:
        ret, img = cam.read()
        # img = cv2.resize(img, (340, 220))

        # convert BGR to HSV
        imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
        # create the mask
        mask = cv2.inRange(imgHSV, lowerBound, upperBound)
        # noise removal
        maskOpen = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernelOpen)
        maskClose = cv2.morphologyEx(maskOpen, cv2.MORPH_CLOSE, kernelClose)
        maskFinal = maskClose
        conts, h = cv2.findContours(maskFinal.copy(), cv2.RETR_EXTERNAL,
                                    cv2.CHAIN_APPROX_NONE)

        if (len(conts) == 2):
            if (pinchFlag == 1):
                pinchFlag = 0
                mouse.release(Button.left)
            mouse.release(Button.left)
            x1, y1, w1, h1 = cv2.boundingRect(conts[0])
            x2, y2, w2, h2 = cv2.boundingRect(conts[1])
            cv2.rectangle(img, (x1, y1), (x1 + w1, y1 + h1), (255, 0, 0), 2)
            cv2.rectangle(img, (x2, y2), (x2 + w2, y2 + h2), (255, 0, 0), 2)
            cx1 = int(x1 + w1 / 2)
            cy1 = int(y1 + h1 / 2)
            cx2 = int(x2 + w2 / 2)
            cy2 = int(y2 + h2 / 2)
            cx = int((cx1 + cx2) / 2)
            cy = int((cy1 + cy2) / 2)
            cv2.line(img, (cx1, cy1), (cx2, cy2), (255, 0, 0), 2)
            cv2.circle(img, (cx, cy), 2, (0, 0, 255), 2)
            mouseLoc = mLoc01d + ((cx, cy) - mLoc01d) / DampingFactor
            mouse.position = (sx - (mouseLoc[0] * sx / camx),
                              mouseLoc[1] * sy / camy)
            while mouse.position != (sx - (mouseLoc[0] * sx / camx),
                                     mouseLoc[1] * sy / camy):
                break
            mLoc01d = mouseLoc
            openx, openy, openw, openh = cv2.boundingRect(
                np.array([[x1, y1], [x1 + w1, y1 + h1], [x2, y2],
                          [x2 + w2, y2 + h2]]))
            # cv2.rectangle(img, (openx,openy), (openx+openw, openy+openh), (255, 0, 0), 2)

        elif (len(conts) == 1):
            x, y, w, h = cv2.boundingRect(conts[0])
            if (pinchFlag == 0):
                if (abs((w * h - openw * openh) * 100 / (w * h)) < 20):
                    pinchFlag = 1
                    mouse.click(Button.left, 2)
                    openx, openy, openw, openh = (0, 0, 0, 0)
            cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
            cx = int(x + w / 2)
            cy = int(y + h / 2)
            cv2.circle(img, (cx, cy), int((w + h) / 4), (0, 0, 255), 2)
            mouseLoc = mLoc01d + ((cx, cy) - mLoc01d) / DampingFactor
            mouse.position = (sx - (mouseLoc[0] * sx / camx),
                              mouseLoc[1] * sy / camy)
            while mouse.position != (sx - (mouseLoc[0] * sx / camx),
                                     mouseLoc[1] * sy / camy):
                break
            mLoc01d = mouseLoc

        # cv2.imshow("maskClose", maskClose)
        # cv2.imshow("maskOpen", maskOpen)
        # cv2.imshow("mask", mask)
        cv2.imshow("cam", img)
        cv2.waitKey(1)

    video_capture.release()
    cv2.destroyAllWindows()
Пример #29
0
from pynput.mouse import Button, Controller
import time

mouse = Controller()

while 1 == 1:
    time.sleep(0.5)
    mouse.move(1, 0)
Пример #30
0
import cv2
import numpy as np
from pynput.mouse import Button, Controller
import wx
from random import randint
from matplotlib import pyplot as plt

mouse = Controller()
app = wx.App(False)
(sx,sy) = wx.GetDisplaySize()
(camx,camy) = (240,320)
cam = cv2.VideoCapture(0)
cam.set(3,camx)
cam.set(4,camy)
mLocOld = np.array([0,0])
mouseLoc =  np.array([0,0])
df = 2
tile_s = 60
S_s_d = 58000
over = 5


def create_mask(imgHSV,lower_bound,upper_bound,kernelOpen,kernelClose,eraser = 0):
    h = imgHSV.shape[0]
    mask = cv2.inRange(imgHSV,lower_bound,upper_bound)
    maskOpen = cv2.morphologyEx(mask,cv2.MORPH_OPEN,kernelOpen)
    maskClose = cv2.morphologyEx(maskOpen,cv2.MORPH_CLOSE,kernelClose)
    if eraser == True:
        for x in range(h):
            if x<64 or x>219:
                maskClose[x] = np.zeros(maskClose[x].shape[0])
Пример #31
0
import numpy as np
import cv2
import os
from datetime import datetime
from pynput.mouse import Button, Controller

# za kontrolu misa
mouse = Controller()

# inicijalizacija kamere
cap = cv2.VideoCapture(0)

# ucitavanje haar cascade za lice
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

# faza 0 dok se ne odredi koza - faza 1 pracenje
faze = 0
# timer za prelazak iz faza
last_detected = datetime.now()
# promenljiva koja pamti poslednju detekciju / detekcija se ne menja dok se bar ne drzi 0.2 sekunde
old_detection = 0
new_detection = 0

# inicijalna pozicija sa koje se uzima boja koze i odakle krece pracenje oko nje se formira 
handCenter = (500, 225)
palm_radius_history = []  # not implemented
avg_color_history = []  #implemented

# da li da doda racunanje maske preko histograma
hist = False
hist_mask = []
Пример #32
0
from pynput import keyboard
from pynput.mouse import Button, Controller
import threading
import time
import os
os.system('mode con: cols=120 lines=51')
os.system('cls')

mouse = Controller()

print(
    '''::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::::::::!%&$%%%%*::::$&#BBBBBBBBBBS#&%::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::::@BBB#&&&&&&&&&BBBBBB&&&&&&&&&&&&&&##BBB$::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::::BB#&&&&&&&&&&&&&&&&B&&&&&&&&&&&&&&&&&&&&&BB&::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::::BB&&&&&&&&&&&&&&&&&&&&BS&&&&&&&&&&&&&&&&&&&&#B&:::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::::@B&&&&&&&&&&&&&&&&&&&&&&&B#&&&&&&&&&&&&&&&&&&&&&BB::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:::::::::::::*B&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&#B&:::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::::BB&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&B&%:::::::::::::::::::::::::::::::::::::::::::::::::::::
::::::::::@BB&&&&&&&&&&&&#BB###SBBBB#&&&&&&&&&&&&&#BB#&&&&SBBBBBBBBBBBBB::::::::::::::::::::::::::::::::::::::::::::::::
::::::BBBSBB&&&&&&&&B&&&&&&&&&&#BBBBBBBBBBB&&&&BBSBBBBB&&&&&&&&&&&&&&&&&&BBB!:::::::::::::::::::::::::::::::::::::::::::
::::&B#&&&&&&&&&&&#&&&&&&&BBBBB#&&&&&&&&#BBSBBBBB#&&&&&&&&&&&&&&&&&&&&&&SBBBBB!:::::::::::::::::::::::::::::::::::::::::
:::@B&&&&&&&&&&&&&&&&&&BB#&&&&&&&&&&&&&&&&&&BB&B&&&&&&&&&&&&#&&&#BBB#SBBBBBBBBBS::::::::::::::::::::::::::::::::::::::::
::%B&&&&&&&&&&&&&&&&&&S&&&&&&&&&&&&&&&&&&SSSBBB&&&&&&&&&B#&BB#&&BBBBSSBB&#BBBSB&BB::::::::::::::::::::::::::::::::::::::
:%B&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BBBBB#&&&&&&&&&BBBS&&&&&&#BBB&&&SBBBBBBB&&@#SB&&#B%:::::::::::::::::::::::::::::::::::::
#B&&&&&&&&&&&&&&&&&&&&&&&&SBBBB&&&&&&BBBBBBBSSSB&#S&&&&&&&&#BBBBBBBBBBBBBBBB!!S!B&@:::::::::::::::::::::::::::::::::::::
B&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&BBBBBBBBBBBB&&&&&&&&&&&&&BBBB#BBB!$BB#.BBBB::::::BB::::::::::::::::::::::::::::::::::::::
&&&&&&&&&&&&&&&&&&&&&&&&&&&BBBBBBBBBBBB!*BBB#:::::@@@BS%:::::BBBBBBB..:BBBB::::::BB:::::::::::::::::::::::::::::::::::::
&&&&&&&&&&&&&&&&&&&BBBBBBBB&&&&BBBBBBB$..&BBB!:::::::::B:::::BBBBBBBBBBBBBB:::::%B::::::::::::::::::::::::::::::::::::::
Пример #33
0
#-*-coding:utf-8-*-

from pynput.mouse import Button, Controller
import time
import win32clipboard as w 
import win32con 
from controlKeyboard import doKeyboard,altUp,down,enter,LaoGongTV,ctrlTab,ctrlW,space,ctrlV,keyFill,ctrlShiftI

mouse = Controller()

def setText(aString):  
    w.OpenClipboard()  
    w.EmptyClipboard()  
    w.SetClipboardData(win32con.CF_UNICODETEXT, aString)  
    w.CloseClipboard() 

for i in range(100):
	
	mouse.position = (1702,1006)
	mouse.click(Button.left,1)
	time.sleep(0.5)
	codes = '''
	document.getElementsByClassName("p-txt")[%s].innerText;
	''' % str(i)
	setText(codes)
	ctrlV()
	# time.sleep(2)
	enter()