Skip to content

Instantly share code, notes, and snippets.

@barrackdo
Created February 29, 2012 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barrackdo/1942922 to your computer and use it in GitHub Desktop.
Save barrackdo/1942922 to your computer and use it in GitHub Desktop.
[sleipnir] OneKeyActionKaiSetting
(function(){
var pnir = sleipnir.api;
var fso = new ActiveXObject('Scripting.FileSystemObject');
var usrRsrc = fso.BuildPath(sleipnir.UserFolder, "UserResource");
var okaPath = fso.BuildPath(usrRsrc, "OneKeyAction");
var txtPath = fso.BuildPath(okaPath, "settings.txt");
if(!fso.FolderExists(usrRsrc)) {
fso.CreateFolder(usrRsrc);
}
if(!fso.FolderExists(okaPath)) {
fso.CreateFolder(okaPath);
}
if(!fso.FileExists(txtPath)) {
try{
var strm = fso.CreateTextFile(txtPath, true, false);
for(var i = 0; i < 0xff; i++) {
strm.WriteLine("\t");
}
strm.Write("\t");
}finally{
strm.Close();
}
}
var stream = fso.OpenTextFile(txtPath, 1, false, -2);
var text = stream.ReadAll().split(/\r\n/);
stream.Close();
var keyArray = {
"0x00" : text[0].split('\t')[1],
"0x01" : text[1].split('\t')[1],
"0x02" : text[2].split('\t')[1],
"0x03" : text[3].split('\t')[1],
"0x04" : text[4].split('\t')[1],
"0x05" : text[5].split('\t')[1],
"0x06" : text[6].split('\t')[1],
"0x07" : text[7].split('\t')[1],
"0x08(BS)" : text[8].split('\t')[1],
"0x09(Tab)" : text[9].split('\t')[1],
"0x0a" : text[10].split('\t')[1],
"0x0b" : text[11].split('\t')[1],
"0x0c" : text[12].split('\t')[1],
"0x0d(Enter)" : text[13].split('\t')[1],
"0x0e" : text[14].split('\t')[1],
"0x0f" : text[15].split('\t')[1],
"0x10(Shift)" : text[16].split('\t')[1],
"0x11(Ctrl)" : text[17].split('\t')[1],
"0x12(Alt)" : text[18].split('\t')[1],
"0x13(P/B)" : text[19].split('\t')[1],
"0x14" : text[20].split('\t')[1],
"0x15" : text[21].split('\t')[1],
"0x16" : text[22].split('\t')[1],
"0x17" : text[23].split('\t')[1],
"0x18" : text[24].split('\t')[1],
"0x19" : text[25].split('\t')[1],
"0x1a" : text[26].split('\t')[1],
"0x1b(Esc)" : text[27].split('\t')[1],
"0x1c(変換)" : text[28].split('\t')[1],
"0x1d(無変換)" : text[29].split('\t')[1],
"0x1e" : text[30].split('\t')[1],
"0x1f" : text[31].split('\t')[1],
"0x20(Sp)" : text[32].split('\t')[1],
"0x21(PgUp)" : text[33].split('\t')[1],
"0x22(PgDn)" : text[34].split('\t')[1],
"0x23(End)" : text[35].split('\t')[1],
"0x24(Home)" : text[36].split('\t')[1],
"0x25(←)" : text[37].split('\t')[1],
"0x26(↑)" : text[38].split('\t')[1],
"0x27(→)" : text[39].split('\t')[1],
"0x28(↓)" : text[40].split('\t')[1],
"0x29" : text[41].split('\t')[1],
"0x2a" : text[42].split('\t')[1],
"0x2b" : text[43].split('\t')[1],
"0x2c(PrtSc)" : text[44].split('\t')[1],
"0x2d(Ins)" : text[45].split('\t')[1],
"0x2e(Del)" : text[46].split('\t')[1],
"0x2f" : text[47].split('\t')[1],
"0x30(0)" : text[48].split('\t')[1],
"0x31(1)" : text[49].split('\t')[1],
"0x32(2)" : text[50].split('\t')[1],
"0x33(3)" : text[51].split('\t')[1],
"0x34(4)" : text[52].split('\t')[1],
"0x35(5)" : text[53].split('\t')[1],
"0x36(6)" : text[54].split('\t')[1],
"0x37(7)" : text[55].split('\t')[1],
"0x38(8)" : text[56].split('\t')[1],
"0x39(9)" : text[57].split('\t')[1],
"0x3a" : text[58].split('\t')[1],
"0x3b" : text[59].split('\t')[1],
"0x3c" : text[60].split('\t')[1],
"0x3d" : text[61].split('\t')[1],
"0x3e" : text[62].split('\t')[1],
"0x3f" : text[63].split('\t')[1],
"0x40" : text[64].split('\t')[1],
"0x41(a)" : text[65].split('\t')[1],
"0x42(b)" : text[66].split('\t')[1],
"0x43(c)" : text[67].split('\t')[1],
"0x44(d)" : text[68].split('\t')[1],
"0x45(e)" : text[69].split('\t')[1],
"0x46(f)" : text[70].split('\t')[1],
"0x47(g)" : text[71].split('\t')[1],
"0x48(h)" : text[72].split('\t')[1],
"0x49(i)" : text[73].split('\t')[1],
"0x4a(j)" : text[74].split('\t')[1],
"0x4b(k)" : text[75].split('\t')[1],
"0x4c(l)" : text[76].split('\t')[1],
"0x4d(m)" : text[77].split('\t')[1],
"0x4e(n)" : text[78].split('\t')[1],
"0x4f(o)" : text[79].split('\t')[1],
"0x50(p)" : text[80].split('\t')[1],
"0x51(q)" : text[81].split('\t')[1],
"0x52(r)" : text[82].split('\t')[1],
"0x53(s)" : text[83].split('\t')[1],
"0x54(t)" : text[84].split('\t')[1],
"0x55(u)" : text[85].split('\t')[1],
"0x56(v)" : text[86].split('\t')[1],
"0x57(w)" : text[87].split('\t')[1],
"0x58(x)" : text[88].split('\t')[1],
"0x59(y)" : text[89].split('\t')[1],
"0x5a(z)" : text[90].split('\t')[1],
"0x5b(Win[L])" : text[91].split('\t')[1],
"0x5c(Win]R])" : text[92].split('\t')[1],
"0x5d(Menu)" : text[93].split('\t')[1],
"0x5e" : text[94].split('\t')[1],
"0x5f" : text[95].split('\t')[1],
"0x60(0[Ten])" : text[96].split('\t')[1],
"0x61(1[Ten])" : text[97].split('\t')[1],
"0x62(2[Ten])" : text[98].split('\t')[1],
"0x63(3[Ten])" : text[99].split('\t')[1],
"0x64(4[Ten])" : text[100].split('\t')[1],
"0x65(5[Ten])" : text[101].split('\t')[1],
"0x66(6[Ten])" : text[102].split('\t')[1],
"0x67(7[Ten])" : text[103].split('\t')[1],
"0x68(8[Ten])" : text[104].split('\t')[1],
"0x69(9[Ten])" : text[105].split('\t')[1],
"0x6a(*[Ten])" : text[106].split('\t')[1],
"0x6b(+[Ten])" : text[107].split('\t')[1],
"0x6c" : text[108].split('\t')[1],
"0x6d(-[Ten])" : text[109].split('\t')[1],
"0x6e(.[Ten])" : text[110].split('\t')[1],
"0x6f(/[Ten])" : text[111].split('\t')[1],
"0x90(NumLk)" : text[112].split('\t')[1],
"0x91(ScrLk)" : text[113].split('\t')[1],
"0x72" : text[114].split('\t')[1],
"0x73" : text[115].split('\t')[1],
"0x74" : text[116].split('\t')[1],
"0x75" : text[117].split('\t')[1],
"0x76" : text[118].split('\t')[1],
"0x77" : text[119].split('\t')[1],
"0x78" : text[120].split('\t')[1],
"0x79" : text[121].split('\t')[1],
"0x7a" : text[122].split('\t')[1],
"0x7b" : text[123].split('\t')[1],
"0x7c" : text[124].split('\t')[1],
"0x7d" : text[125].split('\t')[1],
"0x7e" : text[126].split('\t')[1],
"0x7f" : text[127].split('\t')[1],
"0x80" : text[128].split('\t')[1],
"0x81" : text[129].split('\t')[1],
"0x82" : text[130].split('\t')[1],
"0x83" : text[131].split('\t')[1],
"0x84" : text[132].split('\t')[1],
"0x85" : text[133].split('\t')[1],
"0x86" : text[134].split('\t')[1],
"0x87" : text[135].split('\t')[1],
"0x88" : text[136].split('\t')[1],
"0x89" : text[137].split('\t')[1],
"0x8a" : text[138].split('\t')[1],
"0x8b" : text[139].split('\t')[1],
"0x8c" : text[140].split('\t')[1],
"0x8d" : text[141].split('\t')[1],
"0x8e" : text[142].split('\t')[1],
"0x8f" : text[143].split('\t')[1],
"0x90" : text[144].split('\t')[1],
"0x91" : text[145].split('\t')[1],
"0x92" : text[146].split('\t')[1],
"0x93" : text[147].split('\t')[1],
"0x94" : text[148].split('\t')[1],
"0x95" : text[149].split('\t')[1],
"0x96" : text[150].split('\t')[1],
"0x97" : text[151].split('\t')[1],
"0x98" : text[152].split('\t')[1],
"0x99" : text[153].split('\t')[1],
"0x9a" : text[154].split('\t')[1],
"0x9b" : text[155].split('\t')[1],
"0x9c" : text[156].split('\t')[1],
"0x9d" : text[157].split('\t')[1],
"0x9e" : text[158].split('\t')[1],
"0x9f" : text[159].split('\t')[1],
"0xa0" : text[160].split('\t')[1],
"0xa1" : text[161].split('\t')[1],
"0xa2" : text[162].split('\t')[1],
"0xa3" : text[163].split('\t')[1],
"0xa4" : text[164].split('\t')[1],
"0xa5" : text[165].split('\t')[1],
"0xa6" : text[166].split('\t')[1],
"0xa7" : text[167].split('\t')[1],
"0xa8" : text[168].split('\t')[1],
"0xa9" : text[169].split('\t')[1],
"0xaa" : text[170].split('\t')[1],
"0xab" : text[171].split('\t')[1],
"0xac" : text[172].split('\t')[1],
"0xad" : text[173].split('\t')[1],
"0xae" : text[174].split('\t')[1],
"0xaf" : text[175].split('\t')[1],
"0xb0" : text[176].split('\t')[1],
"0xb1" : text[177].split('\t')[1],
"0xb2" : text[178].split('\t')[1],
"0xb3" : text[179].split('\t')[1],
"0xb4" : text[180].split('\t')[1],
"0xb5" : text[181].split('\t')[1],
"0xb6" : text[182].split('\t')[1],
"0xb7" : text[183].split('\t')[1],
"0xb8" : text[184].split('\t')[1],
"0xb9" : text[185].split('\t')[1],
"0xba(:)" : text[186].split('\t')[1],
"0xbb(;)" : text[187].split('\t')[1],
"0xbc(,)" : text[188].split('\t')[1],
"0xbd(-)" : text[189].split('\t')[1],
"0xbe(.)" : text[190].split('\t')[1],
"0xbf(/)" : text[191].split('\t')[1],
"0xc0(@)" : text[192].split('\t')[1],
"0xc1" : text[193].split('\t')[1],
"0xc2" : text[194].split('\t')[1],
"0xc3" : text[195].split('\t')[1],
"0xc4" : text[196].split('\t')[1],
"0xc5" : text[197].split('\t')[1],
"0xc6" : text[198].split('\t')[1],
"0xc7" : text[199].split('\t')[1],
"0xc8" : text[200].split('\t')[1],
"0xc9" : text[201].split('\t')[1],
"0xca" : text[202].split('\t')[1],
"0xcb" : text[203].split('\t')[1],
"0xcc" : text[204].split('\t')[1],
"0xcd" : text[205].split('\t')[1],
"0xce" : text[206].split('\t')[1],
"0xcf" : text[207].split('\t')[1],
"0xd0" : text[208].split('\t')[1],
"0xd1" : text[209].split('\t')[1],
"0xd2" : text[210].split('\t')[1],
"0xd3" : text[211].split('\t')[1],
"0xd4" : text[212].split('\t')[1],
"0xd5" : text[213].split('\t')[1],
"0xd6" : text[214].split('\t')[1],
"0xd7" : text[215].split('\t')[1],
"0xd8" : text[216].split('\t')[1],
"0xd9" : text[217].split('\t')[1],
"0xda" : text[218].split('\t')[1],
"0xdb([)" : text[219].split('\t')[1],
"0xdc(\\[Yen])" : text[220].split('\t')[1],
"0xdd(])" : text[221].split('\t')[1],
"0xde(^)" : text[222].split('\t')[1],
"0xdf" : text[223].split('\t')[1],
"0xe0" : text[224].split('\t')[1],
"0xe1" : text[225].split('\t')[1],
"0xe2(\\[Bk/])" : text[226].split('\t')[1],
"0xe3" : text[227].split('\t')[1],
"0xe4" : text[228].split('\t')[1],
"0xe5" : text[229].split('\t')[1],
"0xe6" : text[230].split('\t')[1],
"0xe7" : text[231].split('\t')[1],
"0xe8" : text[232].split('\t')[1],
"0xe9" : text[233].split('\t')[1],
"0xea" : text[234].split('\t')[1],
"0xeb" : text[235].split('\t')[1],
"0xec" : text[236].split('\t')[1],
"0xed" : text[237].split('\t')[1],
"0xee" : text[238].split('\t')[1],
"0xef" : text[239].split('\t')[1],
"0xf0(カナ)" : text[240].split('\t')[1],
"0xf1" : text[241].split('\t')[1],
"0xf2" : text[242].split('\t')[1],
"0xf3" : text[243].split('\t')[1],
"0xf4" : text[244].split('\t')[1],
"0xf5" : text[245].split('\t')[1],
"0xf6" : text[246].split('\t')[1],
"0xf7" : text[247].split('\t')[1],
"0xf8" : text[248].split('\t')[1],
"0xf9" : text[249].split('\t')[1],
"0xfa" : text[250].split('\t')[1],
"0xfb" : text[251].split('\t')[1],
"0xfc" : text[252].split('\t')[1],
"0xfd" : text[253].split('\t')[1],
"0xfe" : text[254].split('\t')[1],
"0xff" : text[255].split('\t')[1]
};
if(document.getElementById("OneKeyActionSetting") == null && pnir.AddressBarString.indexOf("http:///") == -1) {
var html = "<html><head><style>div{margin:.25em auto;}label{width:6.5em;text-align:right;margin-right:.5em}input{width:15em}</style></head><body id='OneKeyActionSetting'>";
for(var keyString in keyArray) {
if(keyString.match(/\(/) != null) {
html+= "<div><label for='key_" + keyString.substring(0, 4) + "'>" + keyString + "</label><input type='text' id='key_" + keyString.substring(0, 4) + "' value='" + keyArray[keyString] + "'></div>";
}else {
html+= "<input type='hidden' id='key_" + keyString.substring(0, 4) + "' value='" + keyArray[keyString] + "'>";
}
}
html += "</body></html>";
var nw = pnir.NewWindow('about:blank', true);
var doc = pnir.GetDocumentObject(nw);
if (doc == null) {
alert('documentオブジェクトを作成できません');
}
doc.write(html);
}else {
var ipt = document.getElementsByTagName("input");
var n = 0;
try{
stream = fso.CreateTextFile(txtPath, true, false);
for(var keyString in keyArray) {
stream.WriteLine(keyString + "\t" + ipt[n].value);
n++;
}
stream.Write("\t");
}finally{
stream.Close();
}
alert("OK");
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment