win7一键拖动生成快速启动栏

一键拖动生成快速启动工具栏

 

^#x:: ;自动添加快速启动工具栏  
if had_added()  
    ExitApp  
  
ql_add()  
Sleep,200  
if (is_locked())  
{  
    lock_unlock()  
}  
Sleep,200  
clear()  
Sleep,200  
control_move()  
control_set()  
Sleep,200  
lock_unlock()  
blockinput,off  
  
  
;=====================================================  
  
ql_add()  
{  
  
    winactivate,ahk_class Shell_TrayWnd  
    WinGetPos, x, y, w, h, ahk_class Shell_TrayWnd  
    ControlClick, % "x" 0 " y" h, ahk_class Shell_TrayWnd,, R  
blockinput,on  
    while(!menu1_hwnd := waitmenu(click_x, click_y))  
        Sleep, 200  
    ControlSend, ahk_parent, t, ahk_id %menu1_hwnd%  
    ControlSend, ahk_parent, {Right}, ahk_id %menu1_hwnd%  
    WinGetPos, m1x, m1y, m1w, m1h, ahk_id %menu1_hwnd%  
    while(!menu2_hwnd := waitmenu(m1x+m1w, m1y, menu1_hwnd))  
        Sleep, 200  
    ControlSend, ahk_parent,n, ahk_id %menu2_hwnd%  
    WinWait, 新工具栏 - 选择文件夹  
    ControlClick, Edit1, 新工具栏 - 选择文件夹,, L  
    ControlSetText, Edit1, %APPDATA%\Microsoft\Internet Explorer\Quick Launch, 新工具栏 - 选择文件夹  
    ControlSend, Edit1, {Enter}, 新工具栏 - 选择文件夹  
    ControlClick, Button1, 新工具栏 - 选择文件夹  
    ControlGetPos,xs,ys,,,Button1,新工具栏 - 选择文件夹  
  
    Loop  
    {  
  
        IfWinExist, 新工具栏 - 选择文件夹  
        {  
            WinActivate,新工具栏 - 选择文件夹  
            MouseMove,xs+5,ys+5,0  
            Send {LButton}  
        }  
        else  
        {  
            break  
        }  
        Sleep, 200  
    }  
}  
  
  
  
is_locked()  
{  
    RegRead, Status, HKCU, Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove  
    return !Status  
}  
  
lock_unlock()  
{  
    WinGetPos, x, y, w, h, ahk_class Shell_TrayWnd  
    ControlClick,% "x" x " y" y+h, ahk_class Shell_TrayWnd,, R  
    while(!Menu_hwnd := waitmenu(Click_x, Click_y))  
    Sleep, 200  
    ControlSend, ahk_parent, l, ahk_id %Menu_hwnd%  
}  
clear()  
{  
    WinGet, ctr_list, ControlList, ahk_class Shell_TrayWnd  
    Loop, Parse, ctr_list, `n, `r  
    {  
        if InStr(A_LoopField,"ToolbarWindow32")  
        {  
            ControlGetText, txt, % A_LoopField, ahk_class Shell_TrayWnd  
            if (txt="Quick Launch")  
            {  
                ql_ctr := A_LoopField  
                break  
            }  
        }  
    }  
    if ql_ctr  
    {  
        ControlGet, ql_ctr_hwnd, Hwnd, , % ql_ctr, ahk_class Shell_TrayWnd  
        WinGetPos, x, y, w, h, ahk_id %ql_ctr_hwnd%  
        ControlClick, % "x" 0 " y" h, ahk_id %ql_ctr_hwnd%,, R  
        while(!Menu1_hwnd := waitmenu(x, y+h))  
        Sleep, 200  
        ControlSend, ahk_parent, v, ahk_id %Menu1_hwnd%  
        ControlSend, ahk_parent, {Right}, ahk_id %Menu1_hwnd%  
        WinGetPos, m1x, m1y, m1w, m1h, ahk_id %Menu1_hwnd%  
        while(!Menu2_hwnd := waitmenu(m1x+m1w, m1y, Menu1_hwnd))  
        Sleep, 200  
        ControlSend, ahk_parent, g, ahk_id %Menu2_hwnd%  
        WinWaitClose, ahk_id %Menu2_hwnd%  
  
        WinGetPos, x, y, w, h, ahk_id %ql_ctr_hwnd%  
        ControlClick, % "x" 0 " y" h, ahk_id %ql_ctr_hwnd%,, R  
        while(!Menu3_hwnd := waitmenu(x, y+h))  
        Sleep, 200  
        ControlSend, ahk_parent, x, ahk_id %Menu3_hwnd%  
        WinWaitClose, ahk_id %Menu3_hwnd%  
  
        WinGetPos, x, y, w, h, ahk_id %ql_ctr_hwnd%  
        ControlClick, % "x" 0 " y" h, ahk_id %ql_ctr_hwnd%,, R  
        while(!Menu4_hwnd := waitmenu(x, y+h))  
        Sleep, 200  
        ControlSend, ahk_parent, w, ahk_id %Menu4_hwnd%  
        WinWaitClose, ahk_id %Menu4_hwnd%  
    }  
}  
  
control_move()  
{  
    Loop,5  
    {  
        ControlGetPos,x2,y2,,,MSTaskListWClass1,ahk_class Shell_TrayWnd  
        ControlGetPos,x,y,,,ToolbarWindow323,ahk_class Shell_TrayWnd  
        if (x>x2)  
{  
        WinActivate,ahk_class Shell_TrayWnd  
        MouseMove,x-5,y+5,0  
        Send {LButton down}  
        Sleep,350  
        MouseMove,0,y+5,8  
        Send {LButton up}  
}  
else  
{  
break  
}  
    }  
}  
  
control_set()  
{  
    blockinput,on  
    WinActivate,ahk_class Shell_TrayWnd  
    ControlGetPos,x,y,w,h,ToolbarWindow323,ahk_class Shell_TrayWnd  
    ControlGetPos,x2,y2,,,MSTaskListWClass1,ahk_class Shell_TrayWnd  
    MouseMove,x+w+(x2-x-w)*2/3,h/2,0  
    Send {LButton down}  
    Sleep,200  
    ControlGetPos,,,w0,h,ToolbarWindow323,ahk_class Shell_TrayWnd  
wc:=w0/2  
mousemove,-wc,0,5,r  
con:=0  
loop  
{  
    if (wc<1)  
    {  
        break  
    }  
    wc:=wc/2  
    ControlGetPos,,,w,h,ToolbarWindow323,ahk_class Shell_TrayWnd  
    if ((w0-wc*2>w)and(con=0))  
{  
    con:=1  
  
}  
else if ((w0-wc*2=w)and(con=0))  
{  
    con:=0  
}  
else if ((w0+wc*2<w)and(con=1))  
{  
    con:=0  
  
}  
else if ((w0-wc*2=w)and(con=1))  
{  
con:=1  
}  
  
if (con=0)  
{  
w0:=w  
mousemove,-wc,0,5,r  
}  
else  
{  
        w0:=w  
        mousemove,wc,0,5,r  
}  
  
  
}  
    Send {LButton up}  
blockinput,off  
}  
  
had_added(){  
    WinGet, ctr_list, ControlList, ahk_class Shell_TrayWnd  
    Loop, Parse, ctr_list, `n, `r  
    {  
        if InStr(A_LoopField,"ToolbarWindow32")  
        {  
            ControlGetText, txt, % A_LoopField, ahk_class Shell_TrayWnd  
            if (txt="Quick Launch")  
            {  
                ql_ctr := A_LoopField  
                break  
            }  
        }  
    }  
    if ql_ctr  
        return 1  
}  
  
  
waitmenu(click_x, click_y, ex_hwnd:="")  
{  
    WinGet, wins, List  
    a := ""  
    Loop % wins  
    {  
        win := wins%A_index%  
        WinGetPos, x, y, w, h, ahk_id %win%  
        WinGetTitle, title, ahk_id %win%  
        if (!title && (Abs(Click_y-y)<8 || Abs(Click_y-(y+h))<8) && w<300 && w>80 && h>20 && (ex_hwnd ? win<>ex_hwnd : 1))  
{  
            return win  
}  
    }  
}  

 

posted on 2017-04-04 13:56  zhanglei1371  阅读(526)  评论(0编辑  收藏  举报

导航