Look at this fun code snippets I got from the API-Guide while searching for cool api-calls
sorry if this disturbs anyone, but it thought it was fun to share with all-yaCode: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![]()





Reply With Quote