激活IE指定tab
;功能:激活IE指定tab
/*
测试方法:
打开IE 依次访问
http://www.baidu.com/
http://cn.bing.com/
百度处于不激活状态、必应处于激活状态。
*/
;作者:sunwind
;时间:2015年1月18日01:03:16
;问题反馈:qq 1571657
;http://blog.csdn.net/liuyukuan/article/details/42823645
;测试环境:IE8
;操作系统:WIN7 64
;AHK版本:AutoHotkey Unicode 32-bit 1.1.16.4
iWeb_Activate("百度一下,你就知道")
sleep,1000
iWeb_Activate("微软必应搜索 - 全球搜索,有问必应 (Bing)")
return
iWeb_Activate(sTitle)
{
; thanks Sean
; http://www.autohotkey.com/forum/viewtopic.php?p=231093#231093
DllCall("LoadLibrary", "str", "oleacc.dll")
DetectHiddenWindows, On
;~ WinActivate,% "ahk_id " HWND
;~ WinWaitActive,% "ahk_id " HWND,,5
ControlGet, hTabBand, hWnd,, TabBandClass1, ahk_class IEFrame
ControlGet, hTabUI , hWnd,, DirectUIHWND1, ahk_id %hTabBand%
If hTabUI && DllCall("oleacc\AccessibleObjectFromWindow", "Uint", hTabUI, "Uint",-4, "Uint", GUID(IID_IAccessible,"{618736E0-3C3D-11CF-810C-00AA00389B71}"), "UintP", pacc)=0
{
Loop, % pacc.accChildCount
If paccChild:=pacc.accChild[A_Index]
If paccChild.accRole[0] = 0x3C
{
paccTab:=paccChild
Break
}
}
If pacc:=paccTab
{
Loop, % pacc.accChildCount
If paccChild:=pacc.accChild[A_Index]
If paccChild.accName[0] = sTitle
{
paccChild.accDoDefaultAction[0]
Break
}
}
WinActivate,% sTitle
}
GUID(ByRef GUID, sGUID) ; Converts a string to a binary GUID and returns its address.
{
VarSetCapacity(GUID, 16, 0)
return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

