Skip to content

Instantly share code, notes, and snippets.

@Benshi
Created March 23, 2021 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Benshi/08d11ff7f6636b35f200f06cd762cc3b to your computer and use it in GitHub Desktop.
Save Benshi/08d11ff7f6636b35f200f06cd762cc3b to your computer and use it in GitHub Desktop.
マウスの主ボタンと副ボタンを入れ替える (VBA)
Option Explicit
#If VBA7 Then
Private Declare PtrSafe Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoW" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
#Else
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoW" (ByVal uAction As Long, ByVal uParam As Long, ByRef lpvParam As Any, ByVal fuWinIni As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
#End If
Public Property Let SwapMouseButton(bool As Boolean)
Const SPI_SETMOUSEBUTTONSWAP As Long = 33&
SystemParametersInfo SPI_SETMOUSEBUTTONSWAP, IIf(bool, 1&, 0&), ByVal 0&, ByVal 1&
End Property
Public Property Get SwapMouseButton() As Boolean
Const SM_SWAPBUTTON As Long = 23&
SwapMouseButton = CBool(GetSystemMetrics(SM_SWAPBUTTON))
End Property
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment