Skip to content

Commit 71a3662

Browse files
authored
Add files via upload
1 parent 3108d05 commit 71a3662

File tree

3 files changed

+215
-0
lines changed

3 files changed

+215
-0
lines changed

scripts/sync_clipboard-main/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# sync_clipboard
2+
This program is for syncing two computers clipboards. By this they can copy paste data from each other this works under same Wi-Fi
3+
So to work with this you need python, beautifulsoup4,requests module to be installed.
4+
Now after all installation,
5+
Open the sync_clipboard_to_pc_gui.py file in that computer from which you want the copied data.
6+
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.
7+
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.
8+
To do so, now open the sync_clipboard_from_pc_or_mobile_gui.py file on another computer in the same network.
9+
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.
10+
Use it you will automatically learned how it works.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
#import asyncio
2+
from tkinter.filedialog import askopenfile
3+
from tkinter.filedialog import asksaveasfile
4+
from time import sleep
5+
import tkinter
6+
from tkinter import filedialog
7+
from tkinter import *
8+
from tkinter import ttk
9+
from tkinter import messagebox
10+
import os,sys
11+
#import re
12+
from tkinter import *
13+
import subprocess
14+
import threading
15+
import requests
16+
from bs4 import BeautifulSoup as bs
17+
import time
18+
from bottle import route, run
19+
20+
#import pyperclip 'http://192.168.43.1:8080/'
21+
def sync():
22+
23+
url=entry.get()
24+
#url='http://192.168.43.147:8080/'
25+
entry.delete(0, tkinter.END)
26+
entry.insert(0,"connected!!! syncing to %s"%url )
27+
while True:
28+
#try:
29+
global stop
30+
31+
32+
c=requests.get(url)
33+
if c.status_code==200:
34+
print("connected!!! syncing to %s"%url,end="\r")
35+
36+
else:
37+
print('tell your friend to run sync_clipboard_to_pc.py in mobile :)')
38+
break
39+
pr=c.text
40+
soup=bs(pr,'html.parser')
41+
mobile_text=soup.find('h1')
42+
hs=mobile_text.text
43+
44+
pk=win.clipboard_get()
45+
if pk not in hs:
46+
print('i think you copied from your computer so i stop for 5 sec paste it in 2 sec')
47+
time.sleep(5)
48+
win.clipboard_clear()
49+
win.clipboard_append(hs)
50+
if stop==1:
51+
print("i am stopped.....")
52+
break
53+
#except:
54+
#print('please tell your friend to run sync_clipboard_to_pc.py in mobile :)')
55+
#break
56+
57+
58+
59+
60+
61+
62+
def stop():
63+
64+
# Assign global variable and set value to stop
65+
global stop
66+
entry.delete(0, tkinter.END)
67+
entry.insert(0, 'i am stoped......')
68+
stop = 1
69+
def exiit():
70+
win.destroy()
71+
def start_sync(event):
72+
global start_thread
73+
global stop
74+
stop=0
75+
start_thread = threading.Thread(target=sync)
76+
start_thread.deamon=True
77+
start_thread.start()
78+
win=Tk()
79+
win.geometry("400x200")
80+
laable=ttk.Button(win,text='start syncing',command=lambda :start_sync(None))
81+
laable.pack()
82+
83+
stop = ttk.Button(win, text="Stop syncing",command=stop)
84+
stop.pack()
85+
entryText = tkinter.StringVar()
86+
entry = ttk.Entry( win, textvariable=entryText,width=50 )
87+
entry.pack()
88+
89+
button = ttk.Button(text = "Click and Quit", command = exiit)
90+
button.pack()
91+
92+
win.mainloop()
93+
os._exit(0)
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#import asyncio
2+
from tkinter.filedialog import askopenfile
3+
from tkinter.filedialog import asksaveasfile
4+
from time import sleep
5+
import tkinter
6+
from tkinter import filedialog
7+
from tkinter import *
8+
from tkinter import ttk
9+
from tkinter import messagebox
10+
import os,sys
11+
#import re
12+
from tkinter import *
13+
import subprocess
14+
import threading
15+
16+
from bottle import route, run
17+
import os,subprocess,re
18+
#import pyperclip
19+
def sync():
20+
laable.configure(text="started")
21+
laable.configure(command='')
22+
d=''
23+
24+
if os.name =='linux':
25+
26+
#do
27+
df=subprocess.getoutput('ifconfig')
28+
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
29+
for i in ip:
30+
if i.startswith('192'):
31+
d+=i
32+
break
33+
34+
elif os.name =='posix':
35+
36+
df=subprocess.getoutput('ifconfig')
37+
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
38+
for i in ip:
39+
if i.startswith('192'):
40+
d+=i
41+
break
42+
43+
44+
elif os.name=='darwin':
45+
#do
46+
47+
df=subprocess.getoutput('ifconfig')
48+
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
49+
for i in ip:
50+
if i.startswith('192'):
51+
d+=i
52+
break
53+
54+
elif os.name=='nt':
55+
#do
56+
57+
df=subprocess.getoutput('ipconfig')
58+
ip=re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}').findall(df)
59+
for i in ip:
60+
if i.startswith('192'):
61+
d+=i
62+
break
63+
64+
65+
@route('/')
66+
def hello():
67+
#g=pyperclip.paste()
68+
return '''<!DOCTYPE html>
69+
<html>
70+
<head>
71+
<meta http-equiv="refresh" content="10">
72+
</head>
73+
<body>
74+
75+
<h1 color='blue'>%s</h1>
76+
77+
</body>
78+
</html>
79+
80+
'''%win.clipboard_get()
81+
82+
83+
#os.system('python -m http.server 8080')
84+
entryText = tkinter.StringVar()
85+
entry.delete(0, tkinter.END)
86+
entry.insert(0, 'running on >> http://%s/8080/'%d)
87+
#entryText.set('running on >> http://%s/8080/'%d)
88+
run(host=d, port=8080, debug=True)
89+
90+
91+
def start_sync(event):
92+
global start_thread
93+
start_thread = threading.Thread(target=sync)
94+
start_thread.deamon=True
95+
start_thread.start()
96+
def exiit():
97+
win.destroy()
98+
99+
100+
win=Tk()
101+
win.geometry("400x200")
102+
laable=ttk.Button(win,text='start syncing',command=lambda :start_sync(None))
103+
laable.pack()
104+
entryText = tkinter.StringVar()
105+
entry = ttk.Entry( win, textvariable=entryText,width=50 ,state="rw")
106+
entry.pack()
107+
108+
button = ttk.Button(text = "Click and Quit", command = exiit)
109+
button.pack()
110+
111+
win.mainloop()
112+
os._exit(0)

0 commit comments

Comments
 (0)