Add files via upload

This commit is contained in:
somen das 2022-12-09 21:26:58 +05:30 committed by GitHub
parent 3108d05d03
commit 71a36627f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 215 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# sync_clipboard
This program is for syncing two computers clipboards. By this they can copy paste data from each other this works under same Wi-Fi
So to work with this you need python, beautifulsoup4,requests module to be installed.
Now after all installation,
Open the sync_clipboard_to_pc_gui.py file in that computer from which you want the copied data.
By doing this you will see a tkinter window will open with start button click on that start button.now you are ready to go.
You will see one web address in that tkinter window you have to type it manually in that computer where you want the clipboard data.
To do so, now open the sync_clipboard_from_pc_or_mobile_gui.py file on another computer in the same network.
This will open a window where you have a textbox you have to type the web address here as it is on the other computer or phone.
Use it you will automatically learned how it works.

View File

@ -0,0 +1,93 @@
#import asyncio
from tkinter.filedialog import askopenfile
from tkinter.filedialog import asksaveasfile
from time import sleep
import tkinter
from tkinter import filedialog
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import os,sys
#import re
from tkinter import *
import subprocess
import threading
import requests
from bs4 import BeautifulSoup as bs
import time
from bottle import route, run
#import pyperclip 'http://192.168.43.1:8080/'
def sync():
url=entry.get()
#url='http://192.168.43.147:8080/'
entry.delete(0, tkinter.END)
entry.insert(0,"connected!!! syncing to %s"%url )
while True:
#try:
global stop
c=requests.get(url)
if c.status_code==200:
print("connected!!! syncing to %s"%url,end="\r")
else:
print('tell your friend to run sync_clipboard_to_pc.py in mobile :)')
break
pr=c.text
soup=bs(pr,'html.parser')
mobile_text=soup.find('h1')
hs=mobile_text.text
pk=win.clipboard_get()
if pk not in hs:
print('i think you copied from your computer so i stop for 5 sec paste it in 2 sec')
time.sleep(5)
win.clipboard_clear()
win.clipboard_append(hs)
if stop==1:
print("i am stopped.....")
break
#except:
#print('please tell your friend to run sync_clipboard_to_pc.py in mobile :)')
#break
def stop():
# Assign global variable and set value to stop
global stop
entry.delete(0, tkinter.END)
entry.insert(0, 'i am stoped......')
stop = 1
def exiit():
win.destroy()
def start_sync(event):
global start_thread
global stop
stop=0
start_thread = threading.Thread(target=sync)
start_thread.deamon=True
start_thread.start()
win=Tk()
win.geometry("400x200")
laable=ttk.Button(win,text='start syncing',command=lambda :start_sync(None))
laable.pack()
stop = ttk.Button(win, text="Stop syncing",command=stop)
stop.pack()
entryText = tkinter.StringVar()
entry = ttk.Entry( win, textvariable=entryText,width=50 )
entry.pack()
button = ttk.Button(text = "Click and Quit", command = exiit)
button.pack()
win.mainloop()
os._exit(0)

View File

@ -0,0 +1,112 @@
#import asyncio
from tkinter.filedialog import askopenfile
from tkinter.filedialog import asksaveasfile
from time import sleep
import tkinter
from tkinter import filedialog
from tkinter import *
from tkinter import ttk
from tkinter import messagebox
import os,sys
#import re
from tkinter import *
import subprocess
import threading
from bottle import route, run
import os,subprocess,re
#import pyperclip
def sync():
laable.configure(text="started")
laable.configure(command='')
d=''
if os.name =='linux':
#do
df=subprocess.getoutput('ifconfig')
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
for i in ip:
if i.startswith('192'):
d+=i
break
elif os.name =='posix':
df=subprocess.getoutput('ifconfig')
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
for i in ip:
if i.startswith('192'):
d+=i
break
elif os.name=='darwin':
#do
df=subprocess.getoutput('ifconfig')
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
for i in ip:
if i.startswith('192'):
d+=i
break
elif os.name=='nt':
#do
df=subprocess.getoutput('ipconfig')
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
for i in ip:
if i.startswith('192'):
d+=i
break
@route('/')
def hello():
#g=pyperclip.paste()
return '''<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="10">
</head>
<body>
<h1 color='blue'>%s</h1>
</body>
</html>
'''%win.clipboard_get()
#os.system('python -m http.server 8080')
entryText = tkinter.StringVar()
entry.delete(0, tkinter.END)
entry.insert(0, 'running on >> http://%s/8080/'%d)
#entryText.set('running on >> http://%s/8080/'%d)
run(host=d, port=8080, debug=True)
def start_sync(event):
global start_thread
start_thread = threading.Thread(target=sync)
start_thread.deamon=True
start_thread.start()
def exiit():
win.destroy()
win=Tk()
win.geometry("400x200")
laable=ttk.Button(win,text='start syncing',command=lambda :start_sync(None))
laable.pack()
entryText = tkinter.StringVar()
entry = ttk.Entry( win, textvariable=entryText,width=50 ,state="rw")
entry.pack()
button = ttk.Button(text = "Click and Quit", command = exiit)
button.pack()
win.mainloop()
os._exit(0)