Code: Select all
Tab & l::
IfWinNotActive, ahk_exe msedge.exe
Return
Send, ^l
If AddressBarWaitFocused(5)
SendRaw, something
Return
Tab & t::
IfWinNotActive, ahk_exe msedge.exe
Return
Send, ^t
If AddressBarWaitFocused(10)
Send, www.autohotkey.com{Enter}
Else MsgBox, Oops...
Return
AddressBarWaitFocused(maxTolsec) {
beg := A_TickCount
While, not AddressBarFocused() and A_TickCount - beg < maxTolsec * 1000
Continue
Return AddressBarFocused()
}
AddressBarFocused() {
Return GetFocusedElement().Name = "Address and search bar"
}
GetFocusedElement() { ;based on the script from Descolada at https://www.autohotkey.com/boards/viewtopic.php?p=459451#p459451
IUIAutomation := ComObjCreate(CLSID_CUIAutomation := "{ff48dba4-60ef-4201-aa87-54103eef594e}", IID_IUIAutomation := "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
DllCall(NumGet(NumGet(IUIAutomation+0)+8*A_PtrSize), "ptr",IUIAutomation, "ptr*",element) ;IUIAutomation::GetFocusedElement
DllCall(NumGet(NumGet(element+0)+23*A_PtrSize), "ptr", element, "ptr*", name) ;IUIAutomationElement::CurrentName
DllCall(NumGet(NumGet(element+0)+10*A_PtrSize), "ptr", element, "uint",30045, "ptr", (VarSetCapacity(val,8+2*A_PtrSize)+NumPut(0,val,0,"short")+NumPut(0,val,8,"ptr"))*0+&val) ;IUIAutomationElement::GetCurrentPropertyValue
ObjRelease(element)
ObjRelease(IUIAutomation)
Return {"Name":StrGet(name,"utf-16"), "Value":StrGet(NumGet(val,8,"ptr"),"utf-16")}
}