The problem back

In the development requirements, I need to use TK package applets to configure proxy services. At this time, I have the following architecture in mind:

  1. The TK applet requests/modifies corresponding PAC files
  2. The back-end service returns/modifies the corresponding PAC file and saves it
  3. The TK applet modifies the request API to the computer host configuration item

For related PAC documents, click here.

At this point you need to build the following code:

  • Back-end PAC file management/return server
  • TK applet
    • PAC black and white list modification/display function
    • Modify the local computer host logic code
    • Proxy Service

You’ve done a lot of good when you can write and save PAC files using TK, but this blog post focuses on the automation issue:

  • Automatically recognize and save the latest changes
  • The proxy service is automatically stopped
  • Automatically modify Windows PC PAC configuration

Windows shell minutes

Place this command line data in the summary information bar:

  • Modify PAC address in Windows native configuration (willhttp://medusasorcerer.comReplace it with your PAC file address) :
    reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /t REG_DWORF /d "http://medusasorcerer.com" /f
    Copy the code
  • Clear (on computers, turn off) the PAC agent configuration
    reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v AutoConfigURL /f
    Copy the code

Code logic summary

  • TK programs need to override the inherited base classTkinter, need to call the method to close the programdestroy()To disable PAC configuration
  • If the thread Hash is used to determine non-equivalence, the PAC proxy content needs to be modified. In this case, the service configuration of the PC should be closed first, and then the proxy address should be re-entered to be effective
  • When using the TK applet, the PAC address obtained is first entered into the host agent configuration

Afterword.

The corresponding Windows interface in PAC registry modification is: