ein von mir sehr geschätzter "NUMLOCK" CODE von NEPUMUK (Danke nochmals!!!), als Abschluss von SendKeys Befehlen, funktioniert mit 32-Bit perfekt. Er sieht so aus:
Option Explicit
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 Function GetKeyboardState Lib "user32.dll" ( _
ByRef pbKeyState As KeyboardBytes) As Long
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private pbKeyState As KeyboardBytes
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_KEYDOWN = &H0
Private Function Get_Value() As Boolean
Call GetKeyboardState(pbKeyState)
Get_Value = pbKeyState.kbByte(vbKeyNumlock) And 1
End Function
Private Sub Set_Value()
Call keybd_event(vbKeyNumlock, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYDOWN, 0)
Call keybd_event(vbKeyNumlock, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End Sub
Public Sub NUMLOCK_True()
If Not Get_Value Then Call Set_Value
End Sub
Nun unter 64-Bit kommt aber die Meldung: "Der CODE muss für 64-Bit aktualisiert werden ... Überarbeiten Sie DCLARE Anweisungen und markieren sie sie mit dem Ptr-Safe Attribute".
Habe das versucht, aber anscheinend nicht richtig. Die Fehlermeldung kommt zwar nicht mehr, aber NumLock wird auch nicht wieder aktivert... Hier mein Versuch:
Option Explicit
Private Declare PtrSafe Sub keybd_event Lib "user32.dll" ( _
ByVal bVk As Byte, _
ByVal bScan As Byte, _
ByVal dwFlags As Long, _
ByVal dwExtraInfo As Long)
Private Declare PtrSafe Function GetKeyboardState Lib "user32.dll" ( _
ByRef pbKeyState As KeyboardBytes) As Long
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private pbKeyState As KeyboardBytes
Private Const KEYEVENTF_EXTENDEDKEY = &H1
Private Const KEYEVENTF_KEYUP = &H2
Private Const KEYEVENTF_KEYDOWN = &H0
Private Function Get_Value() As Boolean
Call GetKeyboardState(pbKeyState)
Get_Value = pbKeyState.kbByte(vbKeyNumlock) And 1
End Function
Private Sub Set_Value()
Call keybd_event(vbKeyNumlock, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYDOWN, 0)
Call keybd_event(vbKeyNumlock, &H45, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0)
End Sub
Public Sub NUMLOCK_True()
If Not Get_Value Then Call Set_Value
End Sub
Hat jemand einen Tipp, was noch angepast werden muss? GOOGLE sagt was von "Zu beachten ist imho noch, dass der Rückgabewert den Type-Alias LongPtr bekommt . Der wird bei 64-Bit-Version zum Typ LongLong und bei 32-Bit zumTyp Long aufgelöst.". Aber das verstehe ich nicht. Da reicht wohl mein VBA nicht aus :-(.
1000 DANK für Eure Tipps