zivt

Connect to a WiFi SSID

9 posts in this topic

Hi,

Is there any example code that shows how to auto connect to a WEP wireless network.

if it possible no GUI!!!

after searching and founding my network i want automatically connect to this network.

Thanks,

Ziv

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Windows can be set to automatically connect to a network.

Edited by somdcomputerguy

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

I want to connect my 10 routers (one by one). - each router has different SSID.

Share this post


Link to post
Share on other sites

Is there any way to that in Xp?

Share this post


Link to post
Share on other sites

Hey man,

you may want to give a try. (It's not as complicated as it first looks!)

Let me know if you run into problems,

Matt

Share this post


Link to post
Share on other sites

Hi,

Thanks for the help,

after installing XP update all works fine but i dont get Connect / Disconnect NOTIFICATION any idea?

Share this post


Link to post
Share on other sites

Calling to _Wlan_Connect retuerns error (@error) 2.

from MSDN - "The system cannot find the file specified."

!APIError @Ln[2182] _WinAPI_WlanConnect - The parameter is incorrect.

Any idea?

Thanks,

Ziv

Share this post


Link to post
Share on other sites

hey man,

Just to clarify things:

An @error value of 2 only indicates the function failed because of an API error - nothing more. The actual API error code lives in @extended - this case it will be 87 (The parameter is incorrect.)

As far as notifications go, XP uses them horribly. You've probably found the only codes it supports are $WLAN_NOTIFICATION_ACM_CONNECTION_COMPLETE and $WLAN_NOTIFICATION_ACM_DISCONNECTED. This is all well and good - except in XP "connection complete" does not always men the connection is complete.

After calling the connect function the "connection complete" notification will appear three times. First time it will mean "the connection has started", second time associated (i assume), and finally connected. Of course if a disconnected notification appears in the middle somewhere the next connected notification will mean "the connection has started"... It is also worth noting the disconnected notification also appears a few times when disconnecting.

If you don't want to deal with all that mess - just use the wait flag when calling _Wlan_Connect() and let the UDF deal with it.

#include "NativeWifi.au3"

$fDebugWifi = True

_Wlan_StartSession()
_Wlan_StartNotificationModule()

Local $oProfile, $sReason

$oProfile = _Wlan_CreateProfileObject()
With $oProfile
.Name = "Test"
.SSID.Add($oProfile.Name)
.Type = "Infrastructure"
.Auth = "Shared Key"
.Encr = "WEP"
.Key.Protected = False
.Key.Type = "Network Key"
.Key.Material = "MyKey"
EndWith

If Not _Wlan_SetProfile($oProfile, $sReason) Then
MsgBox(0, "Wifi", "Failed to create profile " & $oProfile.Name & ". @error=" & @error & @CRLF & "Because: " & $sReason)
Exit
EndIf

If _Wlan_Connect($oProfile.Name, True) Then ;the True means _Wlan_Connect will wait for the connection to either complete or fail before continuing
MsgBox(0, "Wifi", "Connected to " & $oProfile.Name & ".")
Else
MsgBox(0, "Wifi", "Connection failed to " & $oProfile.Name & ". @error=" & @error)
EndIf

Hope this helps,

Matt

1 person likes this

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