stuncloud
4/3/2014 - 4:53 AM

ダブルクリック検知して任意のプロシージャを実行するよ

ダブルクリック検知して任意のプロシージャを実行するよ

if GET_UWSC_NAME = "DoubleClick.uws" then
    print "sample"
    p = getid(GET_LOGPRINT_WIN)

    DoubleClickEvent.SetEvent()

    while status(p, ST_VISIBLE)
        sleep(0)
    wend

    DoubleClickEvent.RemoveEvent()
endif

module DoubleClickEvent
    const DEFAULT_INTERVAL = 300
    hashtbl bEvent, tic

    procedure DoubleClickEvent
        bEvent[VK_LBUTTON] = FALSE
        bEvent[VK_RBUTTON] = FALSE
        tic[VK_LBUTTON]    = 0
        tic[VK_RBUTTON]    = 0
    fend
    
    procedure SetEvent(procname = "EventProcSample", vk = VK_LBUTTON, interval = DEFAULT_INTERVAL)
        select vk
            case VK_LBUTTON, VK_RBUTTON
                if bEvent[vk] then
                    msgbox("イベントの重複登録はだめ")
                else
                    thread EventThread(procname, vk, interval)
                endif
            default
                msgbox("マウスの左か右ボタンじゃないとだめ")
                exit
        selend
    fend

    procedure EventThread(procname, vk, interval)
        bEvent[vk] = TRUE
        while bEvent[vk]
            if getkeystate(vk) then
                t = GetTickCount()
                if t - tic[vk] < interval then
                    eval(procname + "(vk)")
                    tic[vk] = - interval
                else
                    tic[vk] = t
                endif
                while getkeystate(vk)
                    sleep(0)
                wend
            else
                sleep(0)
            endif
        wend
    fend
    
    procedure RemoveEvent(vk = VK_LBUTTON)
        select vk
            case VK_LBUTTON, VK_RBUTTON
                bEvent[vk] = FALSE
        selend
    fend
    
    procedure EventProcSample()
        print "Double clicked!"
    fend

    procedure EventProcSamplePrintPoint(vk)
        // 引数を取ることで、入力されたキーがわかります
        print "[" + vk + "] " + G_MOUSE_X + ", " + G_MOUSE_Y
    fend
    
    def_dll GetTickCount():dword:kernel32.dll
endmodule