<!DOCTYPE html>
<html>
<head>
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.1/css/bootstrap.css" />
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="hta.js"></script>
<script>
// ウインドウの位置とサイズ
centerWindow( 1100, 600 );
// テーブルの行作成用
var row_data = "";
// WSH 標準
var WshShell = newObject("WScript.Shell");
var WshNetwork = newObject("WScript.Network");
// 連想配列=ハッシュ=ディクショナリ
var Dict = newObject("Scripting.Dictionary");
// DB
var AdoCn = newObject("ADODB.Connection");
var AdoRs = newObject("ADODB.Recordset");
var AdoCat = newObject("ADOX.Catalog");
// バイナリデータ
var AdoStream = newObject("ADODB.Stream");
// Windows Shell
var objShell = newObject("Shell.Application");
// テキストファイル
var Fso = newObject("Scripting.FileSystemObject");
// メール送信
var Cdo = newObject("CDO.Message");
// 通信
var Http = newObject("Msxml2.ServerXMLHTTP");
// Base64
var Util = newObject("CAPICOM.Utilities");
// その他
var Guid = newObject("Scriptlet.TypeLib");
// 以下 要インストール
var Helper = newObject("Lbox.BatchHelper");
$(function(){
// ***************************
// ボタン表示位置微調整
// ***************************
$( ".btn" ).css({
"margin-top": "-4px"
});
$("#act1").on("click", function(){
if ( Helper == null ) {
alert("BatchHelper はインストールされていません");
return;
}
var filePath = Helper.OpenFileName( "ファイルの選択", "全て,*.*,CSV,*.csv", "", "", "" );
// DefaultDir (省略可): 初期ディレクトリ
// DefaultExt (省略可): デフォルトの拡張子
// DefaultName (省略可): デフォルトのファイル名
if( filePath == "" ) {
alert("ファイルの参照選択がキャンセルされました")
return;
}
var fileArray = [ filePath ];
loadTable( fileArray );
});
$("#act2").on("click", function(){
if ( Helper == null ) {
alert("BatchHelper はインストールされていません");
return;
}
var filePath = Helper.OpenFileNames( "ファイルの選択", "全て,*.*,CSV,*.csv", "", "" );
// DefaultDir (省略可): 初期ディレクトリ
// DefaultExt (省略可): デフォルトの拡張子
if( filePath == "" ) {
alert("ファイルの参照選択がキャンセルされました")
return;
}
var fileArray = filePath.split("\t");
loadTable( fileArray );
});
$("#act3").on("click", function(){
if ( Helper == null ) {
alert("BatchHelper はインストールされていません");
return;
}
var filePath = Helper.OpenFileName( "ファイルの選択", "TEXT,*.txt,CSV,*.csv", "", "", "" );
if( filePath == "" ) {
alert("ファイルの参照選択がキャンセルされました");
return;
}
var handle = Fso.OpenTextFile( filePath, 1 );
var textBuffer = handle.ReadAll();
var textArray = textBuffer.split( "\r\n" );
loadTable( textArray );
});
$("#act4").on("click", function(){
var objFolder = objShell.NameSpace(0x4);
var colItems = objFolder.Items();
var arrData = [];
for(i = 0; i < colItems.Count; i++) {
arrData.push(colItems.Item(i).Name);
}
loadTable( arrData );
});
});
</script>
<style>
html,body {
height: 100%;
}
body {
margin: 0;
}
/* ブロックを左右に表示 */
.ttl {
display: inline-block;
width: 120px;
vertical-align: top;
}
.entry {
display: inline-block;
}
.line {
margin-bottom: 0;
}
#head {
padding: 16px;
}
/* IFRAMEコントロール用 */
#head {
padding: 16px;
width: 100%;
height: 180px;
background-color: #e0e0e0;
}
#extend {
padding: 4px 16px;
display: block;
margin-left: auto;
margin-right: auto;
width: calc( 100% - 3px );
height: calc( 100% - 180px - 2px );
border: solid 2px #c0c0c0;
overflow: scroll;
}
.row_data td {
cursor: default!important;
}
</style>
</head>
<body>
<div id="head">
<p class="ttl">
ダイアログ
</p>
<p class="entry">
<input
id="act1"
class="ml-4 btn btn-outline-primary"
type="button"
value="ファイルを開く(BatchHelper)">
<input
id="act2"
class="ml-4 btn btn-outline-primary"
type="button"
value="ファイルを開く/複数(BatchHelper)">
</p>
<p class="line"></p>
<p class="ttl">
</p>
<p class="entry">
<input
id="act3"
class="ml-4 btn btn-outline-primary"
type="button"
value="SHIFT_JISファイルを読み込む">
<input
id="act4"
class="ml-4 btn btn-outline-primary"
type="button"
value="プリンタの一覧">
</p>
<p class="line"></p>
<h4 class="text-danger"></h4>
</div>
<div id="extend">
<table class="table table-hover">
<tbody id="tbl">
</tbody>
</table>
<br>
</div>
</body>
</html>