Jump to content

ApplicationFrameHost.exe - getting the real app


Mateo
 Share

Recommended Posts

Hi,

Continuing with my previous questions, I try to get information about all the open windows, and I have a problem, applications like "Settings", "Music", "Calculator" and the like are displayed to me as ApplicationFrameHost.exe.

Anyone have any idea how I find the real app he wanted? (I want to get the real list of apps, as it appears in the task manager (under "Apps"))

(I tried to search a bit in forums that are not necessarily autoit's and could not find anything)

thank you all 😃!

 

Link to comment
Share on other sites

1 hour ago, Mateo said:

Continuing with my previous questions,

Please explain for people that are not aware of the first question. 

From what I  understand maybe the next functions will help you

WinList ()
WinExists ()

 

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Sorry, I'm really sorry I did not explain myself properly.

I meant this post (which is not what I asked for in the post, but the code appears in the post), where I try to take out the list of windows visible to the user (as it appears in the "Apps" task manager)

Link to comment
Share on other sites

But by and large, regardless of my code, I just want to know what window is currently in focus for the user, and if it is one of the Windows applications (settings, calculator, weather, etc.) then the resulting process is ApplicationFrameHost.exe.

I'm trying to find a workaround to know what the process really is running ... (maybe try to figure out how Windows manages it, because when it displays the list of "applications" that run (within the task manager) it displays them correctly, without ApplicationFrameHost.exe).

Link to comment
Share on other sites

Link to comment
Share on other sites

#include <Array.au3>
#include <Process.au3>

Local $aPrograms[0][2]
Local $aWinList = WinList()
For $i = 1 To $aWinList[0][0]
  If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
    ReDim $aPrograms[UBound($aPrograms) + 1][2]
    $aPrograms[UBound($aPrograms)-1][0] = $aWinList[$i][0]
    $aPrograms[UBound($aPrograms)-1][1] = _ProcessGetName(WinGetProcess($aWinList[$i][1])) ;here
  EndIf
Next
_ArrayDisplay($aPrograms)

 

Link to comment
Share on other sites

Sorry, I misread the code.  You are replacing window handle with process name.  Fine.  But why window title is not enough for you ?  You know that the window is Calculator or other tool.  i do not understand what you need more.

Ok maybe this is what you are looking for :

#include <Array.au3>
#include <Process.au3>

Local $aPrograms[0][3]
Local $aWinList = WinList()
For $i = 1 To $aWinList[0][0]
  If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
    ReDim $aPrograms[UBound($aPrograms) + 1][3]
    $aPrograms[UBound($aPrograms)-1][0] = $aWinList[$i][0]
    $aPrograms[UBound($aPrograms)-1][1] = $aWinList[$i][1]
    $aPrograms[UBound($aPrograms)-1][2] = _ProcessGetName(WinGetProcess($aWinList[$i][1]))
  EndIf
Next
_ArrayDisplay($aPrograms)

$hWnd = WinGetHandle("[ACTIVE]")
ConsoleWrite ($hWnd & @CRLF)
Local $ind = _ArraySearch($aPrograms, $hWnd, Default, Default, Default, 2, Default, 1)
If Not @error Then MsgBox ($MB_SYSTEMMODAL,"","You are running " & $aPrograms[$ind][0])

 

Edited by Nine
Link to comment
Share on other sites

Take a look, let's say at the Microsoft store, he's telling me I'm running this "ApplicationFrameHost.exe", but the process you see in Task Manager is a completely different process ...

The thing is I need the process that really runs (ApplicationFrameHost.exe does not help me).

I hope now my problem is clear.

 

Thank you!

image.png.51f0e606ce7e9e8e4dc0f7773c5043ae.png

Link to comment
Share on other sites

Link to comment
Share on other sites

You owe me a beer for this B)

#include <Constants.au3>
#include <Process.au3>
#include <WinAPISysWin.au3>
#include <WinAPIProc.au3>
#include <Array.au3>

Opt("MustDeclareVars", 1)

Local $aPrograms[0][4]
Local $aWinList = WinList()
Local $iPID, $sName

For $i = 1 To $aWinList[0][0]
  If $aWinList[$i][0] <> "" And BitAND(WinGetState($aWinList[$i][1]), 2) Then
    $iPID = WinGetProcess($aWinList[$i][1])
    $sName = _ProcessGetName($iPID)
    If $sName = "ApplicationFrameHost.exe" Then
      $iPID = FindTrueApp($aWinList[$i][0], $iPID, $sName)
      If Not $iPID Then ContinueLoop
    EndIf
    _ArrayAdd($aPrograms, $aWinList[$i][0] & "|" & $aWinList[$i][1] & "|" & $iPID & "|" & $sName)
  EndIf
Next

_ArrayDisplay($aPrograms)

Func FindTrueApp($sTitle, $iPID, ByRef $sProcess)
  Local Static $aList = _WinAPI_EnumWindows(True)
  Local $iTruePID
  For $i = 1 To $aList[0][0]
    If WinGetTitle($aList[$i][0]) = $sTitle Then
      $iTruePID = WinGetProcess($aList[$i][0])
      If $iPID <> $iTruePID Then
        $sProcess = _WinAPI_GetProcessName($iTruePID)
        Return $iTruePID
      EndIf
    EndIf
  Next
  Return 0
EndFunc   ;==>FindTrueApp

Working nicely for me...

Link to comment
Share on other sites

I already asked @water but @Nine You helped me a looooooooot. 

I'm ok to send you a French wine bottle if you wish :), or french beers, but maybe less interesting ? 

Pm me !

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

Hi,

@Nine,

This solution works great, only unfortunately it fails to surpass OneNote for example (the app, not the software).

I tried to solve it myself and I don't succeed :(
(The problem is that the process that has the same title is this ApplicationFrameHost.exe...)

Do you think this has a solution?

 

Mateo.

Link to comment
Share on other sites

  • 2 weeks later...

ok! I seem to have this ApplicationFrameHost shenanigan problem too...

(reading, digesting the above....)

ok ok... I think I have a grasp of the situation...

will ask if I have further question...

@Nine

In your function shown below, you defined $aList as a local static:

Func FindTrueApp($sTitle, $iPID, ByRef $sProcess)
  Local Static $aList = _WinAPI_EnumWindows(True)

Why the need to define it as "Static" considering the function always assign values to $aList variable each time it is called?
It does not need to retain previous values.

Lastly, is ApplicationFrameHost.exe the only culprit?
Should I do the FindTrueApp for all Window?

Dan.

Edited by Burgaud
Link to comment
Share on other sites

1 hour ago, Burgaud said:

Why the need to define it as "Static" considering the function always assign values to $aList variable each time it is called?

There is no need to request a new list at every single UWP apps found by WinList.  So I decided to keep the current list.  If this snippet is called repeatedly in a loop, I would change it.   FWIW, It is just a way for me to promote an under valuated feature of AutoIt. ;)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...