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 script will check to see if Spotify is already running, and if so activate it, otherwise open Spotify. Code:var spotifyWindows = sp.AllApplications().Where(a => a.Process.MainModule.FileName.includes("Spotify.exe"));
if(spotifyWindows) {
var mainSpotifyWindow = sp.WindowFromHandle(spotifyWindows.First().Process.MainWindowHandle);
mainSpotifyWindow.Activate();
} else {
// Open spotify (obviously change the path accordingly)
sp.RunProgram('Spotify.exe', '', 'open', '', true, false, false);
}
Edited by user Friday, April 26, 2019 8:34:34 PM(UTC)
| Reason: Not specified
|
3 users 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)
|
This does a similar thing, but for OneNote (Office16 version, change exe name accordingly). This is a little faster since it doesn't access .Process, but assumes only one app/window is open that ends with " - OneNote" Code:var appWindows = sp.WindowsFromTitleRegex('.* - OneNote$');
if(appWindows && appWindows.Count() > 0) {
appWindows.First().Activate();
} else {
// Open app
var ret = sp.RunProgram('ONENOTE.EXE', '', 'open', '', true, false, false);
}
Edited by user Sunday, April 28, 2019 5:36:35 PM(UTC)
| Reason: Not specified
|
|
|
|
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