Skip to content

Instantly share code, notes, and snippets.

@cress-cc

cress-cc/SendMessage.cls

Last active Apr 12, 2019
Embed
What would you like to do?
VBAでメモ帳起動して貼り付けるやつ
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hwndParent As Long, _
ByVal hwndChildAfter As Long, _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal msg As Long, _
ByVal wParam As Long, _
ByVal lParam As String) As Long
Private Const WM_SETTEXT = &HC
Public Sub Main()
Dim hApp As Long
Dim hEdit As Long
Call Shell("notepad", vbNormalFocus)
hApp = FindWindow("NotePad", vbNullString)
hEdit = FindWindowEx(hApp, 0, "Edit", vbNullString)
Call SendMessage(hEdit, WM_SETTEXT, 0, "じゅげむじゅげむごこうのすりきれ")
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment