ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Wanted: tray icon that shows if wifi connection is 2.4 or 5 GHz

(1/3) > >>

brotherS:
Hello,

does anyone here know an app who offers this? Maybe even with customizable colors (one for 2.4 and another for 5 GHz)? I've tried Google but couldn't find one...

highend01:
Write a simple .ahk script which executes
--- ---netsh wlan show interfacesand parses the content afterwards.

Regarding capturing the cmd output, e.g.: https://autohotkey.com/board/topic/15455-stdouttovar/page-7

If Channel is 1-14 you're on 2,4 GHz and if it's 36+ (both values depend on country, look at e.g. https://en.wikipedia.org/wiki/List_of_WLAN_channels#5_GHz_or_5.8_GHz_(802.11a/h/j/n/ac/ax)
you're on 5 GHz.

~15 lines of code, 3 16x16 px .png / .ico files (e.g. grey = no wifi connection, green = 2.4 GHz, red = 5 GHz, or whatever you'd prefer)...

Works at least on Win 10...

brotherS:
Works at least on Win 10...
-highend01 (January 15, 2020, 03:26 PM)
--- End quote ---
Are you willing to share that working code? I have zero experience with that side of AutoHotkey...

highend01:

--- ---
#NoEnv
#SingleInstance force
#Persistent

Gosub, Check
SetTimer, Check, 5000
return


Check:
result := Runret("cmd /c netsh wlan show interfaces")
RegExMatch(result, "im)channel\s+:\s*(?P<Channel>\d{1,3})", match)

If (matchChannel >= 1 && matchChannel <= 14)
Menu, Tray, Icon, %A_ScriptDir%\_green.png
Else If (matchChannel >= 34)
Menu, Tray, Icon, %A_ScriptDir%\_red.png
Else
Menu, Tray, Icon, %A_ScriptDir%\_grey.png

return


; http://www.autohotkey.com/board/topic/15455-stdouttovar/page-7
Runret(cmd, params="") {
; Assemble command + parameters
cmd := (params) ? cmd . " " . params : cmd

DllCall("CreatePipe", "Ptr*", hStdInRd , "Ptr*", hStdInWr , "Uint", 0, "Uint", 0)
DllCall("CreatePipe", "Ptr*", hStdOutRd, "Ptr*", hStdOutWr, "Uint", 0, "Uint", 0)
DllCall("SetHandleInformation", "Ptr", hStdInRd , "Uint", 1, "Uint", 1)
DllCall("SetHandleInformation", "Ptr", hStdOutWr, "Uint", 1, "Uint", 1)

; Fill a StartupInfo structure
if A_PtrSize = 4 ; We're on a 32-bit system
{
VarSetCapacity(pi, 16, 0)
sisize := VarSetCapacity(si, 68, 0)
NumPut(sisize,    si,  0, "UInt")
NumPut(0x100,     si, 44, "UInt")
NumPut(hStdInRd , si, 56, "Ptr") ; stdin
NumPut(hStdOutWr, si, 60, "Ptr") ; stdout
NumPut(hStdOutWr, si, 64, "Ptr") ; stderr
}
else if A_PtrSize = 8 ; We're on a 64-bit system
{
VarSetCapacity(pi, 24, 0)
sisize := VarSetCapacity(si, 96, 0)
NumPut(sisize,    si,  0, "UInt")
NumPut(0x100,     si, 60, "UInt")
NumPut(hStdInRd , si, 80, "Ptr") ; stdin
NumPut(hStdOutWr, si, 88, "Ptr") ; stdout
NumPut(hStdOutWr, si, 96, "Ptr") ; stderr
}

DllCall("CreateProcess" , "Uint", 0 ; Application Name
, "Ptr", &cmd ; Command Line
, "Uint", 0 ; Process Attributes
, "Uint", 0 ; Thread Attributes
, "Int", True ; Inherit Handles
, "Uint", 0x08000000 ; Creation Flags (0x08000000 = Suppress console window)
, "Uint", 0 ; Environment
, "Uint", 0 ; Current Directory
, "Ptr", &si ; Startup Info
, "Ptr", &pi) ; Process Information

DllCall("CloseHandle", "Ptr", NumGet(pi, 0))
DllCall("CloseHandle", "Ptr", NumGet(pi, A_PtrSize))
DllCall("CloseHandle", "Ptr", hStdOutWr)
DllCall("CloseHandle", "Ptr", hStdInRd)
DllCall("CloseHandle", "Ptr", hStdInWr)

VarSetCapacity(temp, 4095)
size := 0
Loop
{
result := DllCall("Kernel32.dll\ReadFile", "Uint", hStdOutRd, "Ptr", &temp, "Uint", 4095, "UintP", size, "Uint", 0)
if (result = "0")
break
else
output := output . StrGet(&temp, size, "CP850")
}
DllCall("CloseHandle", "Ptr", hStdOutRd)
return output
}

anandcoral:
great highend01  :Thmbsup:

Attached are the pngs, if required by anyone  :)

   

[EDIT] pngs gives error so attached ico files. Please change .png to .ico in ahk by highend01.



Regards,

Anand

Navigation

[0] Message Index

[#] Next page

Go to full version