Update 'Server/serversend- Mouse'
This commit is contained in:
58
Server/serversend- Mouse
Normal file
58
Server/serversend- Mouse
Normal file
@ -0,0 +1,58 @@
|
||||
import socket
|
||||
import os
|
||||
from pynput import keyboard
|
||||
from pynput.mouse import Button, Controller
|
||||
from pynput import mouse
|
||||
|
||||
MOUSE = Controller()
|
||||
dataToSend = ""
|
||||
|
||||
|
||||
SEPARATOR = "<SEPARATOR>"
|
||||
BUFFER_SIZE = 128 # send 4096 bytes each time step
|
||||
|
||||
host = "4.tcp.ngrok.io"
|
||||
# the ip address or hostname of the server, the receiver
|
||||
# the port, let's use 10002
|
||||
port = 17058
|
||||
# the name of file we want to send, make sure it exists
|
||||
# get the file size
|
||||
|
||||
|
||||
|
||||
# create the client socket
|
||||
s = socket.socket()
|
||||
print(f"[+] Connecting to {host}:{port}")
|
||||
s.connect((host, port))
|
||||
print("[+] Connected.")
|
||||
# send the filename and filesize
|
||||
#s.send(f"{filename}{SEPARATOR}{filesize}".encode())
|
||||
|
||||
|
||||
|
||||
##############################################################################
|
||||
|
||||
|
||||
def on_click(x, y, button, pressed):
|
||||
|
||||
if button == Button.left:
|
||||
dataToSend = ("L")
|
||||
else:
|
||||
dataToSend = ("R")
|
||||
|
||||
dataToSend = dataToSend + str(x) + "," + str(y)
|
||||
dataToSendBytes = dataToSend.encode()
|
||||
s.sendall(dataToSendBytes)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
with mouse.Listener(
|
||||
|
||||
on_click = on_click) as listener:
|
||||
|
||||
listener.join()
|
||||
|
||||
|
||||
###############################################################################
|
Reference in New Issue
Block a user