Code: Select all
Prototype DwmGetWindowAttribute(hWnd,dwAttribute.l,*pvAttribute,cbAttribute.l)
Global DwmGWA.DwmGetWindowAttribute,hWnd,title${#MAX_PATH},class${#MAX_PATH}
#DWMWA_CLOAKED = 14
Global handle
Procedure GetWinHandle(pro$)
hWnd = FindWindow_(0, 0)
Repeat
hWnd = GetWindow_(hWnd, #GW_HWNDNEXT)
If hWnd And IsWindowVisible_(hWnd) And GetWindowLongPtr_(hWnd, #GWL_HWNDPARENT) = 0
GetWindowText_(hWnd, @title$, #MAX_PATH)
GetClassName_(hWnd,@class$,#MAX_PATH)
If class$ = "ApplicationFrameWindow" Or class$ = "Windows.UI.Core.CoreWindow"
dll = OpenLibrary(#PB_Any,"DWMAPI.DLL")
If dll
DwmGWA = GetFunction(dll,"DwmGetWindowAttribute")
If DwmGWA
DwmGWA(hWnd,#DWMWA_CLOAKED,@Cloaked,SizeOf(Cloaked))
If Cloaked = 0 And title$ = pro$
handle = hwnd
ProcedureReturn handle
EndIf
EndIf
CloseLibrary(dll)
EndIf
EndIf
EndIf
Until hWnd = 0
ProcedureReturn #False
EndProcedure
RunProgram("Calc.exe")
Delay(1000)
GetWinHandle("Calculator")
If Handle
GetWindowRect_(handle,r.RECT)
hWndOver = WindowFromPoint_((r\top+5) << 32 + r\right-20)
GetWindowRect_(hWndOver,r.RECT)
Debug "Button Width : "+Str((r\right - r\left) /4)
Debug "Button Height : "+Str(r\bottom-r\top)
SendMessage_(Handle, #WM_SYSCOMMAND, #SC_CLOSE, 0)
Else
MessageRequester("Info","Not a UWP application",#MB_OK|#MB_ICONINFORMATION)
EndIf



