Excel_Get

Post your working scripts, libraries and tools
burque505
Posts: 1447
Joined: 22 Jan 2017, 19:37

Re: Excel_Get

05 Dec 2020, 15:22

@Frasier, just FYI: Word_Get.ahk
Regards,
burque505
feiyue
Posts: 260
Joined: 08 Aug 2014, 04:08

Re: Excel_Get

06 Dec 2020, 00:52

This method can automatically get the correct control: :dance: :beer:

Code: Select all


F1:: WordObj:=Word_Get("A")

Word_Get(WinTitle="ahk_class OpusApp")
{
  return Office_Get(WinTitle)
}

Ppt_Get(WinTitle="ahk_class PP12FrameClass")
{
  return Office_Get(WinTitle)
}

Excel_Get(WinTitle="ahk_class XLMAIN")
{
  return Office_Get(WinTitle)
}

Office_Get(WinTitle="")
{
  static h:=DllCall("LoadLibrary", "Str","oleacc", "Ptr")
  WinGet, list, ControlListHwnd, % WinTitle ? WinTitle : "A"
  For i,hWnd in StrSplit(list, "`n")
  {
    ControlGetPos, x, y, w, h,, ahk_id %hWnd%
    if (y<10 or w<100 or h<100)
      Continue
    n:=Acc:=""
    if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd
    , "UInt", 0xFFFFFFF0, "Ptr", 0*(VarSetCapacity(IID,16)
    +NumPut(0x0000000000020400,IID,"Int64")
    +NumPut(0x46000000000000C0,IID,8,"Int64"))+&IID, "Ptr*", pacc)=0
      Acc:=ComObject(9, pacc, 1)
    Try n:=Acc.Application.Version
    if (n)
      return Acc.Application
  }
  MsgBox, 4096,, Error: Can't Get Object From ACC !
  Exit
}


Return to “Scripts and Functions”

Who is online

Users browsing this forum: jacek678 and 16 guests