How do I turn the computer to suspend mode with vb-code?
Thanks in advance
Worf
Printable View
How do I turn the computer to suspend mode with vb-code?
Thanks in advance
Worf
I don't have the code on me...but if you are advanced in vb...
send ctrl+esc keys and then send the "S" (i think it's S) to put it in suspend mode.
If you don't come up with the code in the next hour or so i will post it for you when i get home.
Laterz,
D!m
Ps.maybe someone will help you b4 me :)
here ya go:
See where that "u" is, replace it with "s" or whatever char is unerlined in the start menu.Code:Private Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Function MapVirtualKey Lib "user32" _
Alias "MapVirtualKeyA" (ByVal wCode As Long, _
ByVal wMapType As Long) As Long
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_CONTROL = &H11
Private Const VK_ESCAPE = &H1B
Private Sub Command1_Click()
Dim intScanCtrl As Integer
Dim intScanEsc As Integer
' get OEM scan code for CTRL
intScanCtrl = MapVirtualKey(VK_CONTROL, 0)
' and for ESC
intScanEsc = MapVirtualKey(VK_ESCAPE, 0)
keybd_event VK_CONTROL, intScanCtrl, 0, 0 ' CTRL down
keybd_event VK_ESCAPE, intScanEsc, 0, 0 ' ESC down
' CTRL up
keybd_event VK_CONTROL, intScanCtrl, KEYEVENTF_KEYUP, 0
' ESC up
keybd_event VK_ESCAPE, intScanEsc, KEYEVENTF_KEYUP, 0
SendKeys ("u")
End Sub
OR
you can use an API
I belive it's:
But i'm not that great with API's so you better check with someone.Code:Public Declare Function SuspendThread Lib "kernel32" Alias "SuspendThread" (ByVal hThread As Long) As Long
Hope that helps,
D!m
Ok. I just re-installed windows so I can't test that right away, but after I re-install vb that will be the first thing I'll do with it.
So thanks alot,
Worf