Skip to content

Commit 3b92a3b

Browse files
committed
hyf_getDocumentPath add hh.exe
1 parent 27ce273 commit 3b92a3b

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

Class_Gdip.ahk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,12 +1137,12 @@ class GDIP_PBitmap extends _GDIP {
11371137
}
11381138

11391139
getStreamFromFile(fp) {
1140-
file := FileOpen(fp, "r")
1141-
hData := dllcall("GlobalAlloc", "uint",0x2, "ptr",file.length, "ptr")
1140+
f := FileOpen(fp, "r")
1141+
hData := dllcall("GlobalAlloc", "uint",0x2, "ptr",f.length, "ptr")
11421142
pData := dllcall("GlobalLock", "ptr",hData, "ptr")
1143-
file.RawRead(pData, file.length)
1143+
f.RawRead(pData, f.length)
11441144
dllcall("GlobalUnlock", "ptr",hData)
1145-
file.Close()
1145+
f.close()
11461146
return this.CreateStreamOnHGlobal(hData)
11471147
}
11481148

Class_UIA.ahk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,6 @@ class UIA {
704704
static CreateFalseCondition() => (comcall(22, this, "ptr*",&newCondition:=0), IUIAutomationBoolCondition(newCondition))
705705

706706
; Creates a condition that selects elements that have a property with the specified value.
707-
; NOTE 是boolean,value要用 ComValue(0xB,-1)
708707
static CreatePropertyCondition(propertyId, value) {
709708
if !(propertyId is integer)
710709
propertyId := this.property.%propertyId%

hyaray.ahk

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -649,20 +649,56 @@ hyf_onekeyHide() {
649649

650650
hyf_getDocumentPath(winTitle:="") { ;获取当前窗口编辑文档的路径
651651
exeName := StrLower(WinGetProcessName(winTitle))
652-
if (exeName == "gvim.exe" || exeName == "iThought.exe")
653-
return WinGetTitle(winTitle)
654-
else if (exeName == "excel.exe")
655-
return ox().ActiveWorkbook.fullname
656-
else if (exeName == "winword.exe")
657-
return ComObjActive("Word.application").ActiveDocument.fullname
658-
else if (exeName == "powerpnt.exe")
659-
return ComObjActive("Powerpoint.application").ActivePresentation.fullname
660-
else if (RegExMatch(substr(getCommandLine(winTitle), 4), "[a-zA-Z]:[^:]+$", &m))
661-
return m[0]
652+
exeName := RegExReplace(exeName, "\.exe$")
653+
switch exeName {
654+
case "gvim": return WinGetTitle(winTitle)
655+
case "ithought": return WinGetTitle(winTitle)
656+
case "excel": return ox().ActiveWorkbook.fullname
657+
case "winword": return ComObjActive("Word.application").ActiveDocument.fullname
658+
case "powerpnt": return ComObjActive("Powerpoint.application").ActivePresentation.fullname
659+
case "hh.exe": return getDocPathOfHH(winTitle)
660+
default:
661+
if (RegExMatch(substr(getCommandLine(winTitle), 4), "[a-zA-Z]:[^:]+$", &m))
662+
return m[0]
663+
}
662664
getCommandLine(winTitle:="") {
663665
for item in ComObjGet("winmgmts:").ExecQuery(format("Select * from Win32_Process where ProcessId={1}", WinGetPID(winTitle)))
664666
return item.CommandLine
665667
}
668+
;comcall 简化了下面3行
669+
;if !dllcall(numget(numget(0,pobj,"UPtr"), 0, "UPtr"), "Ptr",pobj, "Ptr",PID, "Ptr*",&psp:=0)
670+
; && !dllcall(numget(numget(0,psp,"UPtr"),A_PtrSize*3,"UPtr"), "Ptr",psp, "Ptr",Query_Guid4String(&SID,SID), "Ptr",IID=="!"?SID:Query_Guid4String(&IID,IID), "Ptr*",&pobj:=0) {
671+
; dllcall(numget(numget(0,psp,"UPtr"),A_PtrSize*2,"UPtr"), "Ptr",psp)
672+
getDocPathOfHH(winTitle:="") {
673+
ctl := ControlGetHwnd("Internet Explorer_Server1", winTitle)
674+
dllcall("LoadLibrary", "Str","oleacc", "Ptr")
675+
numput('int64',0x11CF3C3D618736E0, 'int64',0x719B3800AA000C81, IID:=buffer(16))
676+
if (!dllcall("oleacc\AccessibleObjectFromWindow", "ptr",ctl, "uint",0, "ptr",IID, "ptr*",&pacc:=0)) {
677+
accWin := ComValue(9, pacc, 1)
678+
chmPath := Query_Service(accWin, "{332C4427-26CB-11D0-B483-00C04FD90119}").document.url
679+
chmPath := RegExReplace(chmPath, "im)mk\:\@MSITStore\:(.*)\:\:.*$", "$1")
680+
chmPath := StrReplace(chmPath, "%20", " ")
681+
return chmPath
682+
}
683+
;没单独放起来,可能有重复
684+
Query_Service(pobj, SID, IID:="!", bRaw:="") {
685+
if (isobject(pobj))
686+
pobj := ComObjValue(pobj)
687+
numput('int64',0x11CE74366D5140C1, 'int64',0xFA096000AA003480, pid:=buffer(16))
688+
res0 := comcall(0, pobj, "Ptr",pid, "Ptr*",&psp:=0)
689+
res3 := comcall(3, psp, "Ptr",Query_Guid4String(&SID, SID), "Ptr",IID=="!"?SID:Query_Guid4String(&IID,IID), "Ptr*",&pobj:=0)
690+
if (!res0 && !res3 || ObjRelease(psp)) {
691+
if (bRaw)
692+
return pobj
693+
else
694+
return ComValue(9, pobj, 1)
695+
}
696+
}
697+
Query_Guid4String(&GUID, sz:="") {
698+
dllcall("ole32\CLSIDFromString", "WStr",sz?sz:sz==""?"{00020400-0000-0000-C000-000000000046}":"{00000000-0000-0000-C000-000000000046}", "Ptr",GUID:=buffer(16,0))
699+
return GUID
700+
}
701+
}
666702
}
667703

668704
;funHwnd 处理 winHwnd 为 true 则添加

0 commit comments

Comments
 (0)