Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, name):
self._name = name
self.keyboard = Controller()
import sys
import threading
import pynput.keyboard
from six.moves import input
from . import EventTest
class KeyboardControllerTest(EventTest):
NOTIFICATION = (
'This test case is non-interactive, so you must not use the '
'keyboard.\n'
'You must, however, keep this window focused.')
CONTROLLER_CLASS = pynput.keyboard.Controller
LISTENER_CLASS = pynput.keyboard.Listener
def decode(self, string):
"""Decodes a string read from ``stdin``.
:param str string: The string to decode.
"""
if sys.version_info.major >= 3:
yield string
else:
for encoding in (
'utf-8',
locale.getpreferredencoding(),
sys.stdin.encoding):
if encoding:
try:
def __init__(self, addr=DEFAULT_ADDR):
self.reactor = None
self.addr = addr
self.running = False
self.root = None
self.keyboard = Controller()
def StartCopy():
import sys
keyboard = Controller()
with keyboard.pressed(Key.ctrl):
keyboard.press('c')
keyboard.release('c')
app = QtGui.QApplication(sys.argv)
window = DictionBox()
mouse = pymouse.PyMouse()
x,y=mouse.position()
if x - 130 >=0:
x=x-139
y=y+20
window.move(x,y)
window.show()
app.quit()
def _key_change_callback(deck_id: str, _deck: StreamDeck.StreamDeck, key: int, state: bool) -> None:
if state:
keyboard = Controller()
page = get_page(deck_id)
command = get_button_command(deck_id, page, key)
if command:
Popen(command.split(" "))
keys = get_button_keys(deck_id, page, key)
if keys:
keys = keys.strip().replace(" ", "")
for section in keys.split(","):
for key_name in section.split("+"):
keyboard.press(getattr(Key, key_name.lower(), key_name))
for key_name in section.split("+"):
keyboard.release(getattr(Key, key_name.lower(), key_name))
write = get_button_write(deck_id, page, key)
def StartCopy():
import sys
keyboard = Controller()
with keyboard.pressed(Key.ctrl):
keyboard.press('c')
keyboard.release('c')
app=QtGui.QApplication(sys.argv)
window=DictionBox()
window.show()
app.quit()
app.exec_()
while True:
keylistener = KeyListener()
keylistener.addKeyListener("L_CTRL+q", StartCopy)
handle = Handler(keylistener)
def load_instructions(f):
keyboard = Controller()
sleep(1)
data_file = open(f)
for line in data_file.readlines():
keyboard.type(line + "\n")
sleep(0.2)
self.window.hide()
else:
self.window.showMinimized()
self._macos_focus_workaround()
if self.output_queue:
time.sleep(0.5)
while True:
try:
output = self.output_queue.pop()
except IndexError:
break
keyboard_device = keyboard.Controller()
keyboard_device.type(output)
b_fc2 = bias_variable([500])
h_fc2 = tf.nn.sigmoid(tf.matmul(h_fc1, W_fc2) + b_fc2)
W_fc3 = weight_variable([500, 1])
b_fc3 = bias_variable([1])
y_out = tf.nn.sigmoid(tf.matmul(h_fc2, W_fc3) + b_fc3)
cross_entropy = tf.losses.mean_squared_error(exp_y, y_out)
train_step = tf.train.AdamOptimizer(5e-5).minimize(cross_entropy)
correct_prediction = tf.equal(tf.round(y_out), exp_y)
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
output = tf.round(y_out)
saver = tf.train.Saver()
keyboard = Controller()
def train():
with tf.Session() as sess:
print 'Gathering Data...'
data = []
labels = []
s = time.time()
for n in range(1, 11):
for d in range(0, len(listdir('GamePics/game{}/'.format(n)))):
im = cv2.imread('GamePics/game{}/'.format(n) + str(d) + '.png', 0)
im = cv2.resize(im, (40, 10), interpolation=cv2.INTER_AREA)
im = im / 255.0
data.append(im)
nl = np.load('labels/game{}.npy'.format(n))
labels = np.append(labels, nl)
import cv2
import logging
import time
import numpy as np
import pywintypes
import pytesseract
from fishy.engine.IEngine import IEngine
from fishy.engine.window import Window
from pynput import keyboard, mouse
from fishy.helper import Config, hotkey
mse = mouse.Controller()
kb = keyboard.Controller()
rotate_by = 30
def sign(x):
return -1 if x < 0 else 1
def get_crop_coods(window):
Window.loop()
img = window.get_capture()
img = cv2.inRange(img, 0, 1)
Window.loop_end()
cnt, h = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)