New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conemu - -reuse an instance, but don't bring it to the foreground #1245

Open
mcr74 opened this Issue Sep 4, 2017 · 10 comments

Comments

Projects
None yet
3 participants
@mcr74

mcr74 commented Sep 4, 2017

ConEmu 170316 [32] {Preview}
OS version: Windows 8.1 x64
Used shell version (Far Manager, git-bash, cmd, powershell, cygwin, whatever): git-bash, cmd, powershell, cygwin (doesn't matter)

Problem description

Conemu - -reuse an instance shouldn't bring it to the foreground

I have also posted this on SU: https://goo.gl/DuMCd5

Steps to reproduce

I invoke it from python with:

command = [
  "o:\PAR\ConEmu\ConEmuPortable.exe",
  "-Reuse",
  "-Min",
  "-run", 
  "o:\PAR\PortableGit-2.7.0-64-bit\git-cmd.exe",
  "--no-cd",
  "--command=/usr/bin/bash.exe",
  "-l",
  "-i", 
  # full path to bash file to execute in git-bash on windows e.g. cd to repo
  absfilepath,
  # basename is the script name so that the tab is named after it
  "-cur_console:t:{}".format(basename)
]
subprocess.call(command)

Actual results

The Conemu window gets restored to the foreground

Expected results

The Conemu window stays minimised

Additional files

@Maximus5

This comment has been minimized.

Show comment
Hide comment
@Maximus5

Maximus5 Sep 4, 2017

Owner

That is by design. User expects the opened console ready to execute commands when they run a shell.

Owner

Maximus5 commented Sep 4, 2017

That is by design. User expects the opened console ready to execute commands when they run a shell.

Maximus5 added a commit that referenced this issue Sep 7, 2017

@adrianog

This comment has been minimized.

Show comment
Hide comment
@adrianog

adrianog Sep 7, 2017

But why does it only work only for the first shell? (perhaps the comment is out of date, I notice a related commit)

In any case, here is my problem statement.

I am using Conemu on an industrial scale, and I create a few windows, each containing up to 20 tabs.
What options do I have to load an entire set of tabs (where each tab contains a shell) in the background in a conemu window?

In general, I would like to have the ability to attach shells to conemu instances (as new tabs) without the conemu window coming to the foreground. I am open to suggestions on how to achieve that (the conemuc command line seems to have a few additional options, but I have yet to play with those, and I sense the foregroundness being strong on that side as well...).

adrianog commented Sep 7, 2017

But why does it only work only for the first shell? (perhaps the comment is out of date, I notice a related commit)

In any case, here is my problem statement.

I am using Conemu on an industrial scale, and I create a few windows, each containing up to 20 tabs.
What options do I have to load an entire set of tabs (where each tab contains a shell) in the background in a conemu window?

In general, I would like to have the ability to attach shells to conemu instances (as new tabs) without the conemu window coming to the foreground. I am open to suggestions on how to achieve that (the conemuc command line seems to have a few additional options, but I have yet to play with those, and I sense the foregroundness being strong on that side as well...).

@Maximus5

This comment has been minimized.

Show comment
Hide comment
@Maximus5

Maximus5 Sep 10, 2017

Owner

Switch -min worked for the first instance for an obvious reason: minimize action was not passes to first instance from newly runned one.

By the way, why do you run tabs via -reuse switch? How do you run python scripts? Why don't use -new_console instead?

Owner

Maximus5 commented Sep 10, 2017

Switch -min worked for the first instance for an obvious reason: minimize action was not passes to first instance from newly runned one.

By the way, why do you run tabs via -reuse switch? How do you run python scripts? Why don't use -new_console instead?

@adrianog

This comment has been minimized.

Show comment
Hide comment
@adrianog

adrianog Sep 14, 2017

Switch -min worked for the first instance for an obvious reason: minimize action was not passes to first instance from newly runned one.

I think the indended behaviour of combining those flags for the user it's clear: it should add a tab to a an existing conemu instance (when I have multiple instances this happens to be the last one that was opened), and minimise it if not already minimised.

Is there some nasty coding required to achieve this?

By the way, why do you run tabs via -reuse switch?

This is the problem statement:
What options do I have to load an entire set of tabs (where each tab contains a shell) in the background in a conemu window?

The python script iterates a folder containing .sh files, and executes them one by one with the command above. The first file is executed without the "-reuse" switch, so as to create a new instance. Subsequent files are loaded with the -reuse switch so as to reuse said instance.

How do you run python scripts?

Through windows ftype/assoc mechanism. These is my setup script:

assoc .py=Python.File
assoc .pyc=Python.CompiledFile
assoc .pyo=Python.CompiledFile
assoc .pyw=Python.NoConFile
assoc .pyz=Python.ArchiveFile
assoc .pyzw=Python.NoConArchiveFile

ftype Python.ArchiveFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.CompiledFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.File="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.NoConArchiveFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\pythonw.exe" "%%L" %%*
ftype Python.NoConFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\pythonw.exe" "%%L" %%*

Why don't use -new_console instead?

What would the advantage be?

adrianog commented Sep 14, 2017

Switch -min worked for the first instance for an obvious reason: minimize action was not passes to first instance from newly runned one.

I think the indended behaviour of combining those flags for the user it's clear: it should add a tab to a an existing conemu instance (when I have multiple instances this happens to be the last one that was opened), and minimise it if not already minimised.

Is there some nasty coding required to achieve this?

By the way, why do you run tabs via -reuse switch?

This is the problem statement:
What options do I have to load an entire set of tabs (where each tab contains a shell) in the background in a conemu window?

The python script iterates a folder containing .sh files, and executes them one by one with the command above. The first file is executed without the "-reuse" switch, so as to create a new instance. Subsequent files are loaded with the -reuse switch so as to reuse said instance.

How do you run python scripts?

Through windows ftype/assoc mechanism. These is my setup script:

assoc .py=Python.File
assoc .pyc=Python.CompiledFile
assoc .pyo=Python.CompiledFile
assoc .pyw=Python.NoConFile
assoc .pyz=Python.ArchiveFile
assoc .pyzw=Python.NoConArchiveFile

ftype Python.ArchiveFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.CompiledFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.File="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\python.exe" "%%L" %%*
ftype Python.NoConArchiveFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\pythonw.exe" "%%L" %%*
ftype Python.NoConFile="%%SXDEVICELIVE_ROOT%%\PAR\WinPython-64bit-3.5.2.2Qt5\python-3.5.2.amd64\pythonw.exe" "%%L" %%*

Why don't use -new_console instead?

What would the advantage be?

@Maximus5

This comment has been minimized.

Show comment
Hide comment
@Maximus5

Maximus5 Sep 16, 2017

Owner

Did you ignored new ConEmu build?

To run set of tabs simultaneously you may use -runlist switch.
http://conemu.github.io/en/ConEmuArgs.html

The -new_console would run tabs inside the same window where the script is running.

Owner

Maximus5 commented Sep 16, 2017

Did you ignored new ConEmu build?

To run set of tabs simultaneously you may use -runlist switch.
http://conemu.github.io/en/ConEmuArgs.html

The -new_console would run tabs inside the same window where the script is running.

@adrianog

This comment has been minimized.

Show comment
Hide comment
@adrianog

adrianog Dec 4, 2017

Did you ignored new ConEmu build?

Indeed, I'm running an old build. Assume you've fixed the -reuse bit in the last build. If yes, thanks for that.

To run set of tabs simultaneously you may use -runlist switch.
http://conemu.github.io/en/ConEmuArgs.html

Looks good, thanks. I'll give that a shot

The -new_console would run tabs inside the same window where the script is running.

But I'm executing this from both windows explorer and also by just running the full path command with Windows+R (standard Windows Run dialog). So for that I believe I will have to hardcode a specific conemu title for -reuse in the ftype command.

The problem is that -reuse will not take into consideration the "title" flag. It will reuse whatever last instance had focus.

So I am looking at conemucexe? I can get the conemu window handle from the title with python and pass it as /ATTACH /GHWND=<ConEmuHwnd>

Am I down the right path, or am I missing something more concise to achieve the same?

adrianog commented Dec 4, 2017

Did you ignored new ConEmu build?

Indeed, I'm running an old build. Assume you've fixed the -reuse bit in the last build. If yes, thanks for that.

To run set of tabs simultaneously you may use -runlist switch.
http://conemu.github.io/en/ConEmuArgs.html

Looks good, thanks. I'll give that a shot

The -new_console would run tabs inside the same window where the script is running.

But I'm executing this from both windows explorer and also by just running the full path command with Windows+R (standard Windows Run dialog). So for that I believe I will have to hardcode a specific conemu title for -reuse in the ftype command.

The problem is that -reuse will not take into consideration the "title" flag. It will reuse whatever last instance had focus.

So I am looking at conemucexe? I can get the conemu window handle from the title with python and pass it as /ATTACH /GHWND=<ConEmuHwnd>

Am I down the right path, or am I missing something more concise to achieve the same?

@Maximus5

This comment has been minimized.

Show comment
Hide comment
@Maximus5

Maximus5 Dec 4, 2017

Owner

I don't understand why the -title flag suddenly appeared.
If you "reuse" some window, it would be logical to reuse it at whole, with all settings and the title of course.

Owner

Maximus5 commented Dec 4, 2017

I don't understand why the -title flag suddenly appeared.
If you "reuse" some window, it would be logical to reuse it at whole, with all settings and the title of course.

@adrianog

This comment has been minimized.

Show comment
Hide comment
@adrianog

adrianog Dec 4, 2017

[I've edited the previous comment to remove references to -title alongside -reuse. Currently, when you do -reuse you have no control on what window to reuse. It will be the last one that had focus on - and we agree that the title flag is ignored.]

Now, how do I reuse a specific conemu windows, in the case when I have multiple ones open, and I do not want to reuse the last one, but a specific one (e.g. as identified by the title, or pid).

adrianog commented Dec 4, 2017

[I've edited the previous comment to remove references to -title alongside -reuse. Currently, when you do -reuse you have no control on what window to reuse. It will be the last one that had focus on - and we agree that the title flag is ignored.]

Now, how do I reuse a specific conemu windows, in the case when I have multiple ones open, and I do not want to reuse the last one, but a specific one (e.g. as identified by the title, or pid).

@Maximus5

This comment has been minimized.

Show comment
Hide comment
@Maximus5

Maximus5 Dec 4, 2017

Owner

You may use GuiMacro to create new tab in the specified window. It's upon your script to select it.

Owner

Maximus5 commented Dec 4, 2017

You may use GuiMacro to create new tab in the specified window. It's upon your script to select it.

@adrianog

This comment has been minimized.

Show comment
Hide comment
@adrianog

adrianog Dec 4, 2017

Thank you I'll try and use that.

adrianog commented Dec 4, 2017

Thank you I'll try and use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment