Skip to content

Instantly share code, notes, and snippets.

@cress-cc
Last active April 12, 2019 01:32
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 cress-cc/92896bab9f119377aba2f3c6e7bc0722 to your computer and use it in GitHub Desktop.
Save cress-cc/92896bab9f119377aba2f3c6e7bc0722 to your computer and use it in GitHub Desktop.
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