Processing Ajax...

Title
Close Dialog

Message

Confirm
Close Dialog

Confirm
Close Dialog

Confirm
Close Dialog

User Image
elvn
14 discussion posts
I'm a novice at displayfusion scripting but I've cobbled together some scripts from various other scripts. My question is how can I get this tricky windows store app "zTwtich" to launch? I know enough to get it working from a desktop shortcut via explorer.exe like this:

// windows command shortcut below:
//
// Start in: C:\Windows\
//
// Target:
// C:\Windows\explorer.exe shell:appsFolder\76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App

I can focus the app if it is already open via either of these methods

//get the main window of ZTwitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");

//or I instead commented that out and used the window title to focus ZTwtich if it's already open, which seemed more reliable:

string windowTitle = "zT";

// Focus the window
IntPtr mainWindow = BFS.Window.GetWindowByText("*" + windowTitle + "*");


But when I try to set it to launch with modified sample code I found, inputting the shell/explorer.exe shortcut info like this it won't work:

// Launch the application (customize the path to match your application)
uint appID = BFS.Application.Start("C:\\Windows\\explorer.exe shell:appsFolder\\76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App", "");

Unlike ZTwtich, the official twitch app itself works fine using this code to launch it:

// Launch the application (customize the path to match your application)
uint appID = BFS.Application.Start("C:\\Users\\<USER NAME>\\AppData\\Roaming\\Twitch\\Bin\\Electron\\TwitchUI.exe", "");


I'd really like to figure this out so that going forward I will be able to focus and operate on, and especially LAUNCH windows store apps that are tricky like ZTwitch. Thanks in advance for any help with this issue.

Edit - This site is helpful if a little obtuse about how and where the windows store apps are located but is focused on making them into a desktop shortcut not launching from displayfusion code:
https://answers.microsoft.com/en-us/windows/forum/windows_10-windows_store/starting-windows-10-store-app-from-the-command/836354c5-b5af-4d6c-b414-80e40ed14675?rtAction=1594306673770&page=1

I realize I can also just open the displayfusion taskbar shortcuts and click on the pinned default zTwitch shortcut to find the application and metro ID's which is very handy, or would be if I can find out how to utilize the information better. :|
Jul 9, 2020 (modified Jul 9, 2020)  • #1
User Image
elvn
14 discussion posts
I pointed it to the shortcut and it seems to be working to launch that way but if anyone knows how to get it to launch from code more like the shortcut's own text please let me know.

I also can't get it to reliably focus on zTwitch for other operations once zTwitch is open when I am using the method that focuses on the .exe.
Only the window title search method works but that can get messy if there is more than one window that says zTwitch in the title (like when I just had the properties of my ZTwitch named shortcut open), and the "by title" method is slower and more clunky. The exe method could be malfunctioning because of the other part of the script not resolving properly from the improper metro/exe path though, since it works fine with the official twitch app exe.

For the working official twitch app version of the script, I have the script focus the app or if it's not open it will launch the app and place it at a set x/y position. If it's minimized it will restore it to the set position, otherwise it will minimize it when the script is activated. So it is a miniminze/restore to set location toggle + app launch function.

For reference, this is the application for ZTwitch:

C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.50.0_x64__crad18n2hztbr\TwitchUWP.exe

This is the Metro (Universal) App ID:

76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App
Jul 9, 2020 (modified Jul 9, 2020)  • #2
Keith Lammers (BFS)'s profile on WallpaperFusion.com
You're close, but the parameters need to be in the second part of the overload, like this:

Code

// Launch the application (customize the path to match your application)
uint appID = BFS.Application.Start("C:\\Windows\\explorer.exe", "shell:appsFolder\\76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App");


As for focusing the window, if there are multiple zTwitch windows open, the only way to uniquely identify them would be if they have something different in their window title.

I noticed that your "focus the window" code is only getting the window handle. I'm assuming you're then passing
BFS.Window.Focus(mainWindow)
?
Jul 10, 2020  • #3
User Image
elvn
14 discussion posts
Thanks for the reply.
My problem is that I would like to focus on windows store apps like zTwitch and others by their .exe rather than searching by the window title's text, but windows store apps are messy in their locations and methods.

//-------How can I make a windows store app like this:

the application for zTwitch

C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.50.0_x64__crad18n2hztbr\TwitchUWP.exe

the Metro (Universal) App ID of zTwitch

76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App

//---- Work like a regular app such as this from the official twitch app? (twitch's app doesn't have the messy windows store app methods that zTwitch has):

//get the main window of the default twitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUI.exe");

// and this to launch the default twitch app
uint appID = BFS.Application.Start("C:\\Users\\<USER NAME>\\AppData\\Roaming\\Twitch\\Bin\\Electron\\TwitchUI.exe", "");

//------------------------------------------
//------------------------------------------

// -- I'm only using the window title by text method since I can't get zTwitch code to work by exe like the official twitch app does.. the text method is inferior to the by exe method so I'd really like to get this to work correctly. I did try it like this below using *TwitchUWP.exe but it didn't work:

//get the main window of zTwitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");

// --- I also tried to launch the zTwitch windows store app by this method which doesn't work:

// Launch the zTwitch windows store app
uint appID = BFS.Application.Start("C:\\Windows\\explorer.exe shell:appsFolder\\76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App", "");

// So I instead had to point the Application.Start to a command/explorer shortcut I made, which isn't preferable and is probably slower:

// Launch the ZTwitch windows store app from a customized shortcut .lnk
uint appID = BFS.Application.Start("C:\\Users\\<UserName>\\Desktop\\<a few subfolders>\\Open-zTwitch.lnk", "");


// --- where the start by exe method does work on the official twitch app below since it doesn't have the messy windows store locations/methods:

// Launch the official twitch application
uint appID = BFS.Application.Start("C:\\Users\\<USER NAME>\\AppData\\Roaming\\Twitch\\Bin\\Electron\\TwitchUI.exe", "");
Jul 10, 2020 (modified Jul 10, 2020)  • #4
User Image
elvn
14 discussion posts
I did swap out the code to what you suggested for BFS.Application.Start of the zTwitch app and that launches it much cleaner. Thanks!

Now I am stuck at focusing zTwitch by it's exe. As a workaround I'm searching my window title but that is slower and less reliable.. it ends up clunky. This is what I'm trying to do

//get the main window of twitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");


I got that information from the windows store / metro information when I pinned the zTwitch app to my displayfusion taskbar. That information is here:

the application for zTwitch

C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.50.0_x64__crad18n2hztbr\TwitchUWP.exe

the Metro (Universal) App ID of zTwitch

76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App

You helped me launch them perfectly, thankfully.
If you can help me get the windows store/metro apps like zTwitch to be focused by their .exe instead of the more clunky search by window title method everything will be resolved perfectly. Thanks in advance for any help.

For reference, the default Twitch app, unlike the windows store/metro zTwitch app, works perfectly using this method:

//get the main window of the default twitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUI.exe");
Jul 11, 2020  • #5
User Image
elvn
14 discussion posts
A little more information:

When I look up the running official twitch app in task manager, it shows the actual program icon and TwitchUI.exe but the 3rd party zTwitch windows store/metro app does not.

The shortcut to zTwitch on the displayfusion taskbar says

the application for zTwitch

C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.50.0_x64__crad18n2hztbr\TwitchUWP.exe

the Metro (Universal) App ID of zTwitch

76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App

When I look up zTwitch as a running app in task manager and click on it's properties, it shows folder icon with this:

76Chococode.Twitch.tvforWindows10_1.17763.121.0_x64__crad18n2hztbr

in the top field instead of an exe, and it says it is in C:\Program Files\Windows Apps

The task manager actually has 2 headings under zTwitch (and other similar windows store/metro apps). The other heading is:

RuntimeBroker.exe

in C:\Windows\System32

So I am still confused as to what I should be putting into the BFS.Application.GetMainWindowByFile when using windows store/metro apps

This below doesn't appear to be working. Is there a command I can use to point to the correct location and focus on the running exe or the RuntimeBroker.exe + zTwitch's exe (which is C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.50.0_x64__crad18n2hztbr\TwitchUWP.exe) ?

//get the main window of zTwitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");
Jul 11, 2020 (modified Jul 11, 2020)  • #6
User Image
elvn
14 discussion posts
The metro app BFS.Application.Start code you replied with works flawlessly.

However BFS.Application.GeMainWindowByFile in order to get the metro app by it's exe is not working. I can make it work with the text search method. I'd really prefer that I could get the metro app by .exe though rather than the window text search method because the .exe method is lightning fast and the text search method is not. It is slow and can be clunky.

So this still doesn't work:

Code

//get the main window of zTwitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");


Is there any way (other than searching by window text) to do the same GetMainWindowByFile type of operation that will work with metro apps like these?
Jul 13, 2020  • #7
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
I can confirm that this is an issue with UWP apps and I've added into our tracking system to try and get it fixed up for the next release. Thanks!
Jul 13, 2020  • #8
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
@elvn: Can you please post a link to the app that you're having issues with so we can test with the upcoming version? Thanks!
Jul 14, 2020  • #9
User Image
elvn
14 discussion posts
Sorry for the delay. I appreciate your direct support.

It is a problem, at least for me, with any windows store apps since they don't launch directly by their listed exe link/shortcut. Windows doesn't even allow making shortcuts from windows store apps by default. I can open a list of all my apps from powershell and make shortcuts to the desktop and move them to wherever from there. Then I can reference that shortcut in order to launch the app as a workaround.

Focusing on the apps doesn't work by their Application ~ exe so scripts and code snippets that focus and operate on apps by exe don't work.

BFS.Application.GetMainWindowByFile

and even BFS.Application.GetMainWindowByAppID fails to work on some of them (more details below).

So I have to resort to focusing on them by text name which isn't as quick and is potentially more buggy at times, using

BFS.Window.GetWindowByText

It seems odd that the DisplayFusion taskbar shortcuts for windows store/metro style apps works to launch them just fine, and for some like the zTwitch version Keith replied with, the "Metro (Universal) App ID" works (for launching, not for focusing.. focusing ~ BFS.Get by file doesn't work)

For example the code Keith replied to me with here works to launch some types of windows store apps:

Code

uint appID = BFS.Application.Start("C:\\Windows\\explorer.exe", "shell:appsFolder\\76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App");

But for some, the Metro(Universal)App ID is listed as "ApplicationFrameHost.exe" so it still doesn't work.
The application heading itself shows the program path and exe, but for the windows store metro apps, pointing to that location doesn't work directly.

For example, when I look up (choose edit) on the DisplayFusion taksbar item for the FooIRC app from the windows store,
it lists this in the application line:
C:\Program Files\WindowsApps\62199Synfron.FooIRC_3.11.4.0_x64__f5vwe4t7vzxt6\FooIRC.UWP.exe

and this in the Metro(Universal) App ID:
{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\ApplicationFrameHost.exe
Jul 22, 2020 (modified Jul 22, 2020)  • #10
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
I would recommend using Window Inspector to look at the application window and grab the correct app ID:
https://www.binaryfortress.com/WindowInspector/Download/

I don't think the string with "ApplicationFrameHost.exe" in it is the correct app ID, and that might be the issue. This inspector application will show you the correct ID to use. :)
Jul 22, 2020  • #11
User Image
elvn
14 discussion posts
As I said, some of the apps show the right ID and so I can launch them with the proper code, but thanks I'll try that out for the ones that don't list the proper one. If it works it would help with -launching- apps.

However I still can't focus or "Get" the running microsoft store apps by the app ID ~ exe name. For example this works with regular apps but not metro apps.

Code

IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*SomeRegularApp.exe");


so I'm instead forced to use the window text search method which is slower and can be clunky so is not desirable.

Code

string windowTitle = "MiscMetroAppTitle";

// Focus the window
IntPtr mainWindow = BFS.Window.GetWindowByText("*" + windowTitle + "*");


I'm admittedly a novice. Putting together snippets of code from other functions has been working ok so far but is there any way to focus running metro apps by file directly (or some other way directly that is consistent on different launches of the app) without a slower and somewhat sloppier search by window title? All of my regular app's windows are able to be focused with the GetMainWindowByFile method. Those regular apps using that method are focused and operated on reliably and pretty much instantaneously while the search by text I'm resorting to with the metro apps is slower and less reliable.
Jul 22, 2020 (modified Jul 22, 2020)  • #12
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
Excellent, the appID thing should help with launching. As for getting the main window I have a case opened for our developers. We should have a beta out next week for testing. :)
Jul 23, 2020  • #13
User Image
elvn
14 discussion posts
I haven't tried any new beta versions if they have been released recently but I'm still hopeful that the UWP windows store apps that run in a sandbox will get supported more directly in future versions of DisplayFusion.

I'd like to bring up another issue with them and ask a question in general.

As you can see, windows store apps are beginning to get like phone/tablet "kiosk"-ware so are more difficult to manage and operate on. Apparently since they run in a sandbox, "always on top" functionality doesn't work with them either. I'm about to test this out with the "Set Window Always on Top" function I downloaded from the DisplayFusion library but I suspect that it won't work on sandboxed Microsoft Store apps.

If you could, aside from the sandbox issue, please let me know if there is a way with proper code to check for the Always on Top state. I know the function sets the state using:

Code

//make the window always on top
        BFS.Window.SetAlwaysOnTop(windowHandle, true);

but I'd like to test if it is false first so that I can make the function a toggle. In a flow chart type layout this is what I'd like to do:

If SetAlwaysonTop == false -> then SetAlwaysOnTop(WindowHandle, true); else SetAlwaysOnTop(WindowHandle, false);

I've edited scripts to test for open?/minimized?/not minimized? as a toggle similarly, I just don't know the proper format to test the AlwaysOnTop parameter for being true/false. I only how to set the parameter as true/false from the sample code.

If I can get that working I'd also set a red frame outline around the always on top windows which toggles with their on/off state as well. Hopefully that will be easy from looking at other existing functions that frame windows.
Aug 12, 2020 (modified Aug 12, 2020)  • #14
Keith Lammers (BFS)'s profile on WallpaperFusion.com
The Toggle Always On Top function will work on UWP app windows :)

You can check if it's enabled as well, like this:

Code

if (BFS.Window.HasWindowStyleEx(BFS.WindowEnum.WindowStyleEx.WS_EX_TOPMOST, windowHandle))
{
    // do something
}


Hope that helps!
Aug 13, 2020  • #15
User Image
elvn
14 discussion posts
Great news and thanks for providing the window state format example in that snippet. I'll give it a shot.

In regard to the other operations by exe not working on sandboxed windows, I'm still using the search by text method for now on those UWP applications. It works but there is some lag so it's nowhere near as clean as using the other code that operates on the exe directly.

I've considered swapping out the window restore to position (x, y, w, h) part of the function to instead just load a saved window position profile name (if possible), for the UWP app functions.. but that would restore all of my saved window positions instead of being able to micromanage each app by it's own hotkey like playing cards/tiles the way I am doing it now. I'd also still have to operate by text of the window name in order to check if it's minimized/minimize it/"restore" by loading window positions profile.

If there was a way to save and later load a window position profile that referenced only one particular app window (while not minimizing the rest) it would probably do the same thing in the end as restoring by exe. I could then just launch that window position profile as the restore for that singular UWP store app without restoring (or minimizing) all of my other windows at the same time. The profile load might end up being as laggy as the text method in the end though potentially.

So I'm still looking forward to a future version of DisplayFusion where I can hopefully operate directly on the exe or other direct reference/ID of the UWP store/sandboxed apps (rather than search by text) to minimize, restore or move to exact position I set like I can do on regular non UWP microsoft store sandboxed apps.

Love this app and the support here is solid. Thanks again.
Aug 15, 2020 (modified Aug 15, 2020)  • #16
Owen Muhlethaler (BFS)'s profile on WallpaperFusion.com
We've just released a new DisplayFusion beta version and this issue should be all fixed up. Please let us know if you run into any trouble after updating.

Thanks!
Aug 19, 2020  • #17
User Image
elvn
14 discussion posts
I finally got around to downloading the beta. I hadn't messed with my scripts in awhile since I redid my pc room and switched a few of my monitors to portrait mode.

Anyway I'm finally going to give it a shot but I'm not sure exactly how you fixed the issue. I'll try a few different methods but did you make it so that I can point to the metro app by it's exe or by it's Metro (Universal App ID ? so that I can later focus it that is.

Using the ZTwitch Metro ~ Microsoft store app for example.
Would it be like this?

Code

//get the main window of zTwitch app by it's executable name
IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");


The full location of the exe is:
C:\Program Files\WindowsApps\76Chococode.Twitch.tvforWindows10_1.17763.124.0_x64__crad18n2hztbr\TwitchUWP.exe

or should I be trying to use Get by the app ID ?

Code

//get the main window of zTwitch app by it's AppID
IntPtr mainWindow = BFS.Application.GetMainWindowByAppID("76Chococode.Twitch.tvforWindows10_crad18n2hztbr!App");


I've been launching the ZTwitch metro app by the app ID like the example you showed me earlier in this thread. I just need to know what code to use to Get the window by file or App ID in the displayfusion beta rather than the GetWindowByText method I had been using before.


thanks again for any help. It's taking a little time to redo my pc and all of my window positions in my new monitor array. Getting the Metro apps quicker like regular exes for further operations would be a big difference.
Sep 20, 2020 (modified Sep 20, 2020)  • #18
Keith Lammers (BFS)'s profile on WallpaperFusion.com
You should be able to get the window by using the process filename like in your first example:

IntPtr mainWindow = BFS.Application.GetMainWindowByFile("*TwitchUWP.exe");


That
GetMainWindowByAppID
function isn't for Metro app IDs, it's something different. You can use it like this:

Code

uint appID = BFS.Application.Start("notepad.exe");
IntPtr window = BFS.Application.GetMainWindowByAppID(appID);


Hope that makes sense!
Sep 22, 2020  • #19
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(1)  Login to Vote(-)