Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #If WinActive("ahk_exe firefox.exe") && DomainSearch("google.com")
- F1::MsgBox You are on Google!
- #If
- DomainSearch(SearchDomain) {
- url := GetUrl()
- RegExMatch(url, "\/\/\K[^\/]+", urlDomain)
- return !!InStr(urlDomain, SearchDomain)
- }
- ; Version: 2022.07.06.1
- ; https://gist.github.com/7cce378c9dfdaf733cb3ca6df345b140
- GetUrl()
- {
- static conditions := []
- hWnd := WinExist("A")
- WinGetClass wClass
- ; CLSID_CUIAutomation, IID_IUIAutomation
- IUIAutomation := ComObjCreate("{ff48dba4-60ef-4201-aa87-54103eef594e}", "{30cbe57d-d9d0-452a-ab13-7ac5ac4825ee}")
- ; IUIAutomation::ElementFromHandle
- DllCall(NumGet(NumGet(IUIAutomation+0)+6*A_PtrSize), "Ptr",IUIAutomation, "Ptr",hWnd, "Ptr*",eRoot:=0)
- ctrlTypeId := wClass ~= "Chrome" ? 50030 : 50004
- if (conditions.HasKey(ctrlTypeId)) {
- condition := conditions[ctrlTypeId]
- } else {
- VarSetCapacity(value, 8 + 2 * A_PtrSize), NumPut(3, value, 0, "UShort"), NumPut(ctrlTypeId, value, 8, "Ptr")
- (A_PtrSize = 8)
- ; IUIAutomation::CreatePropertyCondition
- ? DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "Ptr",IUIAutomation, "UInt",30003, "Ptr",&value, "Ptr*",condition:=0)
- : DllCall(NumGet(NumGet(IUIAutomation+0)+23*A_PtrSize), "Ptr",IUIAutomation, "UInt",30003, "UInt64",NumGet(value, 0, "UInt64"), "UInt64",NumGet(value, 8, "UInt64"), "Ptr*",condition:=0)
- }
- ; IUIAutomationElement::FindFirst
- DllCall(NumGet(NumGet(eRoot+0)+5*A_PtrSize), "Ptr",eRoot, "UInt",0x4, "Ptr",condition, "Ptr*",eFirst:=0)
- if (!eFirst)
- return
- VarSetCapacity(propertyValue, 8 + 2 * A_PtrSize), NumPut(0, propertyValue, 0, "UShort"), NumPut(0, propertyValue, 8, "Ptr")
- ; IUIAutomationElement::GetCurrentPropertyValue
- DllCall(NumGet(NumGet(eFirst+0)+10*A_PtrSize), "Ptr",eFirst, "UInt",30045, "Ptr",&propertyValue)
- ObjRelease(eFirst), ObjRelease(eRoot), ObjRelease(IUIAutomation), eFirst := eRoot := IUIAutomation := ""
- return StrGet(NumGet(propertyValue, 8, "Ptr"), "UTF-16")
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement