#6413
Aye Wong
メンバー

Yutakaさんは書きました:
Window オブジェクトの Visible プロパティを使用すると、ウィンドウが表示されている状態かどうかを判別することができます。ヘルプには書いていなかったので追加します。

http://jp.emeditor.com/help/macro/window/visible.htm

ありがとうございます。教えていただいたVisibleを使ってみましたが、まだ関係ないウィンドウが表示されるようです。コードは下のようになりますがどうしたらいいでしょうか?

#title=もう一つのウィンドウと並べて表示

function ShowMenu(menuDef)
{
function Array2Menu(a, commands)
{
var menu = CreatePopupMenu();
for (var i = 0 ; i < a.length ; ++i)
{
if ((a.submenu != null) && a.submenu instanceof Array) {
var submenu = Array2Menu(a
.submenu, commands);
menu.AddPopup(a
.label, submenu);
} else {
var index = commands.length;
if (index == 0) {
index = 1;
}
if (a
.label == “—-“) {
menu.Add(“”, 0, eeMenuSeparator);
} else {
var flags = (a
.checked ? eeMenuChecked : 0) | (a.grayed ? eeMenuGrayed : 0);
menu.Add(a
.label, index, flags);
commands[index] = a
;
}
}
}
return menu;
}
var commands = [];
var menu = Array2Menu(menuDef, commands);
var commandIndex = menu.Track(/*eePosMouse*/);
if (commandIndex > 0) {
commands[commandIndex].command();
return true;
}
return false;
}

function getDesktopSize()
{
var html = new ActiveXObject(“htmlfile”);
return {width:(html.Script.screen.width), height:(html.Script.screen.height)};
}

desktop = getDesktopSize();

function TileHorizontally(w1, w2)
{
w1.SetPosition(0, 0, desktop.width, desktop.height/2);
w2.SetPosition(0, desktop.height/2, desktop.width, desktop.height/2);
w1.SetForeground();
w2.SetForeground();
}

function TileVertically(w1, w2)
{
w1.SetPosition(0, 0, desktop.width/2, desktop.height);
w2.SetPosition(desktop.width/2, 0, desktop.width/2, desktop.height);
w1.SetForeground();
w2.SetForeground();
}

function genMenuDef()
{
var result = [];
for (var i = 1 ; i < shell.windows.Count ; ++i)
{
var w = shell.windows.Item(i);
if (!w.Valid) continue;
if (!w.Visible) continue;
result.push(
{label:w.Caption, submenu:[
{label:"とウィンドウを縦に並べる", w1:w, w2:this, command: function() {TileHorizontally(this.w1, this.w2)}},
{label:"とウィンドウを横に並べる", w1:w, w2:this, command: function() {TileVertically(this.w1, this.w2)}}
]}
);
}
return result;
}

ShowMenu(genMenuDef());