Skip to content

Instantly share code, notes, and snippets.

View ymotchi's full-sized avatar

Yuki Sugimoto ymotchi

View GitHub Profile
@ymotchi
ymotchi / clipboardtest.xlsm
Created June 17, 2012 08:21
User Form of "Monitoring Clipboard in VBA"
Private Sub CheckBox1_Change()
If CheckBox1.Value = True Then
Module1.catchClipboard
Else
Module1.releaseClipboard
End If
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CheckBox1.Value = True Then
@ymotchi
ymotchi / clipboardtest.xlsm
Created June 17, 2012 07:43
Monitoring Clipboard in VBA
Option Explicit
Private Declare PtrSafe Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hWnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function CallWindowProc Lib "user32.dll" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As LongPtr, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal Msg As Long, ByVal wParam As LongPtr, ByVal lParam As LongPtr) As LongPtr
Private Declare PtrSafe Function SetClipboardViewer Lib "user32.dll" (ByVal hWndNewViewer As LongPtr) As LongPtr
Private Declare PtrSafe Function ChangeClipboardChain Lib "user32.dll" (ByVal hWndRemove As LongPtr, ByVal hWndNewNext As LongPtr) As Long
Private Declare Function IsClip