Jump to content

AWC Wifi Hotspot


AWC
 Share

Recommended Posts

Hi, i Have maked a program to make wifi hotspot, can you try it an repport me any bug ?

Thanks !

 

NB : AWConstants file can be found at : https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=59636

The code :
 

#AutoIt3Wrapper_Icon=oem2.ico
#AutoIt3Wrapper_Outfile=AWC Wifi Hotspoter.Exe
#AutoIt3Wrapper_Res_Fileversion=1.0
#AutoIt3Wrapper_Res_ProductVersion=0.5
#AutoIt3Wrapper_Res_CompanyName=AWC Systems
#AutoIt3Wrapper_Res_LegalCopyright=2018
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#include <AWConstants.au3>
#NoTrayIcon

$ver = 1.5
$s = ""
$n = tocom("show")
$pid = Run(@ComSpec & " /c " & $n, "", @SW_HIDE, 8)
ProcessWait($pid)
$o = StdoutRead($pid)
$txt = ""
$tm = "Le service Configuration automatique des r‚seaux locaux sans fil (wlansvc)"
$tm &= @CRLF & "n'est pas en cours d'ex‚cution." & @CRLF & ""
If $o = $tm Then
    $txt = "Unsupported !"
    $col = $COLOR_RED
Else
    $txt = "Idle"
    $col = $COLOR_BLUE
EndIf

$main = GUICreate("AWC Wifi Hotspoter", 283, 140, 453, 336, BitOR($GUI_SS_DEFAULT_GUI,$WS_MAXIMIZEBOX,$WS_TABSTOP))
GUISetIcon("C:\Users\Benjamin\Desktop\Folder\WorkingDir\oem2.ico", -1)
$name = GUICtrlCreateInput("AWC Hotspot", 120, 16, 137, 21)
$Label1 = GUICtrlCreateLabel("Hotspot Name", 16, 16, 91, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Hotspot Key", 16, 64, 77, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$key = GUICtrlCreateInput("Input1", 120, 62, 137, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
$Activate = GUICtrlCreateButton("Activate", 101, 104, 81, 25)
$Label3 = GUICtrlCreateLabel("Coded By AWC", 192, 112, 78, 17)
$Label4 = GUICtrlCreateLabel($txt, 12, 112, 76, 17, $SS_CENTER)
GUICtrlSetColor($Label3, $COLOR_MAROON)
GUICtrlSetColor($Label4, $col)
OnAutoItExitRegister("ex")
GUISetState(@SW_SHOW)
        If $o = $tm Then
            GUICtrlSetState($name, $GUI_DISABLE)
            GUICtrlSetState($key, $GUI_DISABLE)
            GUICtrlSetState($Activate, $GUI_DISABLE)
        EndIf

While 1
    Sleep(15)
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            bye()
            Exit

        Case $GUI_EVENT_MINIMIZE
            bg()

        Case $GUI_EVENT_RESTORE
            forg()

        Case $Activate
            If StringLen(GUICtrlRead($key)) < 8 Then
                MsgBox(16, "Alert !", "Key must have 8 caracters !")
                ContinueLoop
                EndIf
            If $s <> 1 Then
            GUICtrlSetState($name, $GUI_DISABLE)
            GUICtrlSetState($key, $GUI_DISABLE)
            prep(GUICtrlRead($name), GUICtrlRead($key))
            GUICtrlSetData($Activate, "Disable")
            ht(1)
            GUICtrlSetData($Label4, "Online")
            GUICtrlSetColor($Label4, $COLOR_BLUE)
            $s = 1
            Else
            GUICtrlSetState($name, $GUI_ENABLE)
            GUICtrlSetState($key, $GUI_ENABLE)
            GUICtrlSetData($Activate, "Activate")
            ht(0)
            GUICtrlSetData($Label4, "Offline")
            GUICtrlSetColor($Label4, $COLOR_RED)
            $s = 0
            EndIf


    EndSwitch
WEnd

Func bye()

    $c = tocom("stop")

EndFunc

Func bg()

    $c = ""
    Return $c

EndFunc

Func forg()

    $c = ""
    Return $c

EndFunc

Func com($c)

EndFunc

Func tocom($todo, $c="")

    If $c <> "" Then $c = " " & $c
    $cm = "netsh wlan " & $todo & " hostednetwork" & $c
    Return $cm

EndFunc

Func ht($sw)

    If $sw = 1 Then
        $c = tocom("start")
    Else
        $c = tocom("stop")
    EndIf

    RunWait(@ComSpec & " /c " & $c, "", @SW_HIDE)


EndFunc

Func prep($n, $k)
    $n = StringReplace($n, " ", "_")
    $n = tocom("set", "ssid=" & $n)
    $k = tocom("set", "key=" & $k)
    $m = tocom("set", "mode=allow")
    RunWait(@ComSpec & " /c " & $n, "", @SW_HIDE)
    RunWait(@ComSpec & " /c " & $k, "", @SW_HIDE)
    RunWait(@ComSpec & " /c " & $m, "", @SW_HIDE)
EndFunc

Func ex()
    $c = tocom("stop")
    Run(@ComSpec & " /c " & $c, "", @SW_HIDE)
EndFunc

 

Edited by Jos
added codebox
Link to comment
Share on other sites

  • 2 years later...

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
 Share

  • Recently Browsing   0 members

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