Created
March 23, 2017 03:33
-
-
Save kumatti1/4172e69ff8b1e840ed6a415f67f64178 to your computer and use it in GitHub Desktop.
メモ帳のダイアログを閉じる
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
'参照設定 UIAutomationClient | |
Private Declare PtrSafe Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As LongPtr, ByVal hWnd2 As LongPtr, ByVal lpsz1 As String, ByVal lpsz2 As String) As LongPtr | |
Sub hoge() | |
Dim o As IUIAutomation | |
Dim e As IUIAutomationElement | |
Set o = New CUIAutomation | |
Dim h As LongPtr | |
h = FindWindowEx(0, 0, "#32770", "メモ帳") | |
If h = 0 Then Exit Sub | |
Set e = o.ElementFromHandle(ByVal h) | |
Dim iCnd As IUIAutomationCondition | |
Set iCnd = o.CreatePropertyCondition(UIA_NamePropertyId, "保存する(S)") | |
Dim Button As IUIAutomationElement | |
Set Button = e.FindFirst(TreeScope_Subtree, iCnd) | |
Dim InvokePattern As IUIAutomationInvokePattern | |
Set InvokePattern = Button.GetCurrentPattern(UIA_InvokePatternId) | |
InvokePattern.Invoke | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment