Skip to content

Instantly share code, notes, and snippets.

@kumatti1
Created October 10, 2014 22:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kumatti1/e681c4ba4a946bdf9b9c to your computer and use it in GitHub Desktop.
Save kumatti1/e681c4ba4a946bdf9b9c to your computer and use it in GitHub Desktop.
ImageMerge制御2
Option Explicit
Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
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
Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Declare PtrSafe Function EnumChildWindows Lib "user32" (ByVal hWndParent As LongPtr, ByVal lpEnumFunc As LongPtr, ByVal lParam As LongPtr) As Long
Declare PtrSafe Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As LongPtr, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Declare PtrSafe Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As LongPtr, ByVal lpString As String, ByVal cch As Long) As Long
Const WM_SETTEXT = &HC
Const CB_SELECTSTRING = &H14D
Const BM_CLICK = &HF5
Const WM_GETTEXT = &HD
Private i As Long
Sub Main()
i = 0
Dim howner As LongPtr
Shell "ImageMerge.exe", vbNormalFocus
Do
DoEvents
Sleep 1&
howner = FindWindowEx(0, 0, "TFormMain", "ImageMerge")
Loop Until howner <> 0
EnumChildWindows howner, AddressOf EnumChildProc, 0
End Sub
Private Function EnumChildProc( _
ByVal h As LongPtr, _
ByVal lParam As LongPtr) As Long
Dim s1 As String
Dim s2 As String
s1 = String$(1024, 0)
s2 = String$(1024, 0)
GetClassName h, s1, Len(s1)
GetWindowText h, s2, Len(s2) - 1
s1 = Left$(s1, InStr(s1, vbNullChar) - 1)
s2 = Left$(s2, InStr(s2, vbNullChar) - 1)
'debug.print s1
'debug.print s2
Select Case True
Case s1 Like "TLabeledEdit"
Select Case i
Case 0
SendMessage h, WM_SETTEXT, 0, ByVal "20"
Case 1
SendMessage h, WM_SETTEXT, 0, ByVal "path2"
Case 2
SendMessage h, WM_SETTEXT, 0, ByVal "path1"
End Select
i = i + 1
End Select
EnumChildProc = 1
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment