Skip to content

Instantly share code, notes, and snippets.

@kumatti1
kumatti1 / Module1.bas
Last active February 20, 2024 15:47
GetProcAddressHook2
Option Explicit
Private Declare PtrSafe Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As LongPtr
Private Declare Function IsBadWritePtr Lib "kernel32" _
(ByVal lp As Long, ByVal ucb As Long) As Long
Private Declare Function VirtualProtect Lib "kernel32" _
(ByVal lpAddress As Long, ByVal dwSize As Long, _
ByVal flNewProtect As Long, lpflOldProtect As Long) As Long
Private Declare Function VirtualAlloc Lib "kernel32" _
(ByVal lpAddress As Long, ByVal dwSize As Long, _
@kumatti1
kumatti1 / gist:2165098
Created March 22, 2012 22:26
DHTML Timer
Option Explicit
'http://www.ka-net.org/office/of12.html
'Microsoft HTML Object Library
Private d As MSHTML.HTMLDocument
Private w As MSHTML.IHTMLWindow2
Private TimerId As Long
@kumatti1
kumatti1 / Module1.bas
Last active November 11, 2023 16:21
マウスカーソル直下の要素を取得
'目的の要素を選択
Sub Main()
Application.OnTime Now + TimeSerial(0, 0, 2), "GetSub"
End Sub
@kumatti1
kumatti1 / Class1.cls
Last active January 31, 2023 22:07
IE通知バー制御
Option Explicit
Implements IUIAutomationEventHandler
Private Sub IUIAutomationEventHandler_HandleAutomationEvent(ByVal sender As UIAutomationClient.IUIAutomationElement, ByVal eventId As Long)
Dim iElemFound As IUIAutomationElement
Set iElemFound = GetElement(o, sender, "はい(Y)", 0)
If iElemFound Is Nothing Then Exit Sub
If iElemFound.CurrentName = "はい(Y)" Then
Dim InvokePattern As IUIAutomationInvokePattern
@kumatti1
kumatti1 / gist:1726828
Created February 3, 2012 00:57
VBAでのTaskDialogIndirect(Win7SP1)
Option Explicit
Enum ICONS
TD_WARNING_ICON = 65535
TD_ERROR_ICON = 65534
TD_INFORMATION_ICON = 65533
TD_SHIELD_ICON = 65532
End Enum
Enum TASKDIALOG_FLAGS
@kumatti1
kumatti1 / gist:1856305
Created February 17, 2012 23:45
VBAでモニタ名を得る
Option Explicit
Enum MONITORS
MONITOR_DEFAULTTONULL
MONITOR_DEFAULTTOPRIMARY
MONITOR_DEFAULTTONEAREST
End Enum
Const PHYSICAL_MONITOR_DESCRIPTION_SIZE = 128 - 1
@kumatti1
kumatti1 / Module1.bas
Created March 1, 2014 09:30
Excel 2013 x64/Win8.1用SetWindowSubclassのサブクラス化VBAコード
Option Explicit
Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExW" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As LongPtr, ByVal lpsz2 As LongPtr) As LongPtr
Private Declare PtrSafe Function VirtualProtect Lib "kernel32" (ByVal lpAddress As Any, _
ByVal dwSize As LongLong, _
ByVal flNewProtect As Long, _
lpflOldProtect As Long) As Long
Const PAGE_EXECUTE_READ = &H20&
Const PAGE_EXECUTE = &H10
Private Declare PtrSafe Function SetWindowSubclass Lib "C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.16384_none_62475f7becb72503\comctl32.dll" (ByVal hWnd As LongPtr, ByVal pfnSubclass As LongPtr, ByVal uIdSubclass As LongPtr, ByVal dwRefData As LongPtr) As Long
Private Declare PtrSafe Function RemoveWindowSubclass Lib "C:\Windows\WinSxS\amd64_microsoft.windows.common-controls_6595b64144ccf1df_6.0.9600.16384_none_62475f7becb72503\comctl32.dll" (ByVal hWnd As LongPtr, ByVal pfnSubclass As LongPtr, ByVal uIdSubclass As Lon
@kumatti1
kumatti1 / UserForm1.frm
Created March 21, 2014 00:03
IEで同期オブジェクト
Option Explicit
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As LongPtr
bInheritHandle As Long
End Type
Private Declare Function MsgWaitForMultipleObjects Lib "user32" _
(ByVal nCount As Long, pHandles As Long, _
ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, _
ByVal dwWakeMask As Long) As Long
@kumatti1
kumatti1 / Module2.bas
Created March 28, 2014 09:29
エクスプローラ検索
Option Explicit
Declare Function ILCreateFromPathW& Lib "Shell32.dll" (ByVal pszPath&)
Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" _
(Destination As Any, Source As Any, ByVal Length As Long)
Declare Sub ILFree Lib "Shell32.dll" (ByVal pidl&)
Declare Function ILGetSize& Lib "Shell32.dll" (ByVal pidl&)
Private Declare _
Function InitVariantFromBuffer Lib "propsys.dll" ( _
ByVal pv As LongPtr, _
@kumatti1
kumatti1 / Module1.bas
Created March 21, 2014 23:25
SetTimerで同期オブジェクト
Option Explicit
Private Type SECURITY_ATTRIBUTES
nLength As Long
lpSecurityDescriptor As LongPtr
bInheritHandle As Long
End Type
Private Declare Function MsgWaitForMultipleObjects Lib "user32" _
(ByVal nCount As Long, pHandles As Long, _
ByVal fWaitAll As Long, ByVal dwMilliseconds As Long, _