Send the "Scroll Lock: command using access VB

M

Mark

Hello all,

I need my program to send a double push of the Scroll lock button to the PC.
Is there a way to send this command, and if so, what function do I use?

Thanks for any guidance on where to start.

Mark
 
K

Klatuu

What do you mean by "to the PC"?

You might be able to use the SendKeys method. Look in VBA Help and see if
it will do what you want.
 
M

Mark

I'm trying to send the command to a KVM switch. If you double press "Scroll
Lock" it changes you to another computer screen. I'm trying to do this from
with in a program. The sendkeys is what I need, but I'm still looking for
the code the Scroll Lock button produces.
 
K

Klatuu

I don't believe it returns an ascii code you can capture.
I would suggest finding out what value the switch expects and see if you can
duplicate that.
 
K

Klatuu

I bet that would do it!
Okay, Mark, go to the site Doug posted and download the code. Paste it into
a standard module by itself. Give it a go and let us know how it works out.
 
S

Stuart McCall

Mark said:
I'm trying to send the command to a KVM switch. If you double press
"Scroll
Lock" it changes you to another computer screen. I'm trying to do this
from
with in a program. The sendkeys is what I need, but I'm still looking for
the code the Scroll Lock button produces.

1. Create a form and place a command button on it, called Command0
2. Paste the following code into the form's class module
3. Open the form and click the button
4. If it works (ie you switch ok) then fine. If not, play with the sleep
command till it works <g>

''' BEGIN CODE '''
Private Declare Sub keybd_event Lib "user32.dll" _
(ByVal bVk As Byte, ByVal bScan As Byte, _
ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)

Const VK_SCROLL = &H91
Const KEYEVENTF_KEYUP = &H2

Private Sub Command0_Click()
keybd_event VK_SCROLL, 0, 0, 0 'Press Scroll Lock
keybd_event VK_SCROLL, 0, KEYEVENTF_KEYUP, 0 'Release Scroll Lock
Sleep 100 'Wait a bit
keybd_event VK_SCROLL, 0, 0, 0 'Press Scroll Lock
keybd_event VK_SCROLL, 0, KEYEVENTF_KEYUP, 0 'Release Scroll Lock
End Sub
''' END CODE '''
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top