Leaderboard
Popular Content
Showing content with the highest reputation on 10/06/2025 in all areas
-
Show Adapters (Disable/Enable/Info)
argumentum and 2 others reacted to TheSaint for a topic
Just a little program I whipped up today. If like me, you connect to the web via LAN, but don't always like your PC to be connected all the time, especially at boot up, then you might find my script handy. Basically I use it to turn my Ethernet connection off. A fairly simple affair, and the state persists after shutdown. BIG THANKS to jguinch for the Network configuration UDF. My script uses and requires the Network.au3 include file from the first post of that topic. My script runs with Admin Rights, as per the first line of the script. Show Adapters.au3 NOTE - On my system, some adapters have a CRLF in the middle of the returned entry. My script changes that, within program, to a backward slash (\) for ease of use etc. As can be noted in the screenshot, the second portion, after the backslash, is the actual adapter name used for ENABLE and DISABLE and getting INFO. To work with the same adapter by default, you can SAVE a selected entry as the one, which can appear selected at startup after first being checked. Enjoy!3 points -
Hello Here is my network UDF. Do not yell at me if it already exists ... I hope it will be useful to someone. Please, let me know if you have any problem. All functions that perform modifications required administrator rights Functions list : Internal functions only : Examples : #Include "network.au3" ; List of availables connections/cards #Include <array.au3> ; only for _ArrayDisplay() $infos = _GetNetworkAdapterList() _ArrayDisplay($infos) ; Network card informations for the network connection called "Local Area Network" $infos = _GetNetworkAdapterInfos("Local Area Network") _ArrayDisplay($infos) ; Disable a network connection _DisableNetAdapter("Broadcom NetLink (TM) Gigabit Ethernet") ; OR _DisableNetAdapter("Local Area Network") ; Enable a network connection _EnableNetAdapter("Local Area Network") ; OR _EnableNetAdapter("Broadcom NetLink (TM) Gigabit Ethernet") ; Enable DHCP (for IP Address) _EnableDHCP("Broadcom NetLink (TM) Gigabit Ethernet") ; OR _EnableDHCP("Local Area Network") ; Configure a static IP adress _EnableStatic("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.10.11", "255.255.255.0") ; OR _EnableStatic("Local Area Network", "192.168.10.11", "255.255.255.0") ; Configure the default gateway _SetGateways("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.10.1") ; OR _SetGateways("Local Area Network", "192.168.10.1") ; Configure DNS servers Local $DNS_SERVERS[4] = [ "192.168.100.1", "192.168.100.2", "192.168.100.3", "192.168.100.4" ] _SetDNSServerSearchOrder("Local Area Network", $DNS_SERVERS) ; OR _SetDNSServerSearchOrder("Broadcom NetLink (TM) Gigabit Ethernet", $DNS_SERVERS) ; Configure the DNS domain name _SetDNSDomain ("Local Area Network", "mondomain.loc") ; OR _SetDNSDomain ("Broadcom NetLink (TM) Gigabit Ethernet", "mondomain.loc") ; Configure the DNS suffixes for all connections : Local $DNS_SUFFIXES[2] = [ "mondomain.loc", "mydomain.priv" ] _SetDNSSuffixSearchOrder($DNS_SUFFIXES) ; Clear the DNS cache (like ipconfig /flushdns) _FlushDNS() ; Remove an entry from the DNS cache _FlushDNSEntry("www.autoitscript.com") ; Configure the WINS servers (very old, now ...) _SetWINSServer("Local Area Network", "192.168.100.251", "192.168.100.252") ; OR _SetWINSServer("Broadcom NetLink (TM) Gigabit Ethernet", "192.168.100.251", "192.168.100.252") ; Enable the two options : ; - Register this connection's address in DNS ( first parameter) ; - Use this connection's DNS suffix in DNS registration (second parameter) _SetDynamicDNSRegistration("Local Area Network", True, True) ; Release the DHCP lease _ReleaseDHCPLease() ; Renew the DHCP lease _RenewDHCPLease() ; Sets the Private category to the network connection called "LAN" _SetCategory("LAN", 1) Download link : Network.au32 points
-
Issues with "_CloseForm"
mr-es335 reacted to pixelsearch for a topic
Of course if there is no [X] option in the main GUI, then you need another option to quit. Then the 3rd label could do the job.1 point -
Issues with "_CloseForm"
pixelsearch reacted to mr-es335 for a topic
pixelsearch, A couple of "things"... 1) Thank you so very, very much. Both you and ioa747 have been instrumental in assisting me and my "un-Vulcanized" brain to at least - in some minuscule manner, of being to understand, at least in some small part, what endeavor you happen to be assisting me with at any particular time. 2) The 3GUI example is based on a one provided by ioa747 - so I cannot take ALL the credit for that one - if indeed, any credit can be rightly assumed. 3) The example you have provided is "very clean and top-down" - which I am sure would make Melba very happy. • The example is also very easy to understand - which is appreciated. I thank you again, pixelsearch, for your time, attention and efforts on my behalf. Both are very much appreciated! PS: I have updated the "Solution" to your final offering!1 point -
Issues with "_CloseForm"
mr-es335 reacted to pixelsearch for a topic
I did that in the script below, based on your initial script : * The 3 GUI's are created only once * The "option 2" GUI got a Close button (no $WS_POPUP style) just to indicate that it is possible, when you click its Close button, to hide the GUI without closing/deleting the GUI * That's why you'll find similar parts of code in both functions _ColRow() when you click a label, and _CloseForm (when you click a GUI Close button) : "similar parts of code" means hide a GUI but don't close/delete it (except for the main GUI which normally exits when you click its Close button) ; ----------------------------------------------- #RequireAdmin ; ----------------------------------------------- #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; ----------------------------------------------- Opt("GUIOnEventMode", 1) ; ----------------------------------------------- Global $Form1, $sCol1Row1, $sCol1Row2 Global $sLabel1, $sOption1Label Global $sLabel2, $sOption2Label ; ----------------------------------------------- Forms() ; ----------------------------------------------- Func Forms() $Form1 = GUICreate("", 235, 75) GUISetFont(14, 800, 0, "Calibri") GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm") $sCol1Row1 = GUICtrlCreateButton("For Option 1", 10, 10, 215, 25) GUICtrlSetOnEvent($sCol1Row1, "Option1") $sCol1Row2 = GUICtrlCreateButton("For Option 2", 10, 40, 215, 25) GUICtrlSetOnEvent($sCol1Row2, "Option2") ; ----------------------------------------------- $sLabel1 = GUICreate("", 75, 23, 620, 48, $WS_POPUP, $WS_EX_TOPMOST) GUISetFont(14, 800, 0, "Calibri") GUISetBkColor(0x3D3D3D) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm") $sOption1Label = GUICtrlCreateLabel("Option 1", 0, 0, 75, 23, $SS_CENTER) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent($sOption1Label, "_ColRow") ; ----------------------------------------------- $sLabel2 = GUICreate("", 75, 23, 620, 48, -1, $WS_EX_TOPMOST) GUISetFont(14, 800, 0, "Calibri") GUISetBkColor(0x3D3D3D) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseForm") $sOption2Label = GUICtrlCreateLabel("Option 2", 0, 0, 75, 23, $SS_CENTER) GUICtrlSetColor(-1, 0xFFFFFF) GUICtrlSetOnEvent($sOption2Label, "_ColRow") ; ----------------------------------------------- GUISwitch($Form1) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd EndFunc ;==>Forms ; ----------------------------------------------- Func Option1() GUICtrlSetState($sCol1Row1, $GUI_DISABLE) GUISwitch($sLabel1) GUISetState(@SW_SHOW) EndFunc ;==>Option1 ; ----------------------------------------------- Func Option2() GUICtrlSetState($sCol1Row2, $GUI_DISABLE) GUISwitch($sLabel2) GUISetState(@SW_SHOW) EndFunc ;==>Option2 ; ----------------------------------------------- Func _ColRow() ; ConsoleWrite("@GUI_CtrlId=" & @GUI_CtrlId & @CRLF) Switch @GUI_CtrlId Case $sOption1Label GUISetState(@SW_HIDE, $sLabel1) GUISwitch($Form1) GUICtrlSetState($sCol1Row1, $GUI_ENABLE) Case $sOption2Label GUISetState(@SW_HIDE, $sLabel2) GUISwitch($Form1) GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch EndFunc ;==>_ColRow ; ----------------------------------------------- Func _CloseForm() Switch @GUI_WinHandle Case $Form1 MsgBox($MB_OK, "GUI Event", "You selected CLOSE in the main window! Exiting...", 1) Exit Case $sLabel1 GUISetState(@SW_HIDE, $sLabel1) GUISwitch($Form1) GUICtrlSetState($sCol1Row1, $GUI_ENABLE) Case $sLabel2 GUISetState(@SW_HIDE, $sLabel2) GUISwitch($Form1) GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch EndFunc ;==>_CloseForm Hope it helps1 point -
Issues with "_CloseForm"
mr-es335 reacted to pixelsearch for a topic
Sure it is, as you don't delete/recreate GUI's during the script, which means all controls variables values will be different. One important point in the discussion is : take care of your variable values if these variables correspond to controls that have been deleted (because you deleted their GUI) For example, your initial script could be amended like this, by adding 2 lines in this function : Func _CloseForm() Switch @GUI_WinHandle Case $Form1 MsgBox($MB_OK, "GUI Event", "You selected CLOSE in the main window! Exiting...", 1) Exit Case $sLabel1 GUIDelete(@GUI_WinHandle) $sOption1Label = 0 ; force this control variable value to 0, because its GUI is deleted <=============== GUICtrlSetState($sCol1Row1, $GUI_ENABLE) Case $sLabel2 GUIDelete(@GUI_WinHandle) $sOption2Label = 0 ; force this control variable value to 0, because its GUI is deleted <=============== GUICtrlSetState($sCol1Row2, $GUI_ENABLE) EndSwitch EndFunc ;==>_CloseForm Now your 1st script should run correctly, even if you choose "Option 1" then "Option 2"1 point