Add 'Serverserversend - all.py'
This commit is contained in:
73
Serverserversend - all.py
Normal file
73
Serverserversend - all.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
import socket
|
||||||
|
import os
|
||||||
|
from multiprocessing import Process
|
||||||
|
from tkinter import *
|
||||||
|
from pynput import keyboard
|
||||||
|
from pynput.mouse import Button, Controller
|
||||||
|
from pynput import mouse
|
||||||
|
# ipFile = open("IP.txt")
|
||||||
|
# IP = ipFile.read()
|
||||||
|
# ipFile.close()
|
||||||
|
import threading # https://docs.python.org/3/library/threading.html
|
||||||
|
import queue #
|
||||||
|
|
||||||
|
|
||||||
|
# window = Tk()
|
||||||
|
# label = Label(window, text= 'What is the IP')
|
||||||
|
# entry = Entry(window, width=200)
|
||||||
|
# entry.insert(END, IP)
|
||||||
|
# label.pack()
|
||||||
|
# entry.pack()
|
||||||
|
MOUSE = Controller()
|
||||||
|
dataToSend = ""
|
||||||
|
|
||||||
|
SEPARATOR = "<SEPARATOR>"
|
||||||
|
BUFFER_SIZE = 128 # send 4096 bytes each time step
|
||||||
|
|
||||||
|
host = "safe-mask.auto.playit.gg"
|
||||||
|
# the ip address or hostname of the server, the receiver
|
||||||
|
# the port, let's use 5001
|
||||||
|
port = 56926
|
||||||
|
|
||||||
|
# create the client socket
|
||||||
|
s = socket.socket()
|
||||||
|
print(f"[+] Connecting to {host}:{port}")
|
||||||
|
s.connect((host, port))
|
||||||
|
print("[+] Connected.")
|
||||||
|
|
||||||
|
|
||||||
|
# -----------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
def on_press(key):
|
||||||
|
dataToSend = "KP"
|
||||||
|
dataToSend = dataToSend + (('{}'.format(key)).replace("'", ""))
|
||||||
|
dataToSendBytes = dataToSend.encode()
|
||||||
|
s.sendall(dataToSendBytes)
|
||||||
|
|
||||||
|
|
||||||
|
def on_release(key):
|
||||||
|
dataToSend = "KR"
|
||||||
|
dataToSend = dataToSend + (('{}'.format(key)).replace("'", ""))
|
||||||
|
dataToSendBytes = dataToSend.encode()
|
||||||
|
s.sendall(dataToSendBytes)
|
||||||
|
|
||||||
|
|
||||||
|
def on_click(x, y, button, pressed):
|
||||||
|
if button == Button.left:
|
||||||
|
dataToSend = ("ML")
|
||||||
|
else:
|
||||||
|
dataToSend = ("MR")
|
||||||
|
|
||||||
|
dataToSend = dataToSend + str(x) + "," + str(y)
|
||||||
|
dataToSendBytes = dataToSend.encode()
|
||||||
|
s.sendall(dataToSendBytes)
|
||||||
|
|
||||||
|
|
||||||
|
def mouseThread():
|
||||||
|
with mouse.Listener(on_click=on_click) as mouseListener:
|
||||||
|
mouseListener.join()
|
||||||
|
threading.Thread(target=mouseThread).start()
|
||||||
|
|
||||||
|
with keyboard.Listener(on_press=on_press, on_release=on_release) as keyListener:
|
||||||
|
keyListener.join()
|
Reference in New Issue
Block a user