[belajar-excel] Macro Capslock On

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[belajar-excel] Macro Capslock On

Andrie -
Suhu Excel,
Mohon bantuannya untuk macro excel auto on capslockThanks

Kid
Reply | Threaded
Open this post in threaded view
|

Re: [belajar-excel] Macro Capslock On

Kid
Administrator
pakai vba, dan pakai winapi ya...
1. disebuah module general, copas script ini :
Private Type ByteKeyboard
    arrKBD(0 To 255) As Byte
End Type

#If VBA7 Then
    Private Declare PtrSafe Function GetKeyState Lib "user32" (ByVal
nVirtKey As Long) As Long
    Private Declare PtrSafe Function GetKeyboardState Lib "user32" (kbArray
As ByteKeyboard) As Long
    Private Declare PtrSafe Function SetKeyboardState Lib "user32" (kbArray
As ByteKeyboard) As Long
#Else
    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As
Long) As Long
    Private Declare Function GetKeyboardState Lib "user32" (kbArray As
ByteKeyboard) As Long
    Private Declare Function SetKeyboardState Lib "user32" (kbArray As
ByteKeyboard) As Long
#End If

Private byteKBD As ByteKeyboard

Public Sub MengOnken(Optional bState As Boolean = False)
    GetKeyboardState byteKBD
    byteKBD.arrKBD(20) = CByte(Abs(bState))
    SetKeyboardState byteKBD
End Sub

2. di module Thisworkbook, buat event workbook open, lalu isi dengan bunyi
script berikut :
         MengOnken  true   'untuk meng-on-ken capslock secara paksa

3. kalau pengen sebelum workbook di tutup si capslock dipaksa off :
    > masih di module thisworkbook, buat event beforeclose, isi dengan
script :
         MengOnken  false   'untuk meng-off-ken capslock secara paksa

On Thu, Feb 27, 2020 at 12:09 PM Andrie - [hidden email] [belajar-excel]
<[hidden email]> wrote:

>
>
> Suhu Excel,
>
> Mohon bantuannya untuk macro excel auto on capslock
> Thanks
>
>
>
>