Sign in to follow this  
Followers 0
Nunos

MsgBox Syntax Help Please

3 posts in this topic

#1 ·  Posted (edited)

I am trying to read a registry key and then based on that information display a Yes/No MsgBox and then call a Function() similar to below.

Your proxy is Enabled would you like to Disable it now? Yes or No

If Yes Function1()

If No Exit Script

Your Proxy is Disabled would you like to Enable it now? Yes or No

If Yes Function2()

If No Exit Script

Dim $sTitle = "IE Proxy is:"
Dim $Proxy = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyEnable")

If $Proxy = 0 Then
 MsgBox(8228,$sTitle, @TAB & "       Disabled" & @CRLF & "     Would you like to Enable it now?")

Func EnableProxyPressed()
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ","127.0.0.1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyoverride", "REG_SZ", "*.local;<local>")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions", "NoBrowserOptions", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel", "ConnectionsTab", "REG_DWORD", "1")
EndFunc   ;==>EnableProxyPressed

ElseIf $Proxy = 1 Then
    MsgBox(8228,$sTitle, @TAB & "       Enabled" & @CRLF & "    Would you like to Disable it now?")

Func DisableProxyPressed()
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions", "NoBrowserOptions", "REG_DWORD", "0")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel", "ConnectionsTab", "REG_DWORD", "0")
EndFunc   ;==>DisableProxyPressed
    
    EndIf

I guess I don't understand how to get the MsgBox button presses maybe I need to do it in a GUI?

Edited by Nunos

Share this post


Link to post
Share on other sites



Maybe this is what you want:

If $Proxy = 0 Then
    If MsgBox(32+4,$sTitle, @TAB & "       Disabled" & @CRLF & "     Would you like to Enable it now?") = 6 Then
        EnableProxyPressed()
    Else
        Exit
    EndIf
Else
    If MsgBox(32+4,$sTitle, @TAB & "       Enabled" & @CRLF & "    Would you like to Disable it now?") = 6 Then
        DisableProxyPressed()
    Else
        Exit
    EndIf
EndIf

 

untested, please test it

Share this post


Link to post
Share on other sites

Thank you that appears to be working I will test it further on a vm or three I will post the completed script below for others.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.8.1
 Author:         Nunos

 Script Function:
    Allows to enable or disable your proxy in Internet Explorer and lockout user from changing.

 Thanks to michaelslamet from the AutoIt Forums for his help. 

#ce ----------------------------------------------------------------------------

Dim $sTitle = "IE Proxy is:"
Dim $Proxy = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings","ProxyEnable")

If $Proxy = 0 Then
    If MsgBox(32+4,$sTitle, @TAB & "       Disabled" & @CRLF & "     Would you like to Enable it now?") = 6 Then
        EnableProxyPressed()
    Else
        Exit
    EndIf
Else
    If MsgBox(32+4,$sTitle, @TAB & "       Enabled" & @CRLF & "    Would you like to Disable it now?") = 6 Then
        DisableProxyPressed()
    Else
        Exit
    EndIf
EndIf


Func EnableProxyPressed()
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyserver", "REG_SZ","127.0.0.1")
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "proxyoverride", "REG_SZ", "*.local;<local>")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions", "NoBrowserOptions", "REG_DWORD", "1")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel", "ConnectionsTab", "REG_DWORD", "1")
    ProcessClose("chrome.exe") ;<=== Close Web Browsers
    ProcessClose("firefox.exe") ;<=== Close Web Browsers
    ProcessClose("iexplore.exe") ;<=== Close Web Browsers
EndFunc   ;==>EnableProxyPressed

Func DisableProxyPressed()
    RegWrite("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings", "Proxyenable", "REG_DWORD", "0")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions", "NoBrowserOptions", "REG_DWORD", "0")
    RegWrite("HKEY_CURRENT_USER\Software\Policies\Microsoft\Internet Explorer\Control Panel", "ConnectionsTab", "REG_DWORD", "0")
    ProcessClose("chrome.exe") ;<=== Close Web Browsers
    ProcessClose("firefox.exe") ;<=== Close Web Browsers
    ProcessClose("iexplore.exe") ;<=== Close Web Browsers
EndFunc   ;==>DisableProxyPressed

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0