|
ウィンドウ位置を復元するのにどうしても秀丸メールを再起動する必要があっ
て、マクロも、秀丸エディタにその辺やらせるようにしました。
それで一応うまくいくようになったと思います。
秀丸エディタと秀丸メールの両方がインストールされてないと動かないですけ
ども、よかったらこれで試してみて欲しいです。2通り保存/復元出来るように
しました。
ライブラリにもアップロードしようかなぁと思います。
// HidemaruMail_SaveRestoreDesktop.mac
// デスクトップ保存/デスクトップ復元をする用のマクロ。
// 2012.08.21 by 斉藤秀夫
//
$key[0] = "xFrame";
$key[1] = "yFrame";
$key[2] = "cxFrame";
$key[3] = "cyFrame";
$key[4] = "xRecv";
$key[5] = "yRecv";
$key[6] = "xOuter0";
$key[7] = "yOuter0";
$key[8] = "xOuter1";
$key[9] = "yOuter1";
$key[10] = "xOuter2";
$key[11] = "yOuter2";
$key[12] = "xOuter3";
$key[13] = "yOuter3";
$key[14] = "cxOuter";
$key[15] = "cyOuter";
$key[16] = "cxOpen";
$key[17] = "cyOpen";
$key[18] = "cxAttach";
$key[19] = "xNotify";
$key[20] = "yNotify";
$key[21] = "xGrep";
$key[22] = "yGrep";
$key[23] = "cxGrep";
$key[24] = "cyGrep";
$key[25] = "xRemote";
$key[26] = "yRemote";
$key[27] = "cxRemote";
$key[28] = "cyRemote";
$key[29] = "xBook";
$key[30] = "yBook";
$key[31] = "cxBook";
$key[32] = "cyBook";
#keycount = 33;
openreg "LOCALMACHINE"
, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Hidemaru";
if( ! result ) {
message "秀丸エディタがインストールされてないか、または32bit版" +
"/64bit版の種類の違うバージョンがインストールされています。";
endmacro;
}
$hidemaruexe = getregstr( "InstallLocation" ) + "\\hidemaru.exe";
closereg;
openreg "LOCALMACHINE"
, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\TuruKame";
if( ! result ) {
message "秀丸メールがインストールされてないか、または32bit版/64" +
"bit版の種類の違うバージョンがインストールされています。";
endmacro;
}
$turukameexe = getregstr( "InstallLocation" ) + "\\turukame.exe";
closereg;
$inifile = macrodir + "\\HidemaruMail_SaveRestoreDesktop.ini";
#savedesktop = 0;
$section = "1";
if( argcount > 0 ) {
$section = getarg(0);
if( $section == "" ) {
$section = "1";
}
}
loaddll "tkinfo.dll";
if( result ) {
if( dllfunc("IsHidemaruMail") ) {
//秀丸メール上の場合
menu "デスクトップ復元 - 1", "デスクトップ復元 - 2"
, "\x01"
, "デスクトップ保存 - 1", "デスクトップ保存 - 2";
#menu = result;
if( #menu == 0 ) {
endmacro;
}
if( #menu == 1 ) {
#savedesktop = 0;
$section = "1";
} else if( #menu == 2 ) {
#savedesktop = 0;
$section = "2";
} else if( #menu == 4 ) {
question "現在のウィンドウ位置を「1」に保存します。" +
"よろしいですか?";
if( result != yes ) {
endmacro;
}
#savedesktop = 1;
$section = "1";
} else /*if( #menu == 5 )*/ {
question "現在のウィンドウ位置を「2」に保存します。" +
"よろしいですか?";
if( result != yes ) {
endmacro;
}
#savedesktop = 1;
$section = "2";
}
if( #savedesktop != 0 ) { //デスクトップ保存
#n = dllfunc("SaveConfig", 1);
goto Label_SaveRestoreDesktop;
}
//デスクトップ復元の場合は秀丸を起動してそこで実行する。
run "\"" + $hidemaruexe + "\" /x \"" + currentmacrofilename
+ "\" /a" + $section;
endmacro;
}
}
Label_SaveRestoreDesktop:
if( #savedesktop == 0 ) {
#handle = findwindowclass("TuruKameFrame");
if( #handle != 0 ) {
question "秀丸メールを再起動します。よろしいですか?";
if( result != yes ) {
endmacro;
}
Label_RetryTermination: ;
#n = sendmessage( #handle, 0x111, 40244, 0 );
//常駐秀丸メールも含めてすべて終了
#tick = tickcount;
while(1) {
#handle = findwindowclass("TuruKameFrame");
if( #handle == 0 ) {
break;
}
if( tickcount - #tick >= 2000 ) {
break;
}
sleep 100;
}
if( #handle != 0 ) {
question "秀丸メールが終了していません。再試行しますか?";
if( result != yes ) {
endmacro;
}
goto Label_RetryTermination;
}
}
}
#i = 0;
openreg "CURRENTUSER", "Software\\Hidemaruo\\TuruKame\\Config";
while( #i < #keycount ) {
if( #savedesktop == 0 ) {
//デスクトップ復元
#xy = getininum( $inifile, $section, $key[#i] );
writeregnum $key[#i], #xy;
} else {
//デスクトップ保存
#xy = getregnum( $key[#i] );
writeininum $inifile, $section, $key[#i], #xy;
}
#i = #i + 1;
}
closereg;
if( #savedesktop == 0 ) {
run $turukameexe;
quit;
}
|
|