;功能:激活IE指定tab /* 测试方法: 打开IE 依次访问 http://www.baidu.com/ http://cn.bing.com/ 百度处于不激活状态、必应处于激活状态。 */ ;作者:sunwind ;时间:2015年1月18日01:03:16 ;问题反馈:qq 157157 ;测试环境: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 : "" }
时间: 2024-10-19 12:19:37