minoilrosso Posted August 17, 2008 Share Posted August 17, 2008 Hi everybody. I'm new to AutoIt, and I humbly request your kind help I need to make a script which detects if there's an active connection to a LAN or WLAN, and then - if the connection exists - runs a batch or .exe file. I know how to do for the second part, but I don't know how to detect the active connection. Thank you in advance for your help. Link to comment Share on other sites More sharing options...
TerarinK Posted August 17, 2008 Share Posted August 17, 2008 through WMI you can check to see what exist such 0x576520616C6C206469652C206C697665206C69666520617320696620796F75207765726520696E20746865206C617374207365636F6E642E Link to comment Share on other sites More sharing options...
rasim Posted August 17, 2008 Share Posted August 17, 2008 minoilrossoWelcome!Try this:Global Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection Global Const $NETWORK_ALIVE_WAN = 0x2 ;RAS connection Global Const $NETWORK_ALIVE_AOL = 0x4 ;AOL $connect = _GetNetworkConnect() If $connect Then MsgBox(64, "Connections", $connect) Else MsgBox(48, "Warning", "There is no connection") EndIf Func _GetNetworkConnect($sType = $NETWORK_ALIVE_LAN) Local $tTYPE, $iData, $iResult $tTYPE = DllStructCreate("int") DllCall("sensapi.dll", "int", "IsNetworkAlive", "ptr", DllStructGetPtr($tTYPE)) $iData = DllStructGetData($tTYPE, 1) If BitAND($iData, $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF If BitAND($iData, $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF If BitAND($iData, $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF Return $iResult EndFunc Link to comment Share on other sites More sharing options...
rover Posted August 17, 2008 Share Posted August 17, 2008 Try this: expandcollapse popupGlobal Const $NETWORK_ALIVE_LAN = 0x1 ;net card connection Global Const $NETWORK_ALIVE_WAN = 0x2 ;RAS connection Global Const $NETWORK_ALIVE_AOL = 0x4 ;AOL $connect = _GetNetworkConnect() If $connect Then MsgBox(64, "Connections", $connect) Else MsgBox(48, "Warning", "There is no connection") EndIf Func _GetNetworkConnect($sType = $NETWORK_ALIVE_LAN) Local $tTYPE, $iData, $iResult $tTYPE = DllStructCreate("int") DllCall("sensapi.dll", "int", "IsNetworkAlive", "ptr", DllStructGetPtr($tTYPE)) $iData = DllStructGetData($tTYPE, 1) If BitAND($iData, $NETWORK_ALIVE_LAN) Then $iResult &= "LAN connected" & @LF If BitAND($iData, $NETWORK_ALIVE_WAN) Then $iResult &= "WAN connected" & @LF If BitAND($iData, $NETWORK_ALIVE_AOL) Then $iResult &= "AOL connected" & @LF Return $iResult EndFuncoÝ÷ Ûú®¢×jȦÊjzÞÞ¶T®ç-~éܶ*'°9e ©eÂ)ejYhq«^i»}êçjدzºÚ"µÍÛØ[ÛÛÝ ÌÍÓUÓÔ×ÐSUWÓSHHÛ]ØÛÛXÝ[ÛÛØ[ÛÛÝ ÌÍÓUÓÔ×ÐSUWÕÐSHÔTÈÛÛXÝ[ÛÛØ[ÛÛÝ ÌÍÓUÓÔ×ÐSUWÐSÓH ÐSÓÌÍØÛÛXÝHÑÙ]]ÛÜÐÛÛXÝ BY^[Y[ÙÐÞ ][ÝÐÛÛXÝ[ÛÉ][ÝË ÌÍØÛÛXÝ B[ÙBÙÐÞ ][ÝÕØ[É][ÝË ][ÝÕHÈÈÛÛXÝ[Û][ÝÊB[Y[ÈÑÙ]]ÛÜÐÛÛXÝ BNÈ^[YÙ]H[Ý[ÛÛ]ÙHÈÛÛX[ ÌÎNÒÐÛÛXÝY ÌÎNÂSØØ[ ÌÍØTÝ[ ÌÍÜÔÝ[H ][ÝÉ][ÝË ÌÍÚQ]K ÌÍÚQÜH ÌÍØTÝ[HØ[ ][ÝÜÙ[ØK ][ÝË ][ÝÚ[ ][ÝË ][ÝÒÓ]ÛÜÐ[]I][ÝË ][ÝÚ[ ][ÝË BIÌÍÚQÜHÜRYÜÜÐ^J ÌÍØTÝ[ HH[]Ù]Ü ÌÍÚQÜ ][ÝÉ][ÝÊBIÌÍÚQ]HH ÌÍØTÝ[ÌWBY]S ÌÍÚQ]K ÌÍÓUÓÔ×ÐSUWÓSH[ ÌÍÜÔÝ[ [ÏH ][ÝÓSÛÛXÝY ][ÝÈ [ÈY]S ÌÍÚQ]K ÌÍÓUÓÔ×ÐSUWÕÐSH[ ÌÍÜÔÝ[ [ÏH ][ÝÕÐSÛÛXÝY ][ÝÈ [ÈY]S ÌÍÚQ]K ÌÍÓUÓÔ×ÐSUWÐSÓ H[ ÌÍÜÔÝ[ [ÏH ][ÝÐSÓÛÛXÝY ][ÝÈ [È]Ù]Ü ÌÍÚQÜ ÌÍØTÝ[ÌK ÌÍÜÔÝ[ B[[ I see fascists... Link to comment Share on other sites More sharing options...
rasim Posted August 17, 2008 Share Posted August 17, 2008 roverRight, but i think both our solutions is correct Link to comment Share on other sites More sharing options...
minoilrosso Posted August 17, 2008 Author Share Posted August 17, 2008 Thank you I'll try both solutions =) Link to comment Share on other sites More sharing options...
rover Posted August 19, 2008 Share Posted August 19, 2008 roverRight, but i think both our solutions is correct Rasim, yes they are I was just pointing out that some lines of code can be saved for simplestruct requirements with DllCall.just for future reference and for anyone else who comes along.Cheers I see fascists... Link to comment Share on other sites More sharing options...
rasim Posted August 19, 2008 Share Posted August 19, 2008 roverThank you for example Link to comment Share on other sites More sharing options...
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