Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default switch the "scroll" led with vba

Hi,

I want to switch the "scroll" led with vba on and of with different buttons
....

I want to switch on and off the scroll led with the following 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 Const VK_OEM_SCROLL = &H91
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer

Sub SCROLL_aktiv() 'SCROLL-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub

Sub SCROLL_inaktiv() ' SCROLL-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
----------------------------------------------------------------------------------------

with the scroll_aktiv procedure i can toggle between on and off. but it
should only switch on the led. with scroll_inaktiv i can't switch of the
led - and i don't know why

the following procedure for the num lock led works fine
------------------------------------------------------------------------------
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer

Sub NUM_TOGGLE()
' NUM-Lock drücken
' Zunächst niederdrücken und dann wieder loslassen
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End Sub

Sub NUM_aktiv() 'NUM-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub

Sub NUM_inaktiv() ' NUM-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
------------------------------------------------------------------------------------
thanks for any help ..
achim


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default switch the "scroll" led with vba

In W9x can do simply this (API's not posted)

Const VK_SCROLL As Long = &H91
Dim keys(0 To 255) As Byte
GetKeyboardState keys(0)
keys(VK_SCROLL) = 1
SetKeyboardState keys(0)

It seems in later versions need to do a bit more to switch the led, try
this -

http://support.microsoft.com/kb/177674

The example is aimed at VB(4/5/6) users, paste all incl Command1_Click into
a normal module and run (and perhaps rename) "Command1_Click".

Regards,
Peter T

"MicrosoftNews" wrote in message
...
Hi,

I want to switch the "scroll" led with vba on and of with different

buttons
...

I want to switch on and off the scroll led with the following 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 Const VK_OEM_SCROLL = &H91
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer

Sub SCROLL_aktiv() 'SCROLL-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub

Sub SCROLL_inaktiv() ' SCROLL-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyOEM_SCROLL) = 1) Then
keybd_event VK_OEM_SCROLL, 1, 0, 0
keybd_event VK_OEM_SCROLL, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
--------------------------------------------------------------------------

--------------

with the scroll_aktiv procedure i can toggle between on and off. but it
should only switch on the led. with scroll_inaktiv i can't switch of the
led - and i don't know why

the following procedure for the num lock led works fine
--------------------------------------------------------------------------

----
Private Declare Sub keybd_event Lib "user32" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Const VK_NUMLOCK = &H90
Private Const KEYEVENTF_KEYUP = &H2
Declare Function GetKeyState Lib "user32.dll" ( _
ByVal nVirtKey As Long) As Integer

Sub NUM_TOGGLE()
' NUM-Lock drücken
' Zunächst niederdrücken und dann wieder loslassen
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End Sub

Sub NUM_aktiv() 'NUM-Lock aktivieren (falls deaktiviert)
If Not (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub

Sub NUM_inaktiv() ' NUM-Lock deaktivieren (falls aktiviert)
If (GetKeyState(vbKeyNumlock) = 1) Then
keybd_event VK_NUMLOCK, 1, 0, 0
keybd_event VK_NUMLOCK, 1, KEYEVENTF_KEYUP, 0
End If
End Sub
--------------------------------------------------------------------------

----------
thanks for any help ..
achim




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Shortcut to switch from "fill down" to "copy" with mouse drag RJ Dake Excel Discussion (Misc queries) 3 August 13th 09 05:35 PM
Disabled "Switch Row/Column" when creating chart from a pivot tabl Gunder Charts and Charting in Excel 1 October 8th 08 08:48 AM
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Why does excell switch my stock symbol "ACN" to "CAN"? garron Setting up and Configuration of Excel 1 June 21st 07 02:35 AM
Scroll Bar missing "Control" tab in "Format Properties" dialog box Peter Rooney Excel Discussion (Misc queries) 5 August 24th 06 05:36 PM


All times are GMT +1. The time now is 06:10 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"