タイトル | : Re^5: 他アプリのTextBoxの文字取得について |
記事No | : 11691 |
投稿日 | : 2008/03/06(Thu) 17:02 |
投稿者 | : 翼 |
魔界の仮面弁士さん
ありがとうございます
> 状況を確認したいので、Declare の宣言部も含めて、 > コード全体を提示していただけないでしょうか?
その通りです Private Declare Function FindWindowA Lib "USER32" (ByVal cnm As String, ByVal cap As String) As Long Private Declare Function FindWindowW Lib "USER32" (ByVal cnm As String, ByVal cap As String) As Long Private Declare Function FindWindowExA Lib "USER32" (ByVal hpar As Long, ByVal hchi As Long, ByVal cnm As String, ByVal cap As String) As Long Private Declare Function FindWindowExW Lib "USER32" (ByVal hpar As Long, ByVal hchi As Long, ByVal cnm As String, ByVal cap As String) As Long Private Declare Function GetWindowTextA Lib "USER32" (ByVal hwd As Long, ByVal buf As String, ByVal bln As Long) As Long Private Declare Function GetWindowTextW Lib "USER32" (ByVal hwd As Long, ByVal buf As String, ByVal bln As Long) As Long Public Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function PostMessageA Lib "USER32" (ByVal hwd As Long, ByVal msg As Long, ByVal wpara As Long, ByVal lpara As Long) As Long Private Declare Function PostMessageW Lib "USER32" (ByVal hwd As Long, ByVal msg As Long, ByVal wpara As Long, ByVal lpara As Long) As Long Private Declare Function GetForegroundWindow Lib "USER32" () As Long Private Declare Function SetForegroundWindow Lib "USER32" (ByVal hWnd As Long) As Long Public Declare Function EnumChildWindows Lib "USER32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Public Declare Function GetClassName Lib "USER32" Alias "GetClassNameA" (ByVal hWnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
' 子クラスの列挙 Public Function EnumChildProc(ByVal hWnd As Long) As Long Dim ret As Long Dim Leng As Long Dim Name As String Dim s As String Dim buf(255) As Byte
On Error GoTo Ext
'バッファ確保 Name = String(255, Chr(0)) Leng = Len(Name) '名前を取得する 'ret = GetWindowText(hWnd, Name, Leng) ret = GetClassName(hWnd, Name, Leng) 'リストボックスに追加していく If ret <> 0 Then If InStr(1, Name, CHILD_CLASS) <> 0 Then ret = SendMessage(hWnd, WM_GETTEXT, MAX_BUFF, buf(0)) s = StrConv(buf, vbUnicode) Debug.Print s If Len(Trim(Left$(s, 9))) = 9 Then s = Left$(s, 9) Form1.Label11.Caption = s End If End If End If '次にいく EnumChildProc = True
Ext: End Function
|