Jump to content

Recommended Posts

Posted

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?

  • Moderators
Posted

@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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
Posted
Posted

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 

Posted

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!

 

  • Moderators
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

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Moderators
Posted

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
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
Posted

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!

  • 1 year later...
Posted
On 3/23/2018 at 5:32 AM, Belini said:

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?

 

Hey, I know this is an old thread, but for the benefit of others reading this..

As touched on, you need to generate a profile to connect to. If you are planning on using that old UDF, there are examples in the zip file on sourceforge on how to do this (providing it still works on modern windows builds!).

Matt

Posted (edited)


Please don’t necropost. I’m sure he’s not still looking for the answer two  years later

Edited by Earthshine

My resources are limited. You must ask the right questions

 

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...