スタンプアルバム

LINEスタンプを制作しています

freecell マネージャ

freecellを番号順にクリアしていくために、WSHを使ってHTAアプリケーションを作りました。
下図がその実行画面です。
機能は次の2つです。
  1. 任意のゲーム番号から始められる
  2. ゲーム番号を順に進める

HTAアプリのソースコードはこちら。

<!DOCTYPE html>
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=x-sjis">
<hta:application scroll="no">
<script type="text/vbScript">
<!--
Dim Wsh, Fso, GameNo
'******** 起動時 ********
Sub window_onload()
  Dim pointfile
  window.moveTo 400, 300
  window.resizeTo 160, 600
  Set Fso = CreateObject("Scripting.FileSystemObject")
  Set pointfile = Fso.OpenTextFile("freecell記録.txt", 1, False, 0)
  GameNo = pointfile.ReadLine
  pointfile.Close
  document.all.txtSaveNo.Value = GameNo
  GameNo = GameNo + 1
  document.all.txtGameNo.Value = GameNo
  Set Wsh = CreateObject("Wscript.Shell")
  Wsh.Run "freecell.exe"
  Call setTimeout("selectGame()", 500)
End Sub
'******** ゲームの選択 ********
Sub selectGame()
  Wsh.AppActivate "フリーセル"
  Wsh.SendKeys("%(GS)")
  Wsh.SendKeys(GameNo & "{ENTER}")
End Sub
'******** 次のゲーム ********
Function NextGame()
  If Wsh.AppActivate("ゲーム番号の指定") = True Then
    SaveGame
    GameNo = document.all.txtGameNo.value + 1
    document.all.txtGameNo.value = GameNo
    Wsh.SendKeys(GameNo & "{ENTER}")
  End If
End Function
'******** ゲーム保存 ********
Function SaveGame()
  Dim pointfile
  Set pointfile = Fso.OpenTextFile("freecell記録.txt", 2, False, 0)
  pointfile.WriteLine(GameNo)
  pointfile.Close
  document.all.txtSaveNo.Value = GameNo
End Function
// -->
</script>
<title>T.T</title>
<style>
<!--
body,table{
  font-size: 11pt;
  color: #ffffff;
}
input{
  border-style: solid;
  border-width : 1px 1px 1px 1px;
  text-align:right;
}
.button {
  width: 36px;
  border-width: 2px;
  border-style : solid;
  border-top-color : #ffffff;
  border-left-color : #ffffff;
  border-bottom-color : #999999;
  border-right-color : #999999;
  background-color:#dddddd;
  color: #000099;
  cursor: pointer;
  font-size: 10pt;
  padding: 1px 16px;
  text-decoration: none;
}
.hvr-fade {
  display: inline-block;
  vertical-align: middle;
}
.hvr-fade:hover {
  background-color:#ff6633;
  color: #ffffff;
}
-->
</style>
</head>
<body leftmargin="5" rightmargin="2" style="background-color: #007D00;">
<table width="110" cellpadding="3">
  <tbody>
    <tr>
      <td style="font-size: 9pt;"><img src="icon.jpg" border="0" align="left" style="margin-right : 4px;"><br>
      by T.T<br>
      17.10.03</td>
    </tr>
    <tr>
      <td>現在 <input size="6" type="text" name="txtGameNo" value=""></td>
    </tr>
    <tr>
      <td>保存 <input size="6" type="text" name="txtSaveNo" value=""></td>
    </tr>
    <tr>
      <td style="font-weight:bold;"><a class="button hvr-fade" onclick="NextGame">Next</a></td>
    </tr>
    <tr>
      <td style="font-weight:bold;"><a class="button hvr-fade" onclick="SaveGame">Save</a></td>
    </tr>
  </tbody>
</table>
</body>
</html>


Freecellというホルダー内に以下のファイルを置いて「freecell.hta」を起動すればゲームが始まります。