Skip to content
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d985b2f
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 13, 2023
5f03d2c
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 24, 2023
ea87181
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 27, 2023
18a1cd2
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 29, 2023
747c338
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 31, 2023
c3a5324
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding May 8, 2023
330d587
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding May 19, 2023
f239e6e
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding May 24, 2023
6c238d0
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding May 25, 2023
6b355f0
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Jun 20, 2023
3a4bf52
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Jun 25, 2023
25423d8
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Feb 28, 2024
087f4c8
添加PinApp,UnPinApp,TogglePinApp, IsAppPinned相关方法
huo-feng-ding Mar 5, 2024
581b4f2
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 25, 2024
ca12701
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Mar 28, 2024
f4db535
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Apr 2, 2024
974abe5
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Jun 19, 2024
45a3f2e
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Sep 6, 2024
5ecb609
Merge remote-tracking branch 'origin/v2_port' into v2_port
huo-feng-ding Sep 9, 2024
d3d20f2
Merge remote-tracking branch 'guan/v2_port' into v2_port
huo-feng-ding Jan 3, 2025
e8b2622
Merge remote-tracking branch 'guan/v2_port' into v2_port
huo-feng-ding Feb 10, 2025
2057267
Merge remote-tracking branch 'guan/v2_port' into v2_port
huo-feng-ding Apr 9, 2025
58b4297
Merge remote-tracking branch 'guan/v2_port' into v2_port
huo-feng-ding Oct 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 77 additions & 3 deletions VD.ah2
Original file line number Diff line number Diff line change
Expand Up @@ -356,14 +356,17 @@ class VD {
return IVirtualDesktop_created
}
static _dll_IsAppIdPinned(exe_path) {
DllCall(this.ptr_IsAppIdPinned, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path, "Int*", &appIsPinned := 0)
; DllCall(this.ptr_IsAppIdPinned, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path, "Int*", &appIsPinned := 0)
DllCall(this.ptr_IsAppIdPinned, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "Ptr", exe_path, "Int*", &appIsPinned := 0)
return appIsPinned
}
static _dll_PinAppID(exe_path) {
DllCall(this.ptr_PinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path)
;DllCall(this.ptr_PinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path)
DllCall(this.ptr_PinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "Ptr", exe_path)
}
static _dll_UnpinAppID(exe_path) {
DllCall(this.ptr_UnpinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path)
; DllCall(this.ptr_UnpinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "WStr", exe_path)
DllCall(this.ptr_UnpinAppID, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "Ptr", exe_path)
}
static _dll_IsViewPinned(IApplicationView) {
DllCall(this.ptr_IsViewPinned, "Ptr", this.IVirtualDesktopPinnedApps.Ptr, "Ptr", IApplicationView, "Int*", &viewIsPinned := 0)
Expand Down Expand Up @@ -633,6 +636,77 @@ class VD {
appIsPinned := this._dll_IsAppIdPinned(exe_path)
return appIsPinned
}
static _AppIdFromView(view) {
; revelation, view IS the object, I was looking everywhere for CLSID of IApplicationView

GetAppUserModelId:=this._vtable(view, 17)

; p(GetAppUserModelId)

appId:=0
; VarSetCapacity(appId, 3000)
; DllCall(GetAppUserModelId, "UPtr", view, "Ptr", &appId)
DllCall(GetAppUserModelId, "UPtr", view, "Ptr*", &appId)

; Ptr* passes the address to Receive the string
; &RECT passes the address to, well input the RECT, not for output
; VarSetCapacity(Rect, 16) ; A RECT is a struct consisting of four 32-bit integers (i.e. 4*4=16).
; DllCall("GetWindowRect", "Ptr", WinExist(), "Ptr", &Rect) ; WinExist() returns an HWND.
; MsgBox % "Left " . NumGet(Rect, 0, "Int") . " Top " . NumGet(Rect, 4, "Int")
; . " Right " . NumGet(Rect, 8, "Int") . " Bottom " . NumGet(Rect, 12, "Int")
; wait what?, now I'm confused
; it is because the function says [out]. not in. [in] write to YOUR struct
; , [out] CREATES the struct and returns the pointer to you

; DllCall(GetAppUserModelId, "UPtr", view, "Str", appId)
; p(appId)
; DllCall(GetAppUserModelId, "UPtr", view, "Ptr", &appId)
; p(StrGet(appId, 3000, "UTF-16"))

; https://stackoverflow.com/questions/27977474/how-to-get-appusermodelid-for-any-app-in-windows-7-8-using-vc#27977668
; https://docs.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-getcurrentprocessexplicitappusermodelid?redirectedfrom=MSDN
; [out] PWSTR *AppID
; A pointer that receives the address of the AppUserModelID assigned to the process. The caller is responsible for freeing this string with CoTaskMemFree when it is no longer needed. (lol)

; p(appId)
; p(StrGet(appId, "UTF-16"))

; File := FileOpen(A_LineFile "\..\notes\dump", "w")
; File.RawWrite(0+appId, 3000)
; File.Close()

return appId
}
static IsAppPinned(wintitle) {
found:=this._tryGetValidWindow(wintitle)
if (!found) {
return -1 ;for false
}
thePView:=found[2]
appId:=this._AppIdFromView(thePView)

appIsPinned:=this._dll_IsAppIdPinned(appId)
return appIsPinned
}
static PinApp(wintitle) {
found := this._tryGetValidWindow(wintitle)
if (!found) {
return -1
}
thePView:=found[2]
appId:=this._AppIdFromView(thePView)
this._dll_PinAppID(appId)
}
static UnPinApp(wintitle) {
found:=this._tryGetValidWindow(wintitle)
if (!found) {
return -1 ;for false
}
thePView:=found[2]
appId:=this._AppIdFromView(thePView)

this._dll_UnpinAppID(appId)
}
static TogglePinExe(exe_path) {
appIsPinned := this._dll_IsAppIdPinned(exe_path)
if (appIsPinned) {
Expand Down