Live-Forum - Die aktuellen Beiträge
Datum
Titel
29.03.2024 13:14:12
28.03.2024 21:12:36
28.03.2024 18:31:49
Anzeige
Archiv - Navigation
1212to1216
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

NUMLOCK-Taste dauerhaft aktivieren

NUMLOCK-Taste dauerhaft aktivieren
Franz
Hallo Freunde,
In vielen Foren wurde ich auf die Problematik aufmerksam dass NUMLOCK in Verbindung mit SENDKEYS-Befehle sich gerne deaktiviert. Habe lediglich 1 Sendkey ESC und 1 RIGHT im Einsatz in einer SelectionChange Routine. Ich kann darauf nicht verzichten. Die Lösung mit der REGEDIT Änderung kann ich auch nicht gebrauchen. Welcher Experte kann mir eine stabile Lösung anbieten damit die NUM-Taste dauerhaft leuchtet?
Der Einsatz von
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function apiGetKeyState Lib "user32" Alias "GetKeyState" (ByVal lngVirtKey As Long) As Integer
Mit den entsprechenden Routinen hat mich bis jetzt nicht nur teilweise weiter gebracht.
Ansonsten werde ich noch Lehrgeld zahlen und weiter tüfteln müssen.
Tschüss!
Franz D.

4
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Benutzer
Anzeige
AW: NUMLOCK-Taste dauerhaft aktivieren
01.05.2011 20:47:13
Hajo_Zi
Hallo Franz,
einfach wieder einschalten.
Option Explicit
' dies geht nicht unter XP
Const VK_NUMLOCK = &H90
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private kbArray As KeyboardBytes
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Sub Numlock_ein()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 1
SetKeyboardState kbArray
End Sub
Sub Numlock_aus()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = 0
SetKeyboardState kbArray
End Sub
Sub Numlock_umkehren()
GetKeyboardState kbArray
kbArray.kbByte(VK_NUMLOCK) = IIf(kbArray.kbByte(VK_NUMLOCK) = 1, 0, 1)
SetKeyboardState kbArray
End Sub
'von Jörg Lorenz

Gruß Hajo
Anzeige
AW: NUMLOCK-Taste dauerhaft aktivieren
01.05.2011 20:57:08
Franz
Hallo Hajo!
Herzlichen Dank zuerst.
Habe dies von der Herber-CD bereits ausprobiert, läuft leider nicht bei mir(Windows 7).
Gruß
Franz D.
AW: NUMLOCK-Taste dauerhaft aktivieren
01.05.2011 21:01:32
Hajo_Zi
Halo Franz,
dann nächstes Beispiel, das geht unter Windows 7
Option Explicit
Private Declare Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer
Private Declare Function GetVersionEx Lib "kernel32" _
Alias "GetVersionExA" (lpVersionInformation As _
OSVERSIONINFO) As Long
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 SetKeyboardState Lib "user32" _
(lppbKeyState As Byte) As Long
Private Const VER_PLATFORM_WIN32_NT = 2
Private Const VER_PLATFORM_WIN32_WINDOWS = 1
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
' Numlock
Private Const VK_NUM = &H90
Private keys(0 To 255) As Byte
' Großbuchstaben
Private Const VK_CAPS = &H14
' Rollen
Private Const VK_SCROLL = &H91
Private Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwMajorVersion As Long
dwMinorVersion As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
Private oSv As OSVERSIONINFO
Private Function KeyStatus(NumKey) As Boolean
Dim bInsertKeyState As Boolean
oSv.dwOSVersionInfoSize = Len(oSv)
GetVersionEx oSv
GetKeyboardState keys(0)
KeyStatus = keys(NumKey)
End Function
Private Sub Switch(NumKey, OnOff As Boolean)
If (KeyStatus(NumKey)  OnOff) Then
If (oSv.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS) Then
keys(NumKey) = 1
SetKeyboardState keys(0)
ElseIf (oSv.dwPlatformId = VER_PLATFORM_WIN32_NT) Then
keybd_event NumKey, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
keybd_event NumKey, &H45, KEYEVENTF_EXTENDEDKEY Or _
KEYEVENTF_KEYUP, 0
End If
End If
End Sub
Private Sub KeyOn()
' Numlock
Switch VK_NUM, 1
' Großbuchstabe
'Switch VK_CAPS, 1
' Rollen
'Switch VK_SCROLL, 1
End Sub
Private Sub KeyOff()
' NumLock
Switch VK_NUM, 0
' GroßBuchstabe
'Switch VK_CAPS, 0
' Rollen
'Switch VK_SCROLL, 0
End Sub
Public Sub NumStatus()
' NumLock
If KeyStatus(VK_NUM) = False Then
' GroßBuchstabe
'If KeyStatus(VK_CAPS) = False Then
' Rollen
'If KeyStatus(VK_SCROLL) = False Then
Call KeyOn
End If
End Sub
' Will
' http://clever-forum.de/ _
read.php?11,237481,237501#msg-237501
Gruß Hajo
Anzeige
AW: NUMLOCK-Taste dauerhaft aktivieren
01.05.2011 21:38:28
Franz
Hallo Hajo,
Habe "NumStatus" hier und da platziert. Es funktionniert schon stabiler aber nicht immer. Ich werde jetzt weiter testen in/mit welchen Events "NumStatus" am besten arbeitet.
Falls ich von dir keine weitere Tipps bekomme, wünsche ich dir jetzt eine stressfreie Woche.
Franz D.

17 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige