GitHub地址:https://github.com/Lexikos/ActiveScript.ahk/tree/for-v1
AHK调用JS.ahk
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=95461 jsonData = ( { "err":"0", "data":[ { "date":"2021-06-01", "title":"books", "chap":"2" }, { "date":"2021-02-01", "title":"book", "chap":"28" }, { "date":"2021-01-01", "title":"book three", "chap":"00" }, { "date":"2021-08-01", "title":"vols", "chap":"30" } ] } ) script = ( var obj = %jsonData%; var headers = '', lines = ''; for (var key in obj.data[0]) headers += (headers == '' ? '' : ',') + key; obj.data.forEach(function(item) { var values = ''; for (var key in item) values += (values == '' ? '' : ',') + item[key] lines += '\r\n' + values; }); headers + lines; ) MsgBox, % GetJS().eval(script) GetJS() { static Doc, JS if !Doc { Doc := ComObjCreate("htmlfile") Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">") JS := Doc.parentWindow (Doc.documentMode < 9 && JS.execScript()) } Return JS } ; ==================== 另一个例子 ==================== JSEval(expr) { Doc := ComObjCreate("htmlfile") Doc.write("<meta http-equiv=""X-UA-Compatible"" content=""IE=9"">") return doc.parentwindow.eval(expr) } a := "b+1" MsgBox % JSEval("b = 1;" a)
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)