懒人精灵(一款类似按键精灵的工具) 界面的加载,点击,关闭事件以及控件动态获取或者设置属性

下面是整个流程如果有什么不懂可以加群785554238,里面有最新的版本和相关最新的脚本例子以及插件

2.懒人精灵新版新增了窗口的加载,以及按钮点击事件,关闭事件,以及对ui可动态获取或者其属性值,下面直接先上效果图,然后上代码

1.点击第一个按钮,出现下面界面

2.点击第二个按钮出现下面界面

3.点击第三个按钮出现下面界面

2.下面是窗口属性的设置界面

点击第一个按钮会禁用多选框如下图

点击第二个按钮会隐藏单选框,如下图

点击第三个按钮会在输入框中自动输入你想输入的内容,如下图

下面是代码部分,整个例子工程可以直接在群里下载


function getWinSize()
    local w,h = getDisplaySize()
    local wid = w
    if wid > h then
        wid = h
    end
    wid = wid * 0.8
    return wid,wid
end

local w,h = getWinSize()


function showMsgBox(text)
    showUI("MsgBoxWnd.ui",w * 2 / 3,h / 2,function(hWnd)
        setLableText(hWnd,"idtext",text)
    end,nil,nil)
end

function showInputBox()
    showUI("InputWnd.ui",w * 2 / 3,h / 2,nil,function(hWnd,id)
        if id == "idOk" then
            local text = getEditText(hWnd,"idEdit1")
            toast("你输入的内容是:"..text,0,0,30)
            closeWindow(hWnd,true)
        end
    end,nil)
end

function showEmptyWnd()
    showUI("EmptyWnd.ui",w,h,nil,function(hWnd,id)
        if id == "idClose" then
            closeWindow(hWnd,true)
        end
    end,nil)
end

function onClickEvent(handle,id) --窗口中按钮点击会响应该事件
    if id == "IdopenEmptyWnd" then
        showEmptyWnd()
    elseif id == "IdopenInputWnd" then
        showInputBox()
    elseif id == "IdopenMsgBox" then
        showMsgBox("你好朋友")
    elseif id == "IdopenMsgBox" then
        showMsgBox("你好朋友")
    elseif id == "IdDisableCheck" then
        setViewEnable(handle,"idCheckbox",false)
    elseif id == "IdShowHideRadio" then
        local v = getViewVisible(handle,"idRadiobox")
        if v == 0 then
            setViewVisible(handle,"idRadiobox",8)
        else
            setViewVisible(handle,"idRadiobox",0)
        end
    elseif id == "IdInputText" then
        setEditText(handle,"idEdit1","你好朋友")
    end
end

function onLoadEvent(handle) --窗口加载完成会响应该事件
    toast("窗口加载完成",0,0,30)
end

function onCloseEvent(handle) --窗口关闭会响应该事件
    toast("窗口被摧毁",0,0,30)
end

showUI("MainWnd.ui",w,h,onLoadEvent,onClickEvent,onCloseEvent)


sleep(100000) --等待退出
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值