I am not aware of any built-in or low-bar solution for this problem.
If you really need this functionally I guess you would have to craft your own helper app that allows you to specify a process and rearrange its window button on the task bar. This can be achieved, but requires some knowledge of Win32 and C++/C#.I tried it for 30 minutes (my personal limit).
This is what I did: This thread is the perfect starting point: How to get the processes that have systray icon
Point 6. Gives you a working solution for outdated (32bit) versions of Windows: A tool to order the window buttons in your taskbar
Unfortunately, it does not work under 64 bit OS and Windows 10.
Nonetheless, some discoveries I made during my exploration with the sample provide in 6: To find the Taskbar on Window 10, use the following code:
...
//IntPtr hToolbar = User32.FindWindowEx( hTask, IntPtr.Zero, "ToolbarWindow32", null ); xp +
IntPtr taskBarWnd = User32.FindWindowEx(hTask, IntPtr.Zero, "MSTaskListWClass", null);
You will need a 64 bit definition of the TBBUTTON struct:
[StructLayout(LayoutKind.Sequential)]
public struct TBBUTTON
{
public int iBitmap;
public int idCommand;
[StructLayout(LayoutKind.Explicit)]
private struct TBBUTTON_U
{
[FieldOffset(0)]
public byte fsState;
[FieldOffset(1)]
public byte fsStyle;
[FieldOffset(0)]
private IntPtr bReserved;
}
private TBBUTTON_U union;
public byte fsState { get { return union.fsState; } set { union.fsState = value; } }
public byte fsStyle { get { return union.fsStyle; } set { union.fsStyle = value; } }
public UIntPtr dwData;
public IntPtr iString;
}
This should give you a good starting point for a roll-your-own solution.
Another helpful starting point could be the 7+ Taskbar Tweaker, which has some very handy taskbar tweaks (as the name suggests). 7+TT also offers a library that does most of the (black) magic for you and could also server as a starting point for a DIY solution (plus it works even on Windows 1607. Take a look at the print taskbar contents sample; AppId is here a good hook to find the right Taskbar Button Window/Button Group).
Good luck.
Update
With the help of the 7+TT Lib your goal is pretty easy to achieve.
Here is a working sample I have made (the archive contains the source of my sample as well as a binary in the x64/Release folder, called taskbar_pusher, that should work with Windows 7 - 10 up to the latest release v1709).
You have to specify the AppId of the button group you would like to push to the rear end of your taskbar like this as command line parameter:
./taskbar_pusher {1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\notepad.exe
You get the AppId from the CLI output of my tool.
You should be able to call it parameterize like this with AHK (though I am not very familiar with AHK).
PS: I had some problems with my secondary taskbar and therefore disabled the code to detect it.