Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
Hello
I want to open UWP applications in Windows10 with strokesplus.net, for example: the Windows Calculator.
But I don't know how. Could you please tell me how to open it?
Thank you!
Nsc
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This works for me: Code:sp.RunProgram("calc", "", "open", "normal", true, false, false);
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
It's been long overdue to make a simpler run command, so I've added a new function in 0.3.5.9: Edited by user Friday, November 22, 2019 3:54:02 AM(UTC)
| Reason: Not specified
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
Rob Thank you very much for your reply. This works on my PC too. Code:sp.RunProgram("calc", "", "open", "normal", true, false, false);
And Thank you for adding this new wonderful function in the next version. But I have a list of other applications to set, and not all of them works well in the way above. In order to open that UWP applications, I need a universal way. Is there an universal way that I can use it to open any UWP Apps with strokesplus.net? For example open the UWP version of 'Inkscape'. (And of course I have a lot of other UWP Apps to set.) Nsc
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
The universal way is to run the applications by their path and executable name.
There's no built-in function to somehow take a program's name and find its path/exe for you. I might look into something to make it easier, but I have a feeling it might be complicated based on many factors.
So just right-click the app's shortcut on the Start menu and get the properties/file location.
|
1 user thanked Rob for this useful post.
|
|
|
Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
Originally Posted by: Rob The universal way is to run the applications by their path and executable name.
There's no built-in function to somehow take a program's name and find its path/exe for you. I might look into something to make it easier, but I have a feeling it might be complicated based on many factors.
So just right-click the app's shortcut on the Start menu and get the properties/file location. Rob Thank you for your reply. It is not easy to get an UWP app's location. Because in the UWP app's context menu there is no properties/file location. Maybe Because that location is not accessable. But finally I found a way to open them. It is like this: (take the Calculator as example) Code:sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\explorer.exe", "shell:appsFolder\\Microsoft.WindowsCalculator_8wekyb3d8bbwe!App", "", "", false, false, false);
I found this way when I saw this: how to open an UWP app from the command lineThe way to open an UWP app from the command line is like this: Code:explorer.exe shell:appsFolder\PackageFamilyName!Application ID
So in strokesplus.net just open "explorer.exe" and set the parameter as "shell:appsFolder\\PackageFamilyName!Application ID" I tried that way and it works. Maybe this is the best way I can found to open an UWP app so far. Nsc
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Ah I see, I've never tried to work with UWP apps in this way. Here's a script that will let you search for apps to get their full execution string (copied to the clipboard) using PowerShell and piping the output into a variable, it also starts the app. If there's only one match, it simply starts the app. If multiple matches were found it presents a list to choose from. I haven't tested it extensively, but it seems to work okay for the few things I've tried. It could probably be improved upon, just threw it together quickly. Code:var searchInputBoxInfo = new InputBoxInfo();
searchInputBoxInfo.Title = 'Search For UWP App';
searchInputBoxInfo.Message = 'Enter a partial name of the UWP app to locate.';
searchInputBoxInfo.AllowDirectInput = true;
searchInputBoxInfo.ShowAtMouseCursor = true;
var searchString = sp.InputBox(searchInputBoxInfo);
if(searchString != null) {
var p = new clr.System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "PowerShell.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = "-command get-appxpackage"
p.Start();
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
var arrayOfLines = output.match(/[^\r\n]+/g);
var inputBoxInfo = new InputBoxInfo();
inputBoxInfo.Title = 'Select UWP App';
inputBoxInfo.Message = 'Select a UWP app below and click OK to activate it.';
for(var i = 0; i < arrayOfLines.length - 1;i++) {
if(arrayOfLines[i].indexOf("PackageFamilyName : ") > - 1) {
var appPackageFam = arrayOfLines[i].replace("PackageFamilyName : ", "") ;
if(appPackageFam.toLowerCase().indexOf(searchString.toLowerCase()) > -1) {
inputBoxInfo.Items.Add(appPackageFam + "!App");
}
}
}
inputBoxInfo.AllowDirectInput = false;
inputBoxInfo.Sort = true;
inputBoxInfo.ShowAtMouseCursor = true;
var appName = "";
if(inputBoxInfo.Items.Count == 1) {
//Only one match found, so just start it
appName = inputBoxInfo.Items[0];
} else {
//Show list of potential apps matched
var res = sp.InputBox(inputBoxInfo);
if(res != null) {
appName = res;
} else {
appName = "";
}
}
if(appName != "") {
//This line copies the full S+ run command for the selected app
//so you can use it directly for much faster opening without searching
clip.SetText(`sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\\\explorer.exe", "shell:appsFolder\\\\${appName}", "", "", false, false, false);`);
//Start the app
sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\explorer.exe", "shell:appsFolder\\"+appName, "", "", false, false, false);
}
}
Edited by user Saturday, November 23, 2019 5:49:00 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
It works. But when no matches were found, it also presents a empty list. So I add an if before line 38: Code:if (inputBoxInfo.Items.Count == 0) {
sp.MessageBox("No App Matches!", "No App Matches!");
}
Maybe it's better to back to search, but I don't know how.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This will create a loop to keep trying if no matches are found, or will exit if you click Cancel at the search dialog. Code://Used to control loop, to keep trying if no match found
var keepTrying = true;
var searchMessage = 'Enter a partial name of the UWP app to locate.';
while (keepTrying) {
var searchInputBoxInfo = new InputBoxInfo();
searchInputBoxInfo.Title = 'Search For UWP App';
searchInputBoxInfo.Message = searchMessage;
searchInputBoxInfo.AllowDirectInput = true;
searchInputBoxInfo.ShowAtMouseCursor = true;
var searchString = sp.InputBox(searchInputBoxInfo);
if(searchString != null) {
var p = new clr.System.Diagnostics.Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = "PowerShell.exe";
p.StartInfo.CreateNoWindow = true;
p.StartInfo.Arguments = "-command get-appxpackage"
p.Start();
var output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
var arrayOfLines = output.match(/[^\r\n]+/g);
var inputBoxInfo = new InputBoxInfo();
inputBoxInfo.Title = 'Select UWP App';
inputBoxInfo.Message = 'Select a UWP app below and click OK to activate it.';
for(var i = 0; i < arrayOfLines.length - 1;i++) {
if(arrayOfLines[i].indexOf("PackageFamilyName : ") > - 1) {
var appPackageFam = arrayOfLines[i].replace("PackageFamilyName : ", "") ;
if(appPackageFam.toLowerCase().indexOf(searchString.toLowerCase()) > -1) {
inputBoxInfo.Items.Add(appPackageFam + "!App");
}
}
}
inputBoxInfo.AllowDirectInput = false;
inputBoxInfo.Sort = true;
inputBoxInfo.ShowAtMouseCursor = true;
if(inputBoxInfo.Items.Count > 0) {
var appName = "";
if(inputBoxInfo.Items.Count == 1) {
//Only one match found, so just start it
appName = inputBoxInfo.Items[0];
} else {
//Show list of potential apps matched
var res = sp.InputBox(inputBoxInfo);
if(res != null) {
appName = res;
} else {
appName = "";
}
}
if(appName != "") {
//App selected, so exit loop
keepTrying = false;
//This line copies the full S+ run command for the selected app
//so you can use it directly for much faster opening without searching
clip.SetText(`sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\\\explorer.exe", "shell:appsFolder\\\\${appName}", "", "", false, false, false);`);
//Start the app
sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\explorer.exe", "shell:appsFolder\\"+appName, "", "", false, false, false);
}
} else {
//No matches found, try search again
searchMessage = 'No matches found. Try again or click Cancel to exit script.';
}
} else {
//Clicked Cancel in the search text popup window, so exit script
keepTrying = false;
}
}
|
|
|
|
Rank: Newbie
Groups: Approved
Joined: 11/6/2019(UTC) Posts: 8
Thanks: 3 times
|
It works well. Thank you! Rob.
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close