import socket import os import shutil import pillow from tkinter import * from tkinter import messagebox from tkinter.filedialog import asksaveasfilename from pillow import ImageTk, Image PORT = 5050 BUFSIZ = 2048 client = socket.socket(socket.AF_INET, socket.SOCK_STREAM) window=Tk() def create_window(): window_takePic=Toplevel(window) window_takePic.geometry("400x400") window_takePic.title("Screenshot") img = ImageTk.PhotoImage(Image.open("pic_ex.jpg")) panel = tk.Label(window_takePic, image = img) panel.pack(side = "bottom", fill = "both", expand = "yes") def connect_1(): #global client while True: IP = txtfld.get() client_addr = (IP, PORT) try: client.connect(client_addr) messagebox.showinfo("Info","Connected!!") break except: messagebox.showinfo("Info","Error connecting to server") break def receivePicture(client): filetodown = open("pic2.jpg", "wb") while True: data = client.recv(1024) if not data: break filetodown.write(data) filetodown.close() def savePicPath(): # day la luu file vo tep save_path = asksaveasfilename() shutil.copyfile("pic3.jpg",save_path) def receivePic(): msg = "takepicture" client.send(bytes(msg,"utf-8")) receivePicture(client) print("nhap lenh tiep:") msg = input() #os.remove() btn_5=Button(window,text="Screenshot",fg='black',height=3,width=15, command = receivePic) btn_5.place(x=155,y=140) txtfld=Entry(window,bd=2,width=41) txtfld.place(x=15, y=10) btn=Button(window, text="Connect", fg='black',command=connect_1,width=10) btn.place(x=280, y=10) btn_1=Button(window,text="Exit",fg='black',command=quit,height=5,width=10) btn_1.place(x=280,y=200) btn_2=Button(window,text="Process\n Running",fg='black',height=15,width=10) btn_2.place(x=15,y=50) btn_3=Button(window,text="App Running",fg='black',height=5,width=22) btn_3.place(x=105,y=50) btn_4=Button(window,text="Shut\ndown",fg='black',height=3,width=5) btn_4.place(x=105,y=140) btn_5=Button(window,text="Screenshot",fg='black',height=3,width=15,command =create_window ) btn_5.place(x=155,y=140) btn_6=Button(window,text="Registry Fix",fg='black',height=5,width=22) btn_6.place(x=105,y=200) btn_7=Button(window,text="Key\nstroke",fg='black',height=9,width=10) btn_7.place(x=280,y=50) window.title('IP Connect') window.geometry("370x300") window.mainloop()