title-match on application pinned to windows taskbar

Q: How do I add command-line arguments to a pinned application and still have it match?

My habits/workflow have a number of apps “pinned” to the windows taskbar, so that Win-# will “always” switch me to the correct window.

image of taskbar pinned icons

(I’m an emacs/ess user for R, no RStudio.) If I have a plot already open, then Win-2 will switch me to the plot window immediately. However, if a plot has not completed yet, then pressing Win-2 will start a new instance of that application. In this case, the icon properties are:

Target: C:RR-3.5.3binx64Rterm.exe

Start in: C:RR-3.5.3binx64

Shortcut key: None

Run: Normal Window

I want to set it up so that inadvertently pressing Win-2 while no plot exists will not start a new instance of Rterm. One mitigating step might be to have Rterm immediately exit by adding --help to the target, but doing so causes the window-name match to fail, and any subsequent plots opening up will not use that taskbar position.

image of taskbar pinned icons plus extra graphic window

Is there a way to add arguments that will not break title-matching? I never intend to start R with that icon (always within emacs/ess), so if there is a way to have it never start an app (just switch to it if created elsewhere), that would be good, too.

(A solution will most likely be windows-centric: R has no control or input on this, I believe.)

Answer

Indeed, this question has little to do with the R Statistical Programming Language.

It is more related to the Microsoft Windows 10 Operating System.

I think that you can start building your solution to this problem by creating an icon on the desktop.

Creating an Icon on the Desktop

Here, you add whatever arguments you need on the Command-Line of the ShortCut represented by the Desktop Icon.

Naming the Desktop Icon

You give the Desktop Icon a name, of course.

The Created Desktop Icon

And you have your Mighty Desktop Icon created for the User’s Delight.

The TaskBar

You drag it on the TaskBar.

Triggering the Windows-3 Key Combination

You press Windows+3 and there you get your Static Software Application launched into effect.

Now, by analyzing the output of the Rterm --help Command-Line, you might find a switch that does not start a new instance of Rterm while no plot exists.

UPDATE:

I think that we might avoid getting the help of an Rterm Expert, @r2evans. I have come up with an One-Liner that you might try.

Just change above the cmd.exe /c pause One-Liner with the %SystemRoot%System32WindowsPowerShellv1.0PowerShell.Exe -Command "If ((Get-Process -Name RTerm) -Eq $()) {Exit-PSSession}" One-Liner.

In short, instead of firing up the Microsoft Windows 10 Command-Line PreProcessor, it fires up the Microsoft Windows PowerShell Shell-Scripting Environment just in order to feed it a simple If Statement that checks if a plot is running and it just exits if there is no plot.

If there is a plot, then pressing the Windows+3 ShortCut Key Combination you just switch to your existing plot.