728x90
#Include com.ahk
NetConnect(0) ; 네트워크 사용안함 설정
NetConnect(1) ; 네트워크 사용 설정
return
NetConnect(bEnable = False, sConnection = "로컬 영역 연결") ; 로컬 영역 연결은 해당하는 네트워크 이름으로 변경
{
COM_CoInitialize()
psh := COM_ActiveXObject("Shell.Application")
pns := COM_Invoke_(psh, "Namespace", 3, CSIDL_Connections:=0x0031)
pitems := COM_Invoke(pns, "Items")
Loop, % COM_Invoke(pitems, "Count")
{
pid := COM_Invoke_(pitems, "Item", 3, A_Index-1)
If (COM_Invoke(pid, "Name") = sConnection)
{
bRes := True
Break
}
COM_Release(pid)
}
If !bRes
ExitApp
pverbs := COM_Invoke(pid, "Verbs")
pvb := COM_Invoke_(pverbs, "Item", 3, nVB:=0)
If pvb
{
sVerbName := COM_Invoke(pvb, "Name")
If (bEnable && InStr(sVerbName, "&a")) || (!bEnable && InStr(sVerbName, "&b")) ; &a and &b can be Language dependent.
COM_Invoke(pvb, "DoIt")
WinWait, %sConnection% ahk_class #32770,, 1
WinWaitClose
COM_Release(pvb)
}
COM_Release(pverbs)
COM_Release(pid)
COM_Release(pitems)
COM_Release(pns)
COM_Release(psh)
COM_CoUninitialize()
}
728x90
'AutoHotKey' 카테고리의 다른 글
[GUI] IP on network interfaces (0) | 2023.09.01 |
---|---|
[GUI] IP on network interfaces (0) | 2023.08.31 |
Ahk Standard Library Collection, 2014 May (+Gui) ~ Libs: 100 (0) | 2023.08.29 |
AutoHotkey 설치 (0) | 2023.08.29 |
CoHelper.ahk (0) | 2023.08.28 |