Jump to content
Belini

Automatically connect to Wifi network

Recommended Posts

Belini

I need to connect in wifi network whenever my program opens and to do this I need to put user and password, how can I do this using Autoit?

Share this post


Link to post
Share on other sites
Earthshine

What have you tried


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Belini
JLogan3o13

@Belini you have been around long enough to know you need to show some effort. A google search like this:

Quote

site:autoitscript.com wifi

yields over 400 results, many of which have examples with code in them. You cannot tell us you have looked at them all.

  • Thanks 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Belini
Posted (edited)

I've read every topic related to NativeWifi.au3 but I was unable to connect with user and password and I was able to just list the available wifi networks, does anyone have a hint on how to connect?

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <wifi33a.au3>

Global $Cb_rede, $Inp_pass, $But_refresh, $But_connect

_Wlan_StartSession()
Gui()

Func Gui()
    GUICreate("Wifi connection", 434, 104, -1, -1)
    GUICtrlCreateLabel("Rede wifi:", 8, 20, 51, 17)
    GUICtrlCreateLabel("Password:", 253, 20, 53, 17)
    $Cb_rede = GUICtrlCreateCombo("Choose a network", 64, 16, 169, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
    update_combo()
    $Inp_pass = GUICtrlCreateInput("", 312, 16, 113, 21, BitOR($ES_PASSWORD, $ES_CENTER, $ES_NUMBER))
    $But_refresh = GUICtrlCreateButton("Refresh", 40, 64, 139, 25)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $But_connect = GUICtrlCreateButton("Connect", 246, 64, 139, 25)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUICtrlSetState($But_connect, $GUI_FOCUS)
    GUISetState(@SW_SHOW)
EndFunc   ;==>Gui

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $But_refresh
            update_combo()
        Case $But_connect
            $rede = GUICtrlRead($Cb_rede)
            $pass = GUICtrlRead($Inp_pass)
            ; I do not know how to connect to the network
    EndSwitch
WEnd

Func update_combo()
    Local $data = "", $scan = ""
    GUICtrlSetData($Cb_rede, "")
    $scan = _Wlan_GetAvailableNetworkList(0)
    $avaiable = UBound($scan) - 1
    If $avaiable > 0 Then
        For $i = 0 To $avaiable
            $data &= $scan[$i][0] & "|"
        Next
        GUICtrlSetData($Cb_rede, $data, $scan[0][0])
    EndIf
EndFunc   ;==>update_combo

 

Edited by Belini

Share this post


Link to post
Share on other sites
Belini

Share this post


Link to post
Share on other sites
Bilgus
Quote

the first link did not open!

Did for me did you make sure your wifi was connected first? :lol:

Share this post


Link to post
Share on other sites
Bilgus

And the second link does have the info you need albeit some is in the comments section basically what it says is that you need an xml file containing the credentials 

Share this post


Link to post
Share on other sites
Belini

What I need is to choose a network, enter the password and connect!

List the wifi networks I can already but I can not connect using the password I have!

 

Share this post


Link to post
Share on other sites
JLogan3o13
Posted (edited)

Did you try the commands contained in the second link outside of AutoIt, so you know whether it is the actual netsh command that is failing or something in the AutoIt implementation of it? Just saying "I can not connect using the password I have!" tells us exactly nothing as to what exactly you're seeing.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Belini
Posted (edited)

I can connect only on wifi networks that already have the saved password and I want to connect in other networks I want to choose the network and enter the password of it, do I have to create some profile for new network?

I guess I'm not sure how to use the _Wlan_Connect () function to send network name and password!

 

Edited by Belini

Share this post


Link to post
Share on other sites
JLogan3o13

Again - why are you unwilling to read that second link, wanting someone to spoon feed it all back to you??? You have to use

netsh wlan add ---

In order to add a new profile, you need an XML file - which the link spells out for you in the comments section. The only additional help anyone can give you is to write the whole thing for you.

  • Like 1

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Belini
Posted (edited)

Sorry for my ignorance because I thought it would suffice to send the network name and password to connect and I did not know that I would need an .xml file just to send this data, I will search on how I would create this file since it will not work without this !

I have been researching this about yesterday and I could not make it work but I do not want anyone to do it for me, just tell me what steps I need to take to send the network name and password to connect?

Edited by Belini

Share this post


Link to post
Share on other sites
Belini
Posted (edited)

@kosamja thanks for the link's, I'll choose to try to create the .xml file

EDIT: Does anyone know where the .xml profile is saved?

Edited by Belini

Share this post


Link to post
Share on other sites
JLogan3o13

A 2 second Google search would show you the answer:

c:\programdata\Microsoft\Wlansvc\Profiles\Interfaces\

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Belini

I have compared the .xml I have here and my question is how to get the data of <hex>************</ hex> and <key material>************* </ key material>

The other data I know to get and I can make the exchange!

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

×