Thanks to those who helped me, I want to share this and hope this comes in useful for you.
I wrote a simple code and put it into this path
Script Editor.app under
Preferences tab I enabled
Show Script menu in menubar
set socksStatus to do shell script "networksetup -getsocksfirewallproxy Wi-fi | grep Enabled"
if (offset of "Yes" in socksStatus) = 0 then
do shell script "networksetup -setsocksfirewallproxystate Wi-fi On"
display notification "Proxy Enabled !"
do shell script "networksetup -setsocksfirewallproxystate Wi-fi Off"
display notification "Socks disabled"
as you can see, when you run the code it enable the proxy and if you run it again it will be disable.
Have a great day !