ConEmu: Run command in open Tab?

2

5

I'm using ConEmu (which is already open for the task in this question) with running ipython. Now I want to run a command from a second programm (namely notepad++) to make my edited python script run within the conemu/ipython environment.

I'd like to use the magic ipython function %run blaa.py so I'm looking for a command to simply paste a text into conemu where the actual cursor stands and run it (press enter).

I tried via Windows->Run (Ctrl+R) using:

conemu.exe /cmd "%run bla.py" -cur_console

but that does open a new tab in conemu and pasting it in there. But Id like to have it within ipython to run within the actual environment, i.e. the same should happen as if I would type "%run bla.py" within ipython myself manually.

Any ideas? Thanks

tim

Posted 2014-06-13T11:09:46.177

Reputation: 302

1Have you read about GuiMacro? – Maximus – 2014-06-13T11:44:37.250

No I always tried to inject something or do it via command line interface. But I'll have a look straight away, thanks for the hint, let's see what I can do with it :) – tim – 2014-06-13T11:48:38.130

COuldnt really figure out how this could help me. Do have another tip about how to use it in this case? :) Thanks!!!! – tim – 2014-06-13T17:44:40.323

@Maximus: Ok I read a lot about it. The documentation is not very verbose so it was very tough to figure it out. I have now the following: C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe -GuiMacro:0 print("%run process.py"); unfortunately that doesn't automatically execute the line within ConEmu/IPython. I tried to add -GuiMacro:0 keys("{Enter}") or ; keys("{Enter}") to that line to execute the statement "%run process.py" within ConEmu, but that doesn't press enter within ConEmu. Any ideas? Thanks a lot – tim – 2014-06-13T19:14:17.497

Finally figured it out after hours. Answer posted below. – tim – 2014-06-13T19:28:26.550

Why you was trying curly brackets around "Enter"? Any suggestions about "verbosing"? – Maximus – 2014-06-13T22:02:15.313

Because here: https://code.google.com/p/conemu-maximus5/wiki/GuiMacro I have read Keys: Post special keystrokes to the console (AutoHotKey syntax) and {Enter} is AHK Syntax as far as I know ;-)

– tim – 2014-06-14T07:04:23.927

Confused. AHK has too many syntaxes. E.g. WheelDown::AltTab, !{tab}, ^c... Somewhere brackets used, somewhere not. – Maximus – 2014-06-14T10:58:23.273

Yeah right, but that was the only hint I could figure out and like I said, I googled on how to send Enter via AHK and only found {Enter} for it. But now, I've figured it out finally by using \n, so everything alright now :-) – tim – 2014-06-14T11:19:26.547

Answers

2

Well, after the hint of "GuiMacro" from Maximus and a LOT OF searching, reading and thinking about it, I finally figured it out.

When I now run via Windows->Run (Ctrl+R) the following command:

C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe -GuiMacro:0 print("%run myfile.py\n");

then the code %run myfile.py is pasted into the IPython Tab in ConEmu and executed \n emulates a Enter-keystroke.

Now I can use this from notepad++ via Run (F5) to run the following:

"C:\Program Files (x86)\ConEmu\ConEmu\ConEmuC.exe" -GuiMacro:0 print("%run '$(FULL_CURRENT_PATH)'\n");

assign a shortcut to it (I have Ctrl+Alt+Q) and vice versa -> You can execute your python-file within the open IPython/ConEmu-Session (instead of executing it in usual cmd). SO AWESOME!!!!!! I hope that helps someone in the future!

tim

Posted 2014-06-13T11:09:46.177

Reputation: 302