Results 1 to 2 of 2

Thread: Fun thing I found

  1. #1

    Thread Starter
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986

    Talking

    Look at this fun code snippets I got from the API-Guide while searching for cool api-calls

    Code:
    Option Explicit
    
    Const VK_CAPITAL = &H14
    Const VK_NUMLOCK = &H90
    Const VK_SCROLL = &H91
    Const VK_USED = VK_SCROLL
    Private Type KeyboardBytes
         kbByte(0 To 255) As Byte
    End Type
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Long
    Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
    Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
    Dim kbArray As KeyboardBytes, CapsLock As Boolean, kbOld As KeyboardBytes
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        'Get the current keyboardstate
        GetKeyboardState kbOld
        'Hide the form
        Me.Hide
        MsgBox "Keep your eyes on the little num-, shift- and scrolllock lights on the keyboard."
        TurnOff VK_CAPITAL
        TurnOff VK_NUMLOCK
        TurnOff VK_SCROLL
        Sleep 1000
        TurnOn VK_NUMLOCK
        Sleep 100
        TurnOn VK_CAPITAL
        Sleep 100
        TurnOn VK_SCROLL
        Sleep 300
        TurnOff VK_NUMLOCK
        Sleep 100
        TurnOff VK_CAPITAL
        Sleep 100
        TurnOff VK_SCROLL
        Sleep 500
        TurnOn VK_NUMLOCK
        TurnOn VK_SCROLL
        Sleep 200
        TurnOff VK_NUMLOCK
        TurnOff VK_SCROLL
        Sleep 200
        TurnOn VK_NUMLOCK
        TurnOn VK_SCROLL
        Sleep 200
        TurnOff VK_NUMLOCK
        TurnOff VK_SCROLL
        Sleep 200
        TurnOn VK_CAPITAL
        Sleep 200
        TurnOff VK_CAPITAL
        Sleep 200
        TurnOn VK_CAPITAL
        Sleep 200
        TurnOff VK_CAPITAL
        Sleep 200
        TurnOn VK_NUMLOCK
        TurnOn VK_SCROLL
        Sleep 200
        TurnOff VK_NUMLOCK
        TurnOff VK_SCROLL
        Sleep 200
        TurnOn VK_NUMLOCK
        TurnOn VK_SCROLL
        Sleep 200
        TurnOff VK_NUMLOCK
        TurnOff VK_SCROLL
        Sleep 200
        TurnOn VK_CAPITAL
        Sleep 400
        TurnOff VK_CAPITAL
        Sleep 200
        TurnOn VK_NUMLOCK
        Sleep 100
        TurnOn VK_CAPITAL
        Sleep 100
        TurnOn VK_SCROLL
        Sleep 300
        TurnOff VK_SCROLL
        Sleep 100
        TurnOff VK_CAPITAL
        Sleep 100
        TurnOff VK_NUMLOCK
        Sleep 1000
        Unload Me
    End Sub
    Private Sub TurnOn(vkKey As Long)
        'Get the keyboard state
        GetKeyboardState kbArray
        'Change a key
        kbArray.kbByte(vkKey) = 1
        'Set the keyboard state
        SetKeyboardState kbArray
    End Sub
    Private Sub TurnOff(vkKey As Long)
        'Get the keyboard state
        GetKeyboardState kbArray
        'change a key
        kbArray.kbByte(vkKey) = 0
        'set the keyboard state
        SetKeyboardState kbArray
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'restore the old keyboard state
        SetKeyboardState kbOld
    End Sub
    sorry if this disturbs anyone, but it thought it was fun to share with all-ya
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Jop:
    I can see the lawsuits coming now....I'm temporarily blind.

    LOL
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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