Cynric肖鹏大富lv4

这个人很懒,什么都没有留下!

概览

发布的

订单

邀请码

关注

粉丝

收藏

设置

  • GUI用了第三方库AHK-Object-Oriented-GUIs-master。
    关于FlexGrid控件自己作了扩展。
    用面向对象的方式来写界面,比原生AHK GUI函数舒服多了。贴一下我扩展的FlexGrid控件类。

    Class FlexGridControl extends GuiBase.ControlType {
    Type := "FlexGrid"

    __New(Gui, Options := "", Headers := "", cols := 1) {
    this.Gui := Gui

    Gui % this.Gui.hwnd ":Add", ActiveX, % "hwndhwnd " Options, VSFlexGrid8.VSFlexGridL
    this.hwnd := hwnd
    GuiControlGet, ctlFlexGrid,, %hwnd%,
    this.ax:=ctlFlexGrid

    if(Headers){
    this.ax.Cols := cols
    this.ax.FormatString := Headers

    }

    SafeRef := new IndirectReferenceHolder(this)

    this.Position := new GuiBase.ControlPosition(SafeRef)

    this.Gui.Print(this.__Class " created")

    return SafeRef
    }

    ConnectEvents(FlexGridEvents){
    FlexGridEvents.ax:=this.ax
    ComObjConnect(this.ax, FlexGridEvents)
    FlexGridEvents.Init()
    }
    }

    请教,ActiveX控件的事件响应函数的引用参数,如何返回值?
  • 第一次发贴,不知道为什么提交后代码格式变成了这样,请版主帮忙排下版。

    私密:AutoHotkey的JSON库
  • 用纯ahk实现的Json解析效率实在太低,在将字符串转Json时,当数据过千时,速度太慢。在官网论坛上找到这个Json解析类,是用调用系统JavaScript解释机来处理的,速度很快。

    私密:AutoHotkey的JSON库
  • class JSON
    {
    static JS := JSON._GetJScripObject()
    Parse(JsonString) {
    try oJSON := this.JS.("(" JsonString ")")
    catch {
    MsgBox, Wrong JsonString!
    Return
    }
    Return this._CreateObject(oJSON)
    }

    Stringify(obj) {
    sObj := this._ObjToString(obj)
    Return this.JS.("JSON.stringify(" . sObj . ")")
    }
    _ObjToString(obj) {
    if IsObject( obj ) {
    isArray := true
    for key in obj {
    if IsObject(key)
    throw Exception("Invalid key")
    if !( key = A_Index || isArray := false )
    break
    }
    str:=""
    for k, v in obj
    str .= ( A_Index = 1 ? "" : "," ) . ( isArray ? "" : k . ":" ) . this._ObjToString(v)

    Return isArray ? "[" str "]" : "{" str "}"
    }
    else if !(obj*1 = "" || RegExMatch(obj, "s"))
    Return obj
    else
    Return """" obj """"
    }
    _GetJScripObject() {
    static doc
    doc := ComObjCreate("htmlfile")
    doc.write("")
    JS := ObjBindMethod(doc.parentWindow, "eval")
    JSON._AddMethods(JS)
    Return JS
    }

    _AddMethods(ByRef JS) {
    JScript =
    (
    Object.prototype.GetKeys = function () {
    var keys = []
    for (var k in this)
    if (this.hasOwnProperty(k))
    keys.push(k)
    return keys
    }
    Object.prototype.IsArray = function () {
    var toStandardString = {}.toString
    return toStandardString.call(this) == '[object Array]'
    }
    )
    JS.(JScript)
    }

    _CreateObject(ObjJS) {
    res := ObjJS.IsArray()
    if (res = "")
    Return ObjJS

    else if (res = -1) {
    obj := []
    Loop % ObjJS.length
    obj[A_Index] := this._CreateObject(ObjJS[A_Index - 1])
    }
    else if (res = 0) {
    obj := {}
    keys := ObjJS.GetKeys()
    Loop % keys.length
    k := keys[A_Index - 1], obj[k] := this._CreateObject(ObjJS[k])
    }
    Return obj
    }
    }

    私密:AutoHotkey的JSON库
个人中心
购物车
优惠劵
有新私信 私信列表
搜索