It's time to share with you my program which allows you disable/enable proxy on from your web browser.
Program was wrote by me in Python. I would like to show you my code and process how to create exe file from .py file.
Program disable/enable proxy using MS Windows registry for Windows 7.
It is working on Windows systems (Windows 7 only).
It is compatibile with IE 11. Chrome also works but proces when registy synchronize with web browser is slower than when you use IE.
There is button with host info like: hostname, IP. Button quit for fast close app.
I will try to explain code in python.
Short analyze source code:
Loading library os for operation system commands, tkinter for GUI, tkinter.messagebox for message windows, socket for hostname and IP, threading for enable using thradings.
import os import tkinter import tkinter.messagebox import socket import threading
Here is definition for registry modification and pinging IP 8.8.8.8. If ping is successful than variable "response" holding 0 else 1. Message is a simple message box. I start ping only one ICMP echo request.
def Pingowanie(): os.system(r'REG ADD "HKEY_CURRENT_USER\Software\Microsoft\
Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f')
response = os.system("ping 8.8.8.8 -n 1")
if response == 0: message = tkinter.messagebox.showinfo("Sukces", "Proxy wyłączone! - Uruchom ponownie Internet Explorer")
else: message = tkinter.messagebox.showinfo("Problem", "Spróbuj ponownie lub sprawdż ustawienia firewalla")
Here is one thread for using independent ping to avoid program freeze when you click button:
def Proxy_disable(): threading.Thread(target=Pingowanie).start()
Here is building GUI and buttons i think that this is easy to understand.
top.resizable - is blocking window for resizable
top.geometry - is for set persistant size of window
przycisk_1.pack() - install button on form.
top.mainloop() - run form
def Okno(): top = tkinter.Tk() top.resizable(width=False, height=False)
top.geometry('{}x{}'.format((230),(140)))
top.title("Version 1.1_2018")
przycisk_1 = tkinter.Button(top, justify="right", text="ENABLE_PROXY", command=Win_command_en, width="50") przycisk_2 = tkinter.Button(top, justify="right", text="DISABLE_PROXY", fg="red", command=Proxy_disable, width="50") przycisk_3 = tkinter.Button(top, justify="right", text="HOST INFO", fg="blue", command=Host_info, width="50")
przycisk_4 = tkinter.Button(top, justify="right", text="Quit", command=top.destroy, width="50") przycisk_1.pack()
przycisk_2.pack()
przycisk_3.pack()
przycisk_4.pack()
label = tkinter.Label(top, text="Made by Kiloparówek \n \n Compatibile with Microsoft IE 11") label.pack() top.mainloop()
For compile all sorurces and librarys in one exe file and replace icon for your own you must use this command:
I hope it is informative for you. If you have any question please comment.
Here you have exe file and source code.
No comments:
Post a Comment