Get installed programs

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Get installed programs

22 Jan 2018, 19:52

Ive found this amazing script to list all installed programs:

Code: Select all

headers := [ "DISPLAYNAME", "VERSION", "PUBLISHER", "PRODUCTID"
           , "REGISTEREDOWNER", "REGISTEREDCOMPANY", "LANGUAGE", "SUPPORTURL"
           , "SUPPORTTELEPHONE", "HELPLINK", "INSTALLLOCATION", "INSTALLSOURCE"
           , "INSTALLDATE", "CONTACT", "COMMENTS", "IMAGE", "UPDATEINFOURL" ]

data := []           
for k, v in headers
   data.Push( GetAppsInfo({ mask: v, offset: A_PtrSize*(k - 1) }) )

arr := []
for k, v in data
   for i, j in v
      arr[i, k] := j
   
for k, v in arr
{
   str .= (k = 1 ? "" : "`r`n")
   for i, j in v
      str .= (i = 1 ? "" : ", ") . j
}
   
;MsgBox, % str


IfExist, %A_ScriptDir%\Get Installed Apps.txt
{
	FileDelete, %A_ScriptDir%\Get Installed Apps.txt
}


FileAppend,
(
%str%
), % (iniFile:=A_ScriptDir . "\Get Installed Apps.txt"), utf-16

Tooltip, Done.
Sleep, 2000
;Tooltip,
Return
^R::Reload
ExitApp
   
GetAppsInfo(infoType)
{
   static CLSID_EnumInstalledApps := "{0B124F8F-91F0-11D1-B8B5-006008059382}"
        , IID_IEnumInstalledApps  := "{1BC752E1-9046-11D1-B8B3-006008059382}"
        
        , AIM_DISPLAYNAME       := 0x00000001
        , AIM_VERSION           := 0x00000002
        , AIM_PUBLISHER         := 0x00000004
        , AIM_PRODUCTID         := 0x00000008
        , AIM_REGISTEREDOWNER   := 0x00000010
        , AIM_REGISTEREDCOMPANY := 0x00000020
        , AIM_LANGUAGE          := 0x00000040
        , AIM_SUPPORTURL        := 0x00000080
        , AIM_SUPPORTTELEPHONE  := 0x00000100
        , AIM_HELPLINK          := 0x00000200
        , AIM_INSTALLLOCATION   := 0x00000400
        , AIM_INSTALLSOURCE     := 0x00000800
        , AIM_INSTALLDATE       := 0x00001000
        , AIM_CONTACT           := 0x00004000
        , AIM_COMMENTS          := 0x00008000
        , AIM_IMAGE             := 0x00020000
        , AIM_READMEURL         := 0x00040000
        , AIM_UPDATEINFOURL     := 0x00080000
        
   pEIA := ComObjCreate(CLSID_EnumInstalledApps, IID_IEnumInstalledApps)
   arr := []
   while DllCall(NumGet(NumGet(pEIA+0) + A_PtrSize*3), Ptr, pEIA, PtrP, pINA) = 0
   {
      VarSetCapacity(APPINFODATA, size := 4*2 + A_PtrSize*18, 0)
      NumPut(size, APPINFODATA)
      mask := "AIM_" . infoType.mask
      NumPut(%mask%, APPINFODATA, 4)
      DllCall(NumGet(NumGet(pINA+0) + A_PtrSize*3), Ptr, pINA, Ptr, &APPINFODATA)
      ObjRelease(pINA)
      if !pData := NumGet(APPINFODATA, 8 + infoType.offset)  {
         arr.Push("")
         continue
      }
      arr.Push( StrGet(pData, "UTF-16") )
      DllCall("Ole32\CoTaskMemFree", Ptr, pData)  ; not sure, whether it's needed
   }
   Return arr
}
The problem im having and could not figure out is how to make it return values based on what is written here:

Code: Select all

headers := [ "DISPLAYNAME", "VERSION", "PUBLISHER", "PRODUCTID"
           , "REGISTEREDOWNER", "REGISTEREDCOMPANY", "LANGUAGE", "SUPPORTURL"
           , "SUPPORTTELEPHONE", "HELPLINK", "INSTALLLOCATION", "INSTALLSOURCE"
           , "INSTALLDATE", "CONTACT", "COMMENTS", "IMAGE", "UPDATEINFOURL" ]
I tried a few experiments and nothing helped. I want to write any of those headers and in any order and get the values based on that.
It does not work if i do this:

Code: Select all

headers := [ "DISPLAYNAME", "VERSION", "INSTALLLOCATION", "INSTALLSOURCE", "PUBLISHER" ]
I dont need this much info. xD
I mostly need the program name, version and location and maybe publisher/who ever made the program/game.
Any ideas how to make it work with any of the names in any order?
Its really an awesome piece of code. Thanks to whoever coded this. Cant remember where i found it. If anyone also stumbles on it, please link to it. :(
User avatar
theimmersion
Posts: 181
Joined: 09 Jul 2016, 08:34
Location: Serbia

Re: Get installed programs

22 Jan 2018, 23:01

Thank You! Now only left to figure out how retrieve any data in any order.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Fredrik F, Google [Bot], maxkill, RandomBoy, ShatterCoder and 389 guests