diff --git a/data/test-msoffice-20231219.json b/data/test-msoffice-20231219.json new file mode 100644 index 0000000..d42ea22 --- /dev/null +++ b/data/test-msoffice-20231219.json @@ -0,0 +1,59 @@ +{ + "description": "WelsonJS test profile for Microsoft Office", + "date": "2023-12-19", + "revision": "20231219r1", + "authors": [ + "Namhyeon Go " + ], + "links": [ + "https://github.com/gnh1201/welsonjs", + "https://catswords.social/@catswords_oss" + ], + "tags": [ + "javascript", + "microsoft", + "coffeescript", + "windows", + "typescript", + "html5", + "js", + "uri", + "desktop", + "ie", + "hta", + "es5", + "jscript", + "wsh", + "msoffice", + "mshtml", + "lolbins", + "lolbas", + "rescript", + "mshta" + ], + "schema": { + "version": "0.1" + }, + "tests": [ + { + "id": "open_excel_file", + "description": "마이크로소프트 엑셀 파일 열기 및 편집 가능 여부 확인", + "tags": ["Office", "Excel"] + }, + { + "id": "open_excel_with_chatgpt", + "description": "마이크로소프트 엑셀 파일 열기 및 ChatGPT를 이용한 편집 가능 여부 확인", + "tags": ["Office", "Excel"] + }, + { + "id": "open_powerpoint_file", + "description": "마이크로소프트 파워포인트 파일 열기 및 편집 가능 여부 확인", + "tags": ["Office", "PowerPoint"] + }, + { + "id": "open_word_file", + "description": "마이크로소프트 워드 파일 열기 및 편집 가능 여부 확인", + "tags": ["Office", "Word"] + } + ] +} diff --git a/officeloader.js b/officeloader.js index cebf696..73b661d 100644 --- a/officeloader.js +++ b/officeloader.js @@ -7,12 +7,13 @@ var ChatGPT = require("lib/chatgpt"); function main(args) { // EXAMPLE: cscript app.js officeloader + // TEST: cscript app.js testloader open_excel_file data\test-msoffice-20231219.json if (args.length > 0) { var filename = args[0]; var programfile = args[1]; open(filename, programfile); } else { - test(); + console.error("Insufficient arguments"); } } @@ -77,32 +78,4 @@ function open(filename, programfile) { } } -function test() { - // 엑셀 인스턴스 생성 - var excel = new Office.Excel(); - - // 질문 목록 - var questions = [ - "엄마가 좋아 아빠가 좋아?", - "나도 모르는 사이 내 통장에 100억이 입금되어 있다면?", - "내 친구가 술에 취해 뻗었는데 신민아가 단둘이 술 먹자고 한다면, 친구 버리고 가도 되나?", - "회사 야유회를 가서 과장님과 같은 텐트에서 자고 있는데 우리 텐트에 뱀이 들어왔다면 과장님 깨워야 되나, 안 깨우고 혼자 도망쳐야 되나?" - ]; - - // 엑셀 열기 - excel.open(); - - // 질문에 답하기 - var i = 1; - questions.forEach(function(x) { - var answer = ChatGPT.chat(x); - console.log("받은 답변:", answer); - excel.getCellByPosition(i, 1).setValue(answer); - i++; - }); - - // 엑셀 닫기 - //excel.close(); -} - exports.main = main; diff --git a/shoutcut.js b/shoutcut.js index 9df8fca..83904fa 100644 --- a/shoutcut.js +++ b/shoutcut.js @@ -1,3 +1,6 @@ +// shoutcut.js +// Namhyeon Go +// https://github.com/gnh1201/welsonjs var SHELL = require("lib/shell"); var SYS = require("lib/system"); diff --git a/testloader.js b/testloader.js index 899e5a8..732016a 100644 --- a/testloader.js +++ b/testloader.js @@ -1,22 +1,21 @@ // testloader.js +// Namhyeon Go +// https://github.com/gnh1201/welsonjs // load libraries var FILE = require("lib/file"); -// load the test profile -var profile = JSON.parse(FILE.readFile("data/test-oss-20231030.json", FILE.CdoCharset.CdoUTF_8)); - // implement the tests var test_implements = { // Ref 1: https://gist.github.com/CityRay/c56e4fa874af9370cc1a367bd43095b0 "es5_polyfills": function() { var parseIntIgnoresLeadingZeros = (function () { - return parseInt('010', 10) === 10; + return parseInt('010', 10) === 10; }()); console.log("parseIntIgnoresLeadingZeros: " + String(parseIntIgnoresLeadingZeros) + " (Default on the built-in engine: true)"); var DateISOString = (function () { - return !!(Date && Date.prototype && Date.prototype.toISOString); + return !!(Date && Date.prototype && Date.prototype.toISOString); }()); console.log("DateISOString: " + String(DateISOString) + " (Default on the built-in engine: false)"); @@ -788,13 +787,70 @@ var test_implements = { .field("GROUP_CONCAT(DISTINCT test_score ORDER BY test_score DESC SEPARATOR ' ')") .group("name") .toString()); + }, + + // profile: data/test-msoffice-20231219.json + "open_excel_file": function() { + var Office = require("lib/msoffice"); + var excel = new Office.Excel(); // Create an Excel instance + excel.open("data\example.xlsx"); // Open the Excel window + }, + + "open_excel_with_chatgpt": function() { + // Load libraries + var Office = require("lib/msoffice"); + var ChatGPT = require("lib/chatgpt"); + + // Create an Excel instance + var excel = new Office.Excel(); + + // List of questions + var questions = [ + "Which one does Mom like, and which one does Dad like?", + "If 100 billion won is deposited into my bank account without my knowledge, what would I do?", + "If my friend passed out from drinking, and Arnold Schwarzenegger suggests having a drink together alone, is it okay to ditch my friend and go with him?", + "If there's a snake in our tent during the company camping trip, should I wake up the manager, or should I escape on my own without waking him up?" + ]; + + // Open the Excel window + excel.open(); + + // Answer to questions + var i = 1; + questions.forEach(function(x) { + var answer = ChatGPT.chat(x); + console.log("Answer:", answer); + excel.getCellByPosition(i, 1).setValue(answer); + i++; + }); + + // Close the Excel window + //excel.close(); + }, + + "open_powerpoint_file": function() { + var Office = require("lib/msoffice"); // Load libraries + var powerpoint = new Office.PowerPoint(); // Create a PowerPoint instance + powerpoint.open("data\example.pptx"); // Open the PowerPoint window + }, + + "open_word_file": function() { + var Office = require("lib/msoffice"); // Load libraries + var word = new Office.Word(); // Create an Word instance + word.open("data\example.docx"); // Open the Word window } }; function main(args) { + // EXAMPLE: cscript app.js testloader if (args.length > 0) { var test_id = args[0]; + var profilefile = args[1]; + // load the test profile + var profile = JSON.parse(FILE.readFile(profilefile, FILE.CdoCharset.CdoUTF_8)); + + // do test if (test_id in test_implements) { var test = profile.tests.find(function(x) { return (x.id == test_id);