[ 初めての方へ | 一覧(最新更新順) | 全文検索 | 過去ログ ]
『マクロでワークブックではないWindow名を取得できる?』(リップス)
マクロの処理内で、 現在開いているWindow (Excelワークブックではなく通常タスクバーに出ているすべてのWindowが対象で) の名称がとれますでしょうか。 やりたいことは、Window名で、"AAAA" が含まれるものが開かれているかどうかを 判定したいと思っています。 ※Window名といっているのは、Windowの一番上に表示されているタイトル部分をさしています。
> ※Window名といっているのは、Windowの一番上に表示されているタイトル部分をさしています。
Windowの一番上に表示されているタイトルは、ワークブックの名前のはずですが? (P)
「GetWindowText api 」のキーワードでWEB検索してみてください。 私はまだAPI関数は理解していません。 (みやほりん)(-_∂)b
>Windowの一番上に表示されているタイトルは、ワークブックの名前のはずですが? ワークブックでなくて、Excel以外の違うアプリケーションで開かれた全部のウィンドウ名が取得したいのです。
(みやほりん)さん 回答ありがとうございます。 GetWindowText api で検索して見ます。 ちなみに、API関数というのはなんでしょうか。(リップス)
だから、理解してないんだってば・・・。 http://www.kanazawa-net.ne.jp/~pmansato/WinApps.htm (みやほりん)(-_∂)b
いろいろと 教えてもらったキーワードで出たページをみながら 以下のように自分で作ってみたのですが、うまく動きません。 どなたかわかる方いらっしゃるでしょうか(;_;)。(リップス)
'標準モジュール Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, lPalam As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long Public Declare Function IsWindowVisible Lib "user32" _ (ByVal hWnd As Long) As Long
Public Declare Function GetWindow Lib "user32" _ (ByVal hWnd As Long, ByVal wCmd As Long) As Long
'************************************************************************** ' 定数宣言 '************************************************************************** 'GetWindowで使用 Public Const GW_OWNER = 4& Public gname
'標準モジュール Public Function Rekkyo(ByVal Handle As Long) As Boolean
Dim Ret As Long Dim Leng As Long Dim Name As String
'バッファ確保 Name = String(255, Chr(0)) Leng = Len(Name)
'名前を取得する Ret = GetWindowText(Handle, Name, Leng) 'リストボックスに追加していく If Ret <> 0 And (IsWindowVisible(Handle)) _ And (GetWindow(Handle, GW_OWNER) = 0) _ And (Left(Name, 7) <> "Progman") Then gname = gname & Name
'次にいく Rekkyo = True
End Function
'ここからはフォームの処理 Private Sub a() gname = "" Dim Ret As Long Ret = EnumWindows(AddressOf Rekkyo, 0) If Ret Then MsgBox gname End If End Sub
この辺のことはご近所さん辺りが詳しいんじゃないのかな・・・。 最近お見えになっていないようなので呼んでみようかな・・・? 壁|*'O')w オーイ!! ご近所さ〜〜〜〜〜ん。
(川野鮎太郎)
これ、参考にすればできるかと。 (ramrun)
Option Explicit
Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Declare Function GetWindowTextLength Lib "user32" Alias _ "GetWindowTextLengthA" (ByVal hWnd As Long) As Long
Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" _ (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function IsWindowVisible Lib "user32" (ByVal hWnd As Long) As Long
Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Const GW_OWNER = 4
Public Function EnumWndProc(ByVal hWnd As Long, lParam As Long) As Long Dim 文字数 As Long Dim テキスト As String Dim 最終行 As Long
If Not 列挙OK(hWnd) Then EnumWndProc = 1 Exit Function End If
文字数 = GetWindowTextLength(hWnd) 最終行 = Cells(65536, 1).End(xlUp).Row + 1
テキスト = String(文字数 + 1, vbNullChar) Call GetWindowText(hWnd, テキスト, Len(テキスト))
Cells(最終行, 1).Value = Left(テキスト, InStr(テキスト, vbNullChar) - 1)
EnumWndProc = 1 End Function
Function 列挙OK(hWnd As Long) If IsWindowVisible(hWnd) = 0 Then 列挙OK = False ElseIf GetWindow(hWnd, GW_OWNER) <> 0 Then 列挙OK = False ElseIf GetWindowTextLength(hWnd) = 0 Then 列挙OK = False Else 列挙OK = True End If End Function
Sub test() Call EnumWindows(AddressOf EnumWndProc, 0) End Sub
作ってみたので、一応書いておきます。 でも、これであっているのかは知りません。(アカギ)
できました! 皆様ありがとうございました(^^ゞ(リップス)
[ 一覧(最新更新順) ]
YukiWiki 1.6.7 Copyright (C) 2000,2001 by Hiroshi Yuki.
Modified by kazu.