VB 快速切换wifi软件 [提供案例参考吧]

Private Declare Function SetWindowPos Lib “user32” (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long ‘定义API
Private Declare Function timeGetTime Lib “winmm.dll” () As Long ‘调用时间API
Private Const HWND_TOPMOST = -1 ‘窗体最上层常数
Private Const SWP_NOMOVE = &H2 ‘窗体不移动(保持当前位置(x和y设定将被忽略))
Private Const SWP_NOSIZE = &H1 ‘窗体大小不变(保持当前大小(cx和cy会被忽略))
‘窗口拖动
Dim X0!, Y0!

Private Sub E_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then ‘左键
Shell “cmd.exe /c netsh wlan connect name=””BNU””” ‘连接EDUwifi

‘状态提示
LabelE_color.BackStyle = 1
‘计时 记录当前计算及运行的时间
Dim savetime As Double
savetime = timeGetTime ‘记下开始时的时间
While timeGetTime

If PingIP(“172.16.202.201”) Then
LabelE_color.BackColor = vbGreen
Else
LabelE_color.BackColor = vbRed
End If
savetime1 = timeGetTime
While timeGetTime DoEvents
Wend

DoEvents
Wend
LabelE_color.BackColor = RGB(255, 255, 255)
LabelE_color.BackStyle = 0

End If

If Button = 2 Then ‘右键
Shell App.Path & “DNSrepairV3.exe”
End If
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
X0 = X
Y0 = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
‘鼠标指针样式更改
Me.MousePointer = 5
‘窗口移动
Me.Left = Me.Left + X – X0
Me.Top = Me.Top + Y – Y0
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
‘鼠标指针样式还原
Me.MousePointer = 1
End Sub

Private Sub P_Click()
Shell “cmd.exe /c netsh wlan connect name=””Printer Wifi””” ‘连接Printer wifi
‘状态提示
LabelP_color.BackStyle = 1
‘计时 记录当前计算及运行的时间
Dim savetime As Double
savetime = timeGetTime ‘记下开始时的时间
While timeGetTime

If PingIP(“192.168.31.1”) Then  ‘小米路由器wifi网关地址———————————————————————-Maybe 需要根据实际情况修改
LabelP_color.BackColor = vbGreen
Else
LabelP_color.BackColor = vbRed
End If
savetime1 = timeGetTime
While timeGetTime DoEvents
Wend

DoEvents
Wend
LabelP_color.BackColor = RGB(255, 255, 255)
LabelP_color.BackStyle = 0
End Sub
Private Sub C_Click()
End
End Sub
Private Sub Form_Load() ‘程序一运行就执行
SetWindowPos hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE ‘设置最上层窗口
End Sub

Private Sub Timer1_Timer()
‘GetCursorPos P
If Me.Top = 0 Then Me.Top = 0
If Me.Top + Me.Height >= Screen.Height – 400 Then Me.Top = Screen.Height – Me.Height
End Sub

Private Sub Timer2_Timer()
On Error Resume Next
Dim P As POINTAPI
Dim f As RECT
GetCursorPos P
GetWindowRect Me.hwnd, f
If Me.WindowState 1 Then
If P.X > f.Left And P.X f.Top And P.Y If Me.Top Me.Top = -10
Me.Show
ElseIf Me.Left Me.Left = -10
Me.Show
ElseIf Me.Left + Me.Width >= Screen.Width Then
Me.Left = Screen.Width – Me.Width + 10
Me.Show
End If
ElseIf f.Top Me.Top = 40 – Me.Height
ElseIf f.Left Me.Left = 40 – Me.Width
ElseIf Me.Left + Me.Width >= Screen.Width – 4 Then
Me.Left = Screen.Width – 40
End If
End If
End Sub

截图

VB 快速切换wifi软件 [提供案例参考吧]

 

VB 快速切换wifi软件 [提供案例参考吧]

 

 

来源:这个人很懒啥也没写

声明:本站部分文章及图片转载于互联网,内容版权归原作者所有,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2021年10月8日
下一篇 2021年10月8日

相关推荐