How to regain the selected content when the script is running

hello,
Once the script starts running that clickdata seems to be the same.I want to get the selected files in real time to calculate their hash values.
thanks

function OnClick(clickData)
{
    d=DOpus.Dlg
    d.Window=clickData.func.sourcetab
    d.template = "a123"
    d.detach =true
    d.Show()

    do{
        msg=d.GetMsg()
        if (msg.event=="click" && msg.control=="button1"){
            hs=""
            list=new Enumerator(DOpus.listers);
            list.moveFirst()
            for (s=new Enumerator(list.item().activetab.selected_files);!s.atEnd();s.moveNext()){
                s.moveFirst()
                sf=s.item()
                hs=hs+DOpus.FSUtil.Hash(sf,"sha")    
            }

            //bianji=d.Control("edit1").value
            d.Control("static1").label= hs
            
        }
        else if(msg.event=="click" && msg.control=="button2"){
            input=d.Control("edit1").value
            shengcheng=d.Control("static1").label
            if (input==shengcheng){
                d.Control("static2").label="good"
            }else{
                d.Control("static2").label="no"
            }
        }
    }
    while(msg==true)
}
<resources>
    <resource name="a123" type="dialog">
        <dialog fontsize="8" height="126" lang="english" width="264">
            <control halign="left" height="18" name="static1" title="计算SHA" type="static" width="216" x="24" y="18" />
            <control default="yes" height="14" name="button1" title="One" type="button" width="50" x="18" y="78" />
            <control height="14" name="button2" title="按钮" type="button" width="50" x="102" y="78" />
            <control halign="left" height="18" name="edit1" title="编辑控件" type="edit" width="216" x="24" y="36" />
            <control halign="left" height="8" name="static2" title="Static" type="static" width="60" x="96" y="60" />
        </dialog>
    </resource>
</resources>


Most of the scripting objects give you a snapshot, to avoid things changing underneath your script (which would usually be bad).

For situations where you want to see an updated view of things, objects that take snapshots usually have an Update method which refreshes them.

e.g. The Listers, Lister and Tab objects all have Update methods.

Thank you very much.It was my mistake, did not look carefully at the manual.