 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Tue Jul 29, 2008 10:55 pm Post subject: |
|
|
2Joy2DWorld:
now that is a reason that would have made me take time before now to finish this up..... _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Wed Jul 30, 2008 12:24 am Post subject: |
|
|
| ahklerner wrote: | | added the remaining functions.....still needs reviewed...thx |
Finally! Great job. I'd also like to review the additional functions as soon as I have time.
OTOH, in order that this library is totally self-contained I feel it needs a few additional auxiliary functions which wll manage UNICODE strings and GUIDs, similar to those in COM library e.g., Ansi4Unicode/Unicode4Ansi/GUID4String/String4GUID. |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Jul 30, 2008 12:49 am Post subject: |
|
|
| Sean wrote: |
Finally! Great job.
|
Thanks!
| Sean wrote: |
I'd also like to review the additional functions as soon as I have spare time.
|
That would be great.
| Sean wrote: |
OTOH, in order that this library is totally self-contained I feel it needs a few additional auxiliary functions which wll manage UNICODE strings and GUIDs, similar to those in COM library e.g., Ansi4Unicode/Unicode4Ansi/GUID4String/String4GUID. |
It sure would be great if you would implement those, as i honestly have no idea where to begin.
now i have started messing with a script for it and by golly, it is hard...
the enumerate function seems to return a structure that contains an array of pointers to other structures...I can get the pointer to that initial structure, but I dont know what offsets to use to get at the array of pointers, nor how to parse the array once I do... _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Jul 30, 2008 1:12 am Post subject: |
|
|
This was my attempt:
| Code: |
hWlan := WLAN_Init()
MsgBox % "hClientHandle: " . hClientHandle := WLAN_WlanOpenHandle()
MsgBox % hEnum := WLAN_WlanEnumInterfaces(hClientHandle)
;What to do here ?!?!?
;psuedo-code
;Array := GetArrayPointer(hEnum)
;Loop, Parse, Array, ??
; ParseStruct(A_LoopField)
WLAN_WlanFreeMemory(hEnum)
WLAN_WlanCloseHandle(hClientHandle)
WLAN_UnInit(hWlan)
ExitApp
WLAN_Init(){
Return DllCall("LoadLibrary", "str", "wlanapi.dll")
}
WLAN_UnInit(hWlan){
DllCall("FreeLibrary", "UInt", hWlan)
}
|
_________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Wed Jul 30, 2008 2:12 am Post subject: |
|
|
I'm not on Wireless, so I can't test it myself, but the following is what I believe the one.
| Code: | hWlan := WLAN_Init()
MsgBox % "hClientHandle: " . hClientHandle := WLAN_WlanOpenHandle()
MsgBox % pEnum := WLAN_WlanEnumInterfaces(hClientHandle)
sInterfaces := "CurrentItem: " . NumGet(pEnum+4) . "`n`n"
Loop, % NumGet(pEnum+0)
sInterfaces .= "<Item " . A_Index-1 . ">`n"
. "GUID: " . Wlan_String4GUID(pEnum+8+(A_Index-1)*532) . "`n"
. "Description: " . Wlan_Ansi4Unicode(pEnum+8+(A_Index-1)*532+16) . "`n"
. "isState: " . NumGet(pEnum+8+(A_Index-1)*532+528) . "`n`n"
MsgBox % sInterfaces
WLAN_WlanFreeMemory(pEnum)
WLAN_WlanCloseHandle(hClientHandle)
WLAN_UnInit(hWlan)
ExitApp
WLAN_Init(){
Return DllCall("LoadLibrary", "str", "wlanapi.dll")
}
WLAN_UnInit(hWlan){
DllCall("FreeLibrary", "UInt", hWlan)
}
Wlan_GUID4String(ByRef GUID, String)
{
VarSetCapacity(GUID,16,0)
DllCall("ole32\IIDFromString", "Uint", Wlan_Unicode4Ansi(String,String), "Uint", &GUID)
Return &GUID
}
Wlan_String4GUID(pGUID)
{
VarSetCapacity(String,38*2+1)
DllCall("ole32\StringFromGUID2", "Uint", pGUID, "Uint", &String, "int", 39)
Return Wlan_Ansi4Unicode(&String)
}
Wlan_Ansi4Unicode(pString)
{
nSize:=DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "Uint", 0, "int", 0, "Uint", 0, "Uint", 0)
VarSetCapacity(sString,nSize)
DllCall("kernel32\WideCharToMultiByte", "Uint", 0, "Uint", 0, "Uint", pString, "int", -1, "str", sString, "int", nSize, "Uint", 0, "Uint", 0)
Return sString
}
Wlan_Unicode4Ansi(ByRef wString, sString)
{
nSize:=DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", 0, "int", 0)
VarSetCapacity(wString,nSize*2)
DllCall("kernel32\MultiByteToWideChar", "Uint", 0, "Uint", 0, "Uint", &sString, "int", -1, "Uint", &wString, "int", nSize)
Return &wString
}
|
Last edited by Sean on Wed Jul 30, 2008 2:32 am; edited 1 time in total |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Jul 30, 2008 2:32 am Post subject: |
|
|
Dude you are AWESOME!!....it works! thanks!! _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Wed Jul 30, 2008 2:49 am Post subject: |
|
|
| Glad it worked fine. BTW, I forgot to mention the index was 0-based, just in case. |
|
| Back to top |
|
 |
Joy2DWorld
Joined: 04 Dec 2006 Posts: 424 Location: Galil, Israel
|
Posted: Wed Jul 30, 2008 4:36 am Post subject: |
|
|
| ahklerner wrote: | | ....it works! thanks!! |
well, am stuck on the WlanOpenHandle Function
not getting "The version number specified by dwClientVersion and pdwNegotiatedVersion is a composite version number made up of both major and minor versions. The major version is specified by the high-order word, and the minor version is specified by the low-order word. The macros WLAN_API_VERSION_MAJOR(_v) and WLAN_API_VERSION_MINOR(_v) return the major and minor version numbers respectively. You can construct a version number using the macro WLAN_API_MAKE_VERSION(_major, _minor)"
does this mean 1 or 1>>16 ?? _________________ Joyce Jamce |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Wed Jul 30, 2008 7:05 am Post subject: |
|
|
| I also updated my post in the first page. As previous, just a straightforward translation of the codes by ahklerner. |
|
| Back to top |
|
 |
Sean
Joined: 12 Feb 2007 Posts: 1397
|
Posted: Wed Jul 30, 2008 7:11 am Post subject: |
|
|
| Joy2DWorld wrote: | | well, am stuck on the WlanOpenHandle Function |
It's just because ahklerner forgot that Wlan functions return 0 on success in the posted script. |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 689
|
Posted: Wed Jul 30, 2008 3:16 pm Post subject: |
|
|
YAY it works!!!! thanks a lot
now if only i could figure out the interface guid part _________________ check out my site
www.eliteknifesquad.com |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 689
|
Posted: Wed Jul 30, 2008 4:03 pm Post subject: |
|
|
Heres my try, it is suppose to message box all available networks
but it wont showem the correct interface guid is there too.
WLanAPI.ahk is Seans code on the first page of this post
| Code: | #Include WLanAPI.ahk
; Wireless Settings
hWlan := WLAN_Init()
hClientHandle := WLAN_WlanOpenHandle()
pEnum := WLAN_WlanEnumInterfaces(hClientHandle)
Loop, % NumGet(pEnum+0)
sInterfaces.= Wlan_String4GUID(pEnum+8+(A_Index-1)*532)
; Wireless Settings
Gui, Add, ListView, x6 y10 w250 h190 , SSID|Type|Strength
Gui, Add, Button, x16 y230 w80 h20 , Connect
Gui, Add, Button, x86 y340 w-252 h-640 , Disconnect
Gui, Add, GroupBox, x6 y210 w110 h80 , Wifi Control's
Gui, Add, Button, x16 y260 w80 h20 , Disconnect
Gui, Add, GroupBox, x126 y210 w120 h80 , AutoConnect Settings
Gui, Add, Button, x137 y230 w90 h20 , AutoC Manager
Gui, Add, Text, x136 y260 w80 h20 , Mini WiFi v1.0
; Generated using SmartGUI Creator 4.0
Gui, Show, x553 y389 h301 w270, Mini WiFi
gosub nwl
return
GuiEscape:
GuiClose:
WLAN_WlanFreeMemory(pEnum)
WLAN_WlanCloseHandle(hClientHandle)
WLAN_UnInit(hWlan)
ExitApp
return
nwl:
Networks := WLAN_WlanGetAvailableNetworkList(hClientHandle,sInterfaces,"0x00000001")
msgbox, %Networks% |
_________________ check out my site
www.eliteknifesquad.com |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Jul 30, 2008 4:34 pm Post subject: |
|
|
updated first post with Sean's changes. Thanks again. _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
ahklerner
Joined: 26 Jun 2006 Posts: 1249 Location: USA
|
Posted: Wed Jul 30, 2008 4:42 pm Post subject: |
|
|
| Code: | ;#Include WLAN.ahk ; <- not needed if you use the StdLib
; Wireless Settings
hWlan := WLAN_Init()
hClientHandle := WLAN_WlanOpenHandle()
pEnum := WLAN_WlanEnumInterfaces(hClientHandle)
InterfaceCount := NumGet(pEnum+0)
Loop, % InterfaceCount
{
CurrentItem := NumGet(pEnum+4) ;<- shouldn't A_Index be in there somewhere ?
Interface_%A_Index%_GUID := Wlan_String4GUID(pEnum+8+(A_Index-1)*532)
Interface_%A_Index%_DESC := Wlan_Ansi4Unicode(pEnum+8+(A_Index-1)*532+16)
Interface_%A_Index%_STATE := NumGet(pEnum+8+(A_Index-1)*532+528)
}
; Wireless Settings
Gui, Add, ListView, x6 y10 w250 h190 , SSID|Type|Strength
Gui, Add, Button, x16 y230 w80 h20 , Connect
Gui, Add, Button, x86 y340 w-252 h-640 , Disconnect
Gui, Add, GroupBox, x6 y210 w110 h80 , Wifi Control's
Gui, Add, Button, x16 y260 w80 h20 , Disconnect
Gui, Add, GroupBox, x126 y210 w120 h80 , AutoConnect Settings
Gui, Add, Button, x137 y230 w90 h20 , AutoC Manager
Gui, Add, Text, x136 y260 w80 h20 , Mini WiFi v1.0
; Generated using SmartGUI Creator 4.0
Gui, Show, x553 y389 h301 w270, Mini WiFi
gosub nwl
return
GuiEscape:
GuiClose:
WLAN_WlanFreeMemory(pEnum)
WLAN_WlanCloseHandle(hClientHandle)
WLAN_UnInit(hWlan)
ExitApp
return
nwl:
pInterfaceGuid := WLAN_GUID4String(GUID,Interface_1_GUID)
pNetworkList := WLAN_WlanGetAvailableNetworkList(hClientHandle,pInterfaceGuid,dwFlags)
msgbox, %pNetworkList%
return
|
it works....well you get the pointer to the structure that contains an array of pointers to structures that describe each network... _________________
ʞɔпɟ əɥʇ ʇɐɥʍ |
|
| Back to top |
|
 |
Fry
Joined: 01 Nov 2007 Posts: 689
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|