Results 1 to 4 of 4

Thread: Suspend mode

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    11
    How do I turn the computer to suspend mode with vb-code?

    Thanks in advance
    Worf
    "64K should be enough"

  2. #2
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    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
    Dim

  3. #3
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    here ya go:
    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
    See where that "u" is, replace it with "s" or whatever char is unerlined in the start menu.

    OR
    you can use an API
    I belive it's:
    Code:
    Public Declare Function SuspendThread Lib "kernel32" Alias "SuspendThread" (ByVal hThread As Long) As Long
    But i'm not that great with API's so you better check with someone.

    Hope that helps,
    D!m
    Dim

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    11
    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
    "64K should be enough"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width