Champak Posted May 2, 2010 Posted May 2, 2010 I'm looking for something pretty simple. Has anyone made anything to simply turn on and off the wifi in the laptop? I saw some scripts/functions for entire wifi functions minus that simple thing...from what I saw at least. Just need to simply turn it off and on. Any help?
darkjohn20 Posted May 2, 2010 Posted May 2, 2010 http://www.autoitscript.com/forum/index.php?showtopic=91018&st=0&p=753501&hl=wifi%20udf&fromsearch=1&#entry753501
somdcomputerguy Posted May 2, 2010 Posted May 2, 2010 I had this code in my script at one point. It may or may not work for you, I wrote it quick and dirty to work specifically on my PC, although it might work on any PC with Windows Mobility Center. It is a toggle, BTW. If Not WinExists("Windows Mobility Center") Then Run("mblctr.exe") WinWaitActive("Windows Mobility Center") EndIf ControlClick("Windows Mobility Center", "", "Button2") WinClose("Windows Mobility Center") - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Champak Posted May 2, 2010 Author Posted May 2, 2010 I don't know what exactly that link is suppose to tell me. I've saw that thread b4 I posted here and didn't see a function that accomplishes what I need. Thanks but that script doesn't work for me.
somdcomputerguy Posted May 2, 2010 Posted May 2, 2010 I'm not surprised that it didn't, but with Run and ControlClick, and info from the AutoIt Window Info Tool (AU3Info), you should be able to get something going. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
evilertoaster Posted May 6, 2010 Posted May 6, 2010 I'm looking for something pretty simple. Has anyone made anything to simply turn on and off the wifi in the laptop?Define "Turn Off".You can shut off power to it from your BIOS usually, that's the most drastic solution.You can also disable the device via WMI (http://msdn.microsoft.com/en-us/library/Aa394595) or other means. Finally, you can disconnect a card from the network using the _Wlan_Disconnect() function in the UDF that darkjohn linked you.
Champak Posted May 7, 2010 Author Posted May 7, 2010 (edited) I was looking for something that simply disable/enable the wifi rather than disconnect the card....like when you use the function key on the laptop to enable/disable. Edited May 7, 2010 by Champak
evilertoaster Posted May 7, 2010 Posted May 7, 2010 Most of the time the FN button are proprietary, and are let up to the BIOS to interpret, which means you are essentially opting for option 1 and disabling power to the card.Do have a read of http://en.wikipedia.org/wiki/Fn_key about that FN key, and the Send() documentation which reiterates:Most laptop computer keyboards have a special Fn key. This key cannot be simulated.Your specific vendor may offer software what has API's to the FN key commands, but your on your own there...
spudw2k Posted May 7, 2010 Posted May 7, 2010 (edited) The FN key is prob the simplest since it's built-in already (depending on your system config). Else here's a script I made once upon a time. It run's in the systray and toggles (enable/disable) your network interfaces. Edited May 7, 2010 by spudw2k Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX Builder Misc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retrieve SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose Array Projects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalc Cool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF
Champak Posted May 9, 2010 Author Posted May 9, 2010 Thanks all, spudw2k that's pretty much what I was looking for...added some hotkeys and I'm good to go; thanks.
Champak Posted May 10, 2010 Author Posted May 10, 2010 (edited) So here's my problem now and I need to figure a workaround. Sometimes "Internet Connection" gateway will be in my Network Connection and sometimes it wont which throws off my hotkey setup of calling the control ID of the trayitem. Or even in my other netbook where I have two wifi connections. My initial thought is to make a GUI populated by checkboxes created from an array of the networks detected. And then save the ones checked in some type of registry/ini. Problem is I don't want to do that because it would mean I would have to check the GUI every time I start the app up because sometimes a connection will show sometimes it wont...or it would be different between different laptops. Is there an automatic way to do this. I hope this made sense. Here is my initial hotkey setup calling the function. expandcollapse popup#include <Array.au3> #include <GUIConstantsEx.au3> ;#include <Misc.au3> Opt("TrayMenuMode",1) TraySetIcon("Shell32.dll",-150) TraySetToolTip("QuickNIC") Global $colNetwork, $msg, $colNetwork Global $strEnable = "En&able" Global $strDisable = "Disa&ble" Global $HotKey ;"!" = Alt HotKeySet("!w", "_Wifi") HotKeySet("!b", "_BlueTooth") HotKeySet("!l", "_LocalArea") Func NetworkConnectionsObject() $objShell = ObjCreate("Shell.Application") $strNetConn = "Network Connections" $objCP = $objShell.Namespace(3) Global $colNetwork = "" For $clsConn In $objCP.Items If $clsConn.Name = $strNetConn Then $colNetwork = $clsConn.GetFolder Next Return $colNetwork EndFunc Func GetNetworkNames($colNetwork) Dim $strNetworks For $clsConn In $colNetwork.Items If StringInstr($clsConn.Name,"Wizard") = 0 Then $strNetworks = $strNetworks & $clsConn.Name & "|" EndIf Next $strNetworks = StringLeft($strNetworks,StringLen($strNetworks)-1) $arrNetworks = StringSplit($strNetworks,"|") _ArrayDelete($arrNetworks,0) _ArraySort($arrNetworks) Return $arrNetworks EndFunc Func AddTrayItems($arrNetworks) For $i = 0 To UBound($arrNetworks) - 1 For $clsConn In $colNetwork.Items If $clsConn.Name = $arrNetworks[$i] Then TrayCreateItem($arrNetworks[$i]) For $clsVerb in $clsConn.verbs If $clsVerb.name = $strDisable Then TrayItemSetState(-1,1) If $clsVerb.name = $strEnable Then TrayItemSetState(-1,4) Next EndIf Next Next EndFunc Func ToggleNetworkInterface($strNetwork) For $clsConn In $colNetwork.Items If $clsConn.Name = $strNetwork Then For $clsVerb in $clsConn.verbs If $clsVerb.name = $strDisable Then If $HotKey = 1 Then TrayItemSetState($msg, $GUI_UNCHECKED) $HotKey = 0 EndIf $clsVerb.DoIt sleep(200) Return 0 EndIf If $clsVerb.name = $strEnable Then If $HotKey = 1 Then TrayItemSetState($msg, $GUI_CHECKED) $HotKey = 0 EndIf $clsVerb.DoIt TrayItemSetState($msg,1) sleep(200) Return 1 EndIf Next EndIf Next EndFunc AddTrayItems(GetNetworkNames(NetworkConnectionsObject())) ;#cs $separator = TrayCreateItem("") $trayabout = TrayCreateItem("About") $trayexit = TrayCreateItem("Exit") ;#ce Func _Wifi() $HotKey = 1 $msg = 9 EndFunc Func _LocalArea() $HotKey = 1 $msg = 8 EndFunc Func _BlueTooth() $HotKey = 1 $msg = 7 EndFunc While 1 $msg = TrayGetMsg() If $msg > 0 and $msg <> $trayabout and $msg <> $trayexit Then ConsoleWrite($msg & TrayItemGetText($msg) & @CRLF) ToggleNetworkInterface(TrayItemGetText($msg)) EndIf ;#cs If $msg = $trayabout Then SplashTextOn("About...","QuickNIC is a tool that provides a quick and easy method to toggle (enable/disable) your Network Connections." & @CRLF & @CRLF & "version 0.2b",300,120) sleep(3500) SplashOff() EndIf ;#ce If $msg = $trayexit Then ExitLoop WEnd Then it all gets messed up if "Network Connection" Gateway shows up in the Network Connections. Is there a better way to accomplish what I want besides what I'm planning? Edited May 10, 2010 by Champak
MattyD Posted May 16, 2010 Posted May 16, 2010 The way to do it with no workarounds is through WlanSetInterface using the wlan_intf_opcode_radio_state opcode. http://msdn.microsoft.com/en-us/library/ms706791(v=VS.85).aspx The UDF I'm working on does not include this yet as the minimum supported client is vista - I'm still trying to reach comprehensive XP support! If all goes to plan it should make an appearance in version 4 which will hopefully be released later this year. Gotta first sort out the mess that is version 3 Much of the funtionality of this API is built into netsh though (command line) from vista on... so it may be worth checking that out. "that simple thing" is simply not built natively into XP... It is all proprietary software unfortunately. Happy coding Matt
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now