Private Sub Command1_Click()
Set wshshell = CreateObject("WScript.Shell")
wshshell.SendKeys "^{ESC}u"
wshshell.SendKeys "R"
End Sub
这是一个关机的编码 可我点击按钮怎么一点反应都没有哪位老师指教一下谢谢
试试
Private Sub Command1_Click()
Set wshshell = CreateObject("WScript.Shell")
wshshell.SendKeys "^{ESC}"
wshshell.SendKeys "U"
wshshell.SendKeys "U"
End Sub
Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click() Set wshshell = CreateObject("WScript.Shell") wshshell.SendKeys "^{ESC}u" Sleep 100 '两次发送按键消息中间加个延时,以保证"U"是在关机选项弹出之后发送的才会有效,否则两次按键消息几乎同时发送,而第二次发送的按键并没有被接收。 wshshell.SendKeys "U" Sleep 100 wshshell.SendKeys "U"
End Sub
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, _ ByVal dwReserved As Long) As Long
Private Const EWX_SHUTDOWN = 1
Private Sub Command1_Click() Call ExitWindowsEx(EWX_SHUTDOWN, 0) '关闭计算机
End Sub
用这个试试吧